Can I use dijkstra_shortest_paths in BGL on “cyclic” directed graph

At first, Sorry for my english 🙁

my graph’s spec is

  • cyclic
  • directed
  • edge weight is positive or zero

As I know dijsktra algorithm cannot find shortest path of “cyclic” graph. But there is no that restriction in BGL docs (

So I wonder I can find shortest paths of this graph by using dijkstra_shortest_paths in BGL.



Yes, you can in fact use the method.

  1. Dijkstra works with cycles in graphs as long as they are positive
  2. The documentation of the method states, which does not apply given your specs:

Use the Bellman-Ford algorithm for the case when some edge weights are negative

See also