I have a simple example of graph:
ListDigraph g;
ListDigraph::ArcMap<int> length(g);
ListDigraph::ArcMap<string> color(g);
build_graph(g, length, color); // function building the graph
The map length contains the weights of the graph, while the map color contains the color of the arcs.
I would like to solve shortest path using Dijkstra, but in a constrained way: for example, I want to avoid two consecutive red arcs in the path.
Dijkstra in LEMON can be called simply by:
Dijkstra<ListDigraph, ListDigraph::ArcMap> dijkstra_test(g,length);
dijkstra_test.run(s);
How can I add a constrain the shortest path computation ?
Use a modified BFS to search through all paths between start and end. Stop the search when a path is found that meets the constraints.
Notice that this does not give the shortest path that meets the constraints. If you need that, then the search must continue until exhaustion, replacing the path to be output whenever a shorter one is found that meets the constraints.