Find the shortest path in a graph which visits certain nodes

Everyone else comparing this to the Travelling Salesman Problem probably hasn’t read your question carefully. In TSP, the objective is to find the shortest cycle that visits all the vertices (a Hamiltonian cycle) — it corresponds to having every node labelled ‘mustpass’. In your case, given that you have only about a dozen labelled ‘mustpass’, … Read more

Why doesn’t Dijkstra’s algorithm work for negative weight edges?

Recall that in Dijkstra’s algorithm, once a vertex is marked as “closed” (and out of the open set) – the algorithm found the shortest path to it, and will never have to develop this node again – it assumes the path developed to this path is the shortest. But with negative weights – it might … Read more

Graph Algorithm To Find All Connections Between Two Arbitrary Vertices

It appears that this can be accomplished with a depth-first search of the graph. The depth-first search will find all non-cyclical paths between two nodes. This algorithm should be very fast and scale to large graphs (The graph data structure is sparse so it only uses as much memory as it needs to). I noticed … Read more

Finding all cycles in a directed graph

I found this page in my search and since cycles are not same as strongly connected components, I kept on searching and finally, I found an efficient algorithm which lists all (elementary) cycles of a directed graph. It is from Donald B. Johnson and the paper can be found in the following link: http://www.cs.tufts.edu/comp/150GA/homeworks/hw1/Johnson%2075.PDF A … Read more

tech