Changeset 1530:d99c3c84f797 in lemon-0.x for demo
- Timestamp:
- 07/04/05 15:08:31 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2021
- Location:
- demo
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
demo/dijkstra_demo.cc
r1528 r1530 45 45 len.set(v5_t, 8); 46 46 47 std::cout << "This program is a simple demo of the LEMON Dijkstra class."<<std::endl; 48 std::cout << "We calculate the shortest path from node s to node t in a graph."<<std::endl; 49 std::cout <<std::endl; 50 51 47 52 std::cout << "The id of s is " << g.id(s)<< ", the id of t is " << g.id(t)<<"."<<std::endl; 48 53 -
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 } -
demo/lp_demo.cc
r1513 r1530 24 24 //The following example is taken from the documentation of the GLPK library. 25 25 //See it in the GLPK reference manual and among the GLPK sample files (sample.c) 26 27 //A default solver is taken 26 28 LpDefault lp; 27 29 typedef LpDefault::Row Row; … … 37 39 Col x3 = lp.addCol(); 38 40 39 //One solution40 // Row p = lp.addRow();41 // Row q = lp.addRow();42 // Row r = lp.addRow();43 // lp.setRow(p,x1+x2+x3 <=100);44 // lp.setRow(q,10*x1+4*x2+5*x3<=600);45 // lp.setRow(r,2*x1+2*x2+6*x3<=300);46 47 //A more elegant one48 41 //Constraints 49 42 lp.addRow(x1+x2+x3 <=100); … … 70 63 } 71 64 65 //End of LEMON style code 72 66 73 67 //Here comes the same problem written in C using GLPK API routines -
demo/reader_writer_demo.cc
r1528 r1530 16 16 SmartGraph::EdgeMap<int> cap(graph); 17 17 reader.readEdgeMap("capacity",cap); 18 // reader.readNode("source",s).readNode("target",t)19 // .readEdgeMap("capacity",cap).run();20 18 reader.run(); 21 19 … … 31 29 writer.run(); 32 30 33 // LemonReader reader(std::cin);34 35 // NodeSetReader<SmartGraph> nodeset(reader, graph);36 // SmartGraph::NodeMap<int> cost(graph);37 // nodeset.readMap("cost", cost);38 // SmartGraph::NodeMap<char> mmap(graph);39 // nodeset.readMap("mmap", mmap);40 41 // EdgeSetReader<SmartGraph> edgeset(reader, graph, nodeset);42 // SmartGraph::EdgeMap<std::string> description(graph);43 // edgeset.readMap<QuotedStringReader>("description", description);44 45 // NodeReader<SmartGraph> nodes(reader, nodeset);46 // SmartGraph::Node source;47 // nodes.readNode("source", source);48 // SmartGraph::Node target;49 // nodes.readNode("target", target);50 51 // AttributeReader<> attribute(reader, "gui");52 // std::string author;53 // attribute.readAttribute<LineReader>("author", author);54 // int count;55 // attribute.readAttribute("count", count);56 57 // PrintReader print(reader);58 59 // reader.run();60 61 62 // for (SmartGraph::NodeIt it(graph); it != INVALID; ++it) {63 // std::cout << cost[it] << ' ' << mmap[it] << std::endl;64 // }65 66 // for (SmartGraph::EdgeIt it(graph); it != INVALID; ++it) {67 // std::cout << description[it] << std::endl;68 // }69 70 // std::cout << "author: " << author << std::endl;71 // std::cout << "count: " << count << std::endl;72 73 // std::cout << "source cost: " << cost[source] << std::endl;74 // std::cout << "target cost: " << cost[target] << std::endl;75 76 // std::cout.flush();77 31 } catch (DataFormatError& error) { 78 32 std::cerr << error.what() << std::endl; -
demo/route.lgf
r1435 r1530 12 12 0 189.239 92.5316 13 13 @edgeset 14 length 15 2 3 901.074 16 8 5 270.85 17 6 9 601.553 18 5 9 285.022 19 9 4 408.091 20 3 0 719.712 21 7 5 612.836 22 0 4 933.353 23 5 0 778.871 24 5 5 0 25 7 1 664.049 26 5 5 0 27 0 9 560.464 28 4 8 352.36 29 4 9 399.625 30 4 1 402.171 31 1 2 591.688 32 3 8 182.376 33 4 5 180.254 34 3 1 345.283 35 5 4 184.511 36 6 2 1112.45 37 0 1 556.624 14 length id 15 2 3 901.074 0 16 8 5 270.85 1 17 6 9 601.553 2 18 5 9 285.022 3 19 9 4 408.091 4 20 3 0 719.712 5 21 7 5 612.836 6 22 0 4 933.353 7 23 5 0 778.871 8 24 5 5 0 9 25 7 1 664.049 10 26 5 5 0 11 27 0 9 560.464 12 28 4 8 352.36 13 29 4 9 399.625 14 30 4 1 402.171 15 31 1 2 591.688 16 32 3 8 182.376 17 33 4 5 180.254 18 34 3 1 345.283 19 35 5 4 184.511 20 36 6 2 1112.45 21 37 0 1 556.624 22 38 38 @nodes 39 39 source 1 40 40 target 8 41 @edges 42 @attributes 41 43 @end -
demo/sample.lgf
r1528 r1530 1 @nodeset 2 id 3 5 4 4 5 3 6 2 7 1 8 0 9 @edgeset 10 id capacity 11 4 5 6 812 3 5 5 813 2 4 4 514 1 4 3 815 1 3 2 516 0 2 1 1017 0 1 0 1018 @nodes 1 @nodeset 2 id coordinates_x coordinates_y 3 5 796.398 208.035 4 4 573.002 63.002 5 3 568.549 401.748 6 2 277.889 68.476 7 1 288.248 397.327 8 0 102.239 257.532 9 @edgeset 10 id capacity 11 4 5 6 8 12 3 5 5 8 13 2 4 4 5 14 1 4 3 8 15 1 3 2 5 16 0 2 1 10 17 0 1 0 10 18 @nodes 19 19 source 0 20 20 target 5
Note: See TracChangeset
for help on using the changeset viewer.