Changeset 1530:d99c3c84f797 in lemon0.x for demo/hello_lemon.cc
 Timestamp:
 07/04/05 15:08:31 (15 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@2021
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

demo/hello_lemon.cc
r1526 r1530 6 6 typedef lemon::ListGraph Graph; 7 7 typedef Graph::EdgeIt EdgeIt; 8 typedef Graph::Edge Edge; 8 9 typedef Graph::NodeIt NodeIt; 10 typedef Graph::Node Node; 11 typedef Graph::EdgeMap<int> LengthMap; 9 12 using lemon::INVALID; 10 13 11 14 Graph g; 12 15 13 for (int i = 0; i < 3; i++) 14 g.addNode(); 16 Node s=g.addNode(); 17 Node v2=g.addNode(); 18 Node v3=g.addNode(); 19 Node v4=g.addNode(); 20 Node v5=g.addNode(); 21 Node t=g.addNode(); 22 23 Edge s_v2=g.addEdge(s, v2); 24 Edge s_v3=g.addEdge(s, v3); 25 Edge v2_v4=g.addEdge(v2, v4); 26 Edge v2_v5=g.addEdge(v2, v5); 27 Edge v3_v5=g.addEdge(v3, v5); 28 Edge v4_t=g.addEdge(v4, t); 29 Edge v5_t=g.addEdge(v5, t); 15 30 16 for (NodeIt i(g); i!=INVALID; ++i) 17 for (NodeIt j(g); j!=INVALID; ++j) 18 if (i != j) g.addEdge(i, j); 31 LengthMap length(g); 32 33 length.set(s_v2, 10); 34 length.set(s_v3, 10); 35 length.set(v2_v4, 5); 36 length.set(v2_v5, 8); 37 length.set(v3_v5, 5); 38 length.set(v4_t, 8); 39 length.set(v5_t, 8); 19 40 20 41 std::cout << "Hello World!" << std::endl; … … 32 53 std::cout << " (" << g.id(g.source(i)) << "," << g.id(g.target(i)) << ")"; 33 54 std::cout << std::endl; 55 std::cout << std::endl; 56 57 std::cout << "There is a map on the edges (length)!" << std::endl; 58 std::cout << std::endl; 59 for (EdgeIt i(g); i!=INVALID; ++i) 60 std::cout << "length(" << g.id(g.source(i)) << "," << g.id(g.target(i)) << ")="<<length[i]<<std::endl; 61 62 std::cout << std::endl; 63 34 64 }
Note: See TracChangeset
for help on using the changeset viewer.