athos@1182: #include athos@1182: athos@1182: #include athos@1182: #include athos@1182: athos@1182: using namespace lemon; athos@1182: athos@1182: athos@1182: int main (int, char*[]) athos@1182: { athos@1182: athos@1182: typedef ListGraph Graph; athos@1182: typedef Graph::Node Node; athos@1182: typedef Graph::Edge Edge; athos@1182: typedef Graph::EdgeMap LengthMap; athos@1182: athos@1182: Graph g; athos@1182: athos@1182: //An example from Ahuja's book athos@1182: athos@1182: Node s=g.addNode(); athos@1182: Node v2=g.addNode(); athos@1182: Node v3=g.addNode(); athos@1182: Node v4=g.addNode(); athos@1182: Node v5=g.addNode(); athos@1182: Node t=g.addNode(); athos@1182: athos@1182: Edge s_v2=g.addEdge(s, v2); athos@1182: Edge s_v3=g.addEdge(s, v3); athos@1182: Edge v2_v4=g.addEdge(v2, v4); athos@1182: Edge v2_v5=g.addEdge(v2, v5); athos@1182: Edge v3_v5=g.addEdge(v3, v5); athos@1182: Edge v4_t=g.addEdge(v4, t); athos@1182: Edge v5_t=g.addEdge(v5, t); athos@1182: athos@1182: LengthMap len(g); athos@1182: athos@1182: len.set(s_v2, 10); athos@1182: len.set(s_v3, 10); athos@1182: len.set(v2_v4, 5); athos@1182: len.set(v2_v5, 8); athos@1182: len.set(v3_v5, 5); athos@1182: len.set(v4_t, 8); athos@1182: len.set(v5_t, 8); athos@1182: athos@1182: std::cout << "The id of s is " << g.id(s)<< ", the id of t is " << g.id(t)<<"."< dijkstra_test(g,len); athos@1182: athos@1182: dijkstra_test.run(s); athos@1182: athos@1182: athos@1182: std::cout << "The distance of node t from node s: " << dijkstra_test.dist(t)<