demo/topology_demo.cc
changeset 2232 ae8562537502
parent 2174 f9e43b5cc617
child 2242 16523135943d
equal deleted inserted replaced
8:035be99f87a6 9:e589cb439edc
    18 
    18 
    19 #include <lemon/list_graph.h>
    19 #include <lemon/list_graph.h>
    20 #include <lemon/topology.h>
    20 #include <lemon/topology.h>
    21 #include <lemon/graph_to_eps.h>
    21 #include <lemon/graph_to_eps.h>
    22 #include <lemon/graph_reader.h>
    22 #include <lemon/graph_reader.h>
    23 #include <lemon/xy.h>
    23 #include <lemon/dim2.h>
    24 
    24 
    25 #include <iostream>
    25 #include <iostream>
    26 
    26 
    27 #include <cstdlib>
    27 #include <cstdlib>
    28 #include <ctime>
    28 #include <ctime>
    47 void drawConnectedComponents() {
    47 void drawConnectedComponents() {
    48   typedef ListUGraph Graph;
    48   typedef ListUGraph Graph;
    49   typedef Graph::Node Node;
    49   typedef Graph::Node Node;
    50 
    50 
    51   Graph graph;
    51   Graph graph;
    52   Graph::NodeMap<xy<double> > coords(graph);
    52   Graph::NodeMap<dim2::Point<double> > coords(graph);
    53 
    53 
    54   UGraphReader<Graph>("u_components.lgf", graph).
    54   UGraphReader<Graph>("u_components.lgf", graph).
    55     readNodeMap("coordinates_x", xMap(coords)).
    55     readNodeMap("coordinates_x", xMap(coords)).
    56     readNodeMap("coordinates_y", yMap(coords)).
    56     readNodeMap("coordinates_y", yMap(coords)).
    57     run();
    57     run();
    72 void drawStronglyConnectedComponents() {
    72 void drawStronglyConnectedComponents() {
    73   typedef ListGraph Graph;
    73   typedef ListGraph Graph;
    74   typedef Graph::Node Node;
    74   typedef Graph::Node Node;
    75 
    75 
    76   Graph graph;
    76   Graph graph;
    77   Graph::NodeMap<xy<double> > coords(graph);
    77   Graph::NodeMap<dim2::Point<double> > coords(graph);
    78 
    78 
    79   GraphReader<Graph>("dir_components.lgf", graph).
    79   GraphReader<Graph>("dir_components.lgf", graph).
    80     readNodeMap("coordinates_x", xMap(coords)).
    80     readNodeMap("coordinates_x", xMap(coords)).
    81     readNodeMap("coordinates_y", yMap(coords)).
    81     readNodeMap("coordinates_y", yMap(coords)).
    82     run();
    82     run();
   102   typedef ListUGraph Graph;
   102   typedef ListUGraph Graph;
   103   typedef Graph::Node Node;
   103   typedef Graph::Node Node;
   104   typedef Graph::UEdge UEdge;
   104   typedef Graph::UEdge UEdge;
   105 
   105 
   106   Graph graph;
   106   Graph graph;
   107   Graph::NodeMap<xy<double> > coords(graph);
   107   Graph::NodeMap<dim2::Point<double> > coords(graph);
   108 
   108 
   109   UGraphReader<Graph>("u_components.lgf", graph).
   109   UGraphReader<Graph>("u_components.lgf", graph).
   110     readNodeMap("coordinates_x", xMap(coords)).
   110     readNodeMap("coordinates_x", xMap(coords)).
   111     readNodeMap("coordinates_y", yMap(coords)).
   111     readNodeMap("coordinates_y", yMap(coords)).
   112     run();
   112     run();
   132   typedef ListUGraph Graph;
   132   typedef ListUGraph Graph;
   133   typedef Graph::Node Node;
   133   typedef Graph::Node Node;
   134   typedef Graph::UEdge UEdge;
   134   typedef Graph::UEdge UEdge;
   135 
   135 
   136   Graph graph;
   136   Graph graph;
   137   Graph::NodeMap<xy<double> > coords(graph);
   137   Graph::NodeMap<dim2::Point<double> > coords(graph);
   138 
   138 
   139   UGraphReader<Graph>("u_components.lgf", graph).
   139   UGraphReader<Graph>("u_components.lgf", graph).
   140     readNodeMap("coordinates_x", xMap(coords)).
   140     readNodeMap("coordinates_x", xMap(coords)).
   141     readNodeMap("coordinates_y", yMap(coords)).
   141     readNodeMap("coordinates_y", yMap(coords)).
   142     run();
   142     run();
   161   typedef ListUGraph Graph;
   161   typedef ListUGraph Graph;
   162   typedef Graph::Node Node;
   162   typedef Graph::Node Node;
   163   typedef Graph::UEdge UEdge;
   163   typedef Graph::UEdge UEdge;
   164 
   164 
   165   Graph graph;
   165   Graph graph;
   166   Graph::NodeMap<xy<double> > coords(graph);
   166   Graph::NodeMap<dim2::Point<double> > coords(graph);
   167 
   167 
   168   UGraphReader<Graph>("partitions.lgf", graph).
   168   UGraphReader<Graph>("partitions.lgf", graph).
   169     readNodeMap("coordinates_x", xMap(coords)).
   169     readNodeMap("coordinates_x", xMap(coords)).
   170     readNodeMap("coordinates_y", yMap(coords)).
   170     readNodeMap("coordinates_y", yMap(coords)).
   171     run();
   171     run();