shortest-path

Minimizing time in transit

依然范特西╮ 提交于 2019-12-08 03:31:01
问题 [Updates at bottom ( including solution source code )] I have a challenging business problem that a computer can help solve. Along a mountainous region flows a long winding river with strong currents. Along certain parts of the river are plots of environmentally sensitive land suitable for growing a particular type of rare fruit that is in very high demand. Once field laborers harvest the fruit, the clock starts ticking to get the fruit to a processing plant. It's very costly to try and send

Variations of Dijkstra's Algorithm for graphs with two weight properties

大兔子大兔子 提交于 2019-12-08 02:50:08
问题 I'm trying to find a heuristic for a problem that is mapped to a directed graph with say non-negative weight edges. However, each edge is associated with two weight properties as opposed to only one weight (e.g. say one is distance, and another one showing how good the road's 4G LTE coverage is!). Is there any specific variation of dijkstra , Bellman Ford , or any other algorithm that pursues this objective? Of course, a naive workaround is manually deriving a single weight property as a

@Query shortestPath return type in Spring Data Neo4j

此生再无相见时 提交于 2019-12-07 14:42:08
问题 What's the return Type of the following query and how do I use it? I tried several things like Path , Iterable<Path> , and others but I always hit some sort of exceptions. It seems to be a LinkedHashMap but are there any other handier object types that I can use? @Query( "START u1=node:User(key= {0}), u2=node:User(key = {1}) " + "MATCH p = shortestPath(u1-[*]-u2) " + "RETURN p") public ??? findShortestPath(String u1, String u2); Am I missing any dependencies? This is the only one that I'm

Modified Dijkstra to find most optimized shortest path given extra properties

微笑、不失礼 提交于 2019-12-07 12:44:34
问题 This is a follow-up question for a question I asked at here. The problem is mapped to a graph with say non-negative weights on edges (no preference if it can be directed or not). However, along with a weight which is actually distance, we also have another property which is data coverage of the edge which can be important factor which route to select given how severe I need internet on my phone (for real-time gaming for example I need good bandwidth). So overall, we want to somehow find a

NetworkX vs Scipy all shortest path algorithms

ぃ、小莉子 提交于 2019-12-07 09:21:20
问题 What are the differences between the NetworkX all shortest paths algorithm and the scipy floyd warshall algorithm? Are there any reasons to prefer one over another? Which is fastest? 回答1: (for those who aren't aware the numpy floyd-warshall algorithm is available in networkx) The networkx description of floyd_warshall_numpy states: Floyd’s algorithm is appropriate for finding shortest paths in dense graphs or graphs with negative weights when Dijkstra’s algorithm fails. This algorithm can

Finding the shortest path in a graph between 2 nodes that goes through a subset of nodes

一曲冷凌霜 提交于 2019-12-06 12:18:23
I'm trying to find out an efficient way of finding the shortest path between 2 nodes in a graph with positive edge costs that goes trough a subset of nodes. More formally: Given a graph G = (U, V) where U is the set of all nodes in the graph and V is the set of all edges in the graph, a subset of U called U' and a cost function say: f : UxU -> R+ f(x, y) = cost to travel from node x to node y if there exists an edge between node x and node y or 0 otherwise, I have to find the shortest path between a source node and a target node that goes trough all the nodes in U'. The order in which I visit

Variations of Dijkstra's Algorithm for graphs with two weight properties

蹲街弑〆低调 提交于 2019-12-06 11:17:04
I'm trying to find a heuristic for a problem that is mapped to a directed graph with say non-negative weight edges. However, each edge is associated with two weight properties as opposed to only one weight (e.g. say one is distance, and another one showing how good the road's 4G LTE coverage is!). Is there any specific variation of dijkstra , Bellman Ford , or any other algorithm that pursues this objective? Of course, a naive workaround is manually deriving a single weight property as a combination of all of them, but this does not look good. Can it be generalized to cases with multiple

Dijkstra's Algorithm Does not generate Shortest Path?

橙三吉。 提交于 2019-12-06 10:29:41
问题 I am working through a shortest path problem using Dijkstra's Algorithm. I am having trouble because the algorithm is supposed to provide the shortest path, but after running the algorithm I get a shorted path by hand. Is this just a by-product of this algorithm? The path I am trying to generate is from a -> z Here is the path that I get from applying the algorithm, taking the shortest distance jump at each vertex I visit: 2 4 2 2 1 2 1 1 8 = 23 a -> d -> g -> k -> r -> n -> q -> p -> t -> z

Implementing Bidirectional A* Shortest Path Algorithm

穿精又带淫゛_ 提交于 2019-12-06 07:39:22
问题 I am implementing a symmetric bidirectional A* shortest path algorithm, as mentioned in [Goldberg and Harrelson,2005]. This is only for understanding the algorithm, therefore I used the most basic version without any optimization steps. My problem is the bidirectional algorithm appears to scan almost two times the number of edges scanned in a uni-directional A* search on the test graph. Example: a s-t query on a road network using A* (left) and bidirectional A* (right). Nodes scanned by the

Minimizing time in transit

偶尔善良 提交于 2019-12-06 07:34:05
[Updates at bottom ( including solution source code )] I have a challenging business problem that a computer can help solve. Along a mountainous region flows a long winding river with strong currents. Along certain parts of the river are plots of environmentally sensitive land suitable for growing a particular type of rare fruit that is in very high demand. Once field laborers harvest the fruit, the clock starts ticking to get the fruit to a processing plant. It's very costly to try and send the fruits upstream or over land or air. By far the most cost effective mechanism to ship them to the