shortest-path

Finding kth-shortest paths?

不问归期 提交于 2019-12-12 07:09:39
问题 Finding the shortest path between two points in a graph is a classic algorithms question with many good answers (Dijkstra's algorithm, Bellman-Ford, etc.) My question is whether there is an efficient algorithm that, given a directed, weighted graph, a pair of nodes s and t, and a value k, finds the kth-shortest path between s and t. In the event that there are multiple paths of the same length that all tie for the kth-shortest, it's fine for the algorithm to return any of them. I suspect that

Neo4j: Shortest Path with Cost Function depending on two Consecutive Relations in Path

廉价感情. 提交于 2019-12-12 04:58:45
问题 Say I have a graph with nodes representing cities and and relations representing possible connections between cities. A connection has a departure and an arrival time. I want to find the shortest path between cities A and B and the cost function is the total travel time. The travel time is the sum of waiting times between connections and connection times. I'm using the Java API and I have tried using the Dijkstra algorithm using GraphAlgoFactory.dijkstra(expander, costEvaluator) . My main

Neo4J: shortest paths with specific relation types sequence constrain

╄→尐↘猪︶ㄣ 提交于 2019-12-12 03:48:59
问题 I need to find shortest paths between nodes, but with some restrictions on relations types in good paths. I have two relation types: A & B. Path is considered bad if it has two or more consecutive relation of type B: Good path: ()-A->()-A->()<-A-()-B->()-A->()-B->() Bad path: ()-A->()-A->()<-A-() -B->()<-B- ()-A->() The Cypher query: MATCH path=allShortestPaths( (p:P{idp:123})-[rel:A|B*]-(p2:P{idp:124}) ) WHERE *some-predicate-on-path-or-rel* RETURN path is not a solution because the shortest

neo4j: shortest paths constrained by node and rel properties

﹥>﹥吖頭↗ 提交于 2019-12-12 03:02:12
问题 From the tutorial: MATCH p=shortestPath( (keanu:Person)-[:KNOWS*]-(kevin:Person) ) WHERE keanu.name="Keanu Reeves" and kevin.name = "Kevin Bacon" RETURN length(p) Imagine each Person node has an age property and an occupation. Every KNOWS edge has a length of acquaintance property. What Cypher query would return a shortest path with, for instance, age > 40 years not (occupation = ACTOR) lengthOfAcquaintance > 10 years In molecular biology interaction data, we wish to make yet more complex

The first 10 shortest paths in a graph - Igraph 0.6 - Python 2.7

本秂侑毒 提交于 2019-12-12 01:09:16
问题 I was wondering about this ever since I've started to successfully implement Igraph into my coding: Can you retrieve with get_all_shortest_paths as many shortest paths as you like. Let's say first 10. I've understood so far that retrieving ALL shortest paths in a undirected graph is non-sense since in most cases you have infinite amount of them. But can I simply retrieve first 10 shortest paths? I've tried to achieve this with an undirected g = Graph() : list = [] list.append(g.get_all

How to get a polyline for shortest path between two points in leaflet?

落花浮王杯 提交于 2019-12-12 01:05:33
问题 I am new in leaflet and I need to create a layer for shortest path between nodes. I also need the polyline for some other calculations. I tried some plugins which just display the shortest path on map but does not provide furthur details(polyline, point-to-point ...) for the optimal route. Is there any way that I can get the data? any plugin or trick ...? 回答1: You want to use some geocoding (see http://leafletjs.com/plugins.html#geocoding ) to turn addresses into lat-lng coordinates, then

How to find optimal route to one of many markers?

╄→尐↘猪︶ㄣ 提交于 2019-12-11 18:44:37
问题 On a map I have to arrays of markers. One's are static, let's call station . Other's also static, but they are temporary, let's call them fire . When fire is clicked shortest route must be constructed to one of stations . I use TravelMode.DRIVING. I know that I can calculate route distance, but in order to calculate I must construct route first. Is there any library to find optimal route between one fixed marker and one of many other markers? Or can you help me telling logic? I can write code

find the shortestS paths in an unweighted graph by a max flow constraint

早过忘川 提交于 2019-12-11 17:46:43
问题 My problem is that I want to find the shortestS(most possible paths) between a vertex S and T in a graph, but I have a flow constraints too, because the problem state: -you have a number of ants(or whatever) / a number of rooms / and a number of links between them, I've to send my ants one turn at a time, from S through my graph, to reach T, but all rooms can contains only one ants at a time except for S and T and the ants may not get stuck in a room during several turn. so I've a flow graph

Movement of turtles between nodes following the shortest path

橙三吉。 提交于 2019-12-11 17:13:19
问题 I am trying to move my citizens from one node (slocation) to another node (new-location) calculating the shortest path. I could only calculate the distance from slocation to new-location using set total-expected-path [distance [slocation] of myself] of new-location. However, I am pretty sure that the following line after to set total-expected-path are not correct. I got the following error: this code can't be run by a turtle, only a link error while node 35 running LINK-LENGTH How can I

Finding shortest path distances in a graph containing at most two negative edges

女生的网名这么多〃 提交于 2019-12-11 13:59:49
问题 I am given a directed graph where each edge has a cost.Taking advantage of the fact that there are at most two negative edges in the graph, my goal is to find shortest path distances from a given node s to all the nodes in V. The time complexity of the algorithm should be O(|E| + |V|*log|V|) , so I think I need to apply Dijkstra's algorithm. I am guessing that I need to translate my given graph somehow to a new graph with non-negative weights that a shortest path from s to v in this graph