demo/disjoint_paths_demo.cc
changeset 2400 b199ded24c19
parent 2391 14a343be7a5a
child 2514 57143c09dc20
equal deleted inserted replaced
3:80f1fa4dd2a6 4:b201d4f148c8
    43 Color color(bool b) {
    43 Color color(bool b) {
    44   return b ? RED : BLACK;
    44   return b ? RED : BLACK;
    45 }
    45 }
    46 
    46 
    47 int main() {
    47 int main() {
    48   cout << "This program calculates the number " <<
    48   cout << "This program calculates the number " 
    49     "of disjoint paths in a graph" << endl;
    49     "disjoint paths in a graph" << endl;
    50   cout << "The graph is read from the disjoint_paths_demo.lgf file" << endl;
    50   cout << "The graph is read from the disjoint_paths_demo.lgf file" << endl;
    51   typedef SmartGraph Graph;
    51   typedef SmartGraph Graph;
    52 
    52 
    53   Graph graph;
    53   Graph graph;
    54 
    54 
    68   preflow.run();
    68   preflow.run();
    69 
    69 
    70   cout << "Number of edge disjoint paths: " << preflow.flowValue() << endl;
    70   cout << "Number of edge disjoint paths: " << preflow.flowValue() << endl;
    71 
    71 
    72   graphToEps(graph, "edge_disjoint_paths.eps").
    72   graphToEps(graph, "edge_disjoint_paths.eps").
    73     title("edge disjoint path").copyright("(C) 2003-2007 LEMON Project").drawArrows().
    73     title("edge disjoint paths").scaleToA4().
       
    74     copyright("(C) 2003-2007 LEMON Project").drawArrows().
    74     edgeColors(composeMap(functorMap(color), flow)).
    75     edgeColors(composeMap(functorMap(color), flow)).
    75     coords(coords).autoNodeScale().run();
    76     coords(coords).run();
    76 
    77 
    77 
    78 
    78   cout << "The paths are written into edge_disjoint_paths.eps" << endl;
    79   cout << "The paths are written into edge_disjoint_paths.eps" << endl;
    79 
    80 
    80   typedef SplitGraphAdaptor<SmartGraph> SGraph;
    81   typedef SplitGraphAdaptor<SmartGraph> SGraph;
    94 
    95 
    95   cout << "Number of node disjoint paths: " << spreflow.flowValue() << endl;
    96   cout << "Number of node disjoint paths: " << spreflow.flowValue() << endl;
    96 
    97 
    97 
    98 
    98   graphToEps(sgraph, "node_disjoint_paths.eps").
    99   graphToEps(sgraph, "node_disjoint_paths.eps").
    99     title("node disjoint path").copyright("(C) 2003-2007 LEMON Project").drawArrows().
   100     title("node disjoint paths").scaleToA4().
       
   101     copyright("(C) 2003-2007 LEMON Project").drawArrows().
   100     edgeColors(composeMap(functorMap(color), sflow)).
   102     edgeColors(composeMap(functorMap(color), sflow)).
   101     coords(SGraph::combinedNodeMap(coords,
   103     coords(SGraph::combinedNodeMap(coords,
   102 				   shiftMap(coords,
   104 				   shiftMap(coords,
   103 					    dim2::Point<double>(5, 0)))).
   105 					    dim2::Point<double>(5, 0)))).
   104     autoNodeScale().run();
   106     run();
   105 
   107 
   106   cout << "The paths are written into node_disjoint_paths.eps" << endl;
   108   cout << "The paths are written into node_disjoint_paths.eps" << endl;
   107   
   109   
   108   return 0;
   110   return 0;
   109 }
   111 }