demo/coloring.cc
changeset 1564 16d316199cf6
parent 1435 8e85e6bbefdf
child 1577 15098fb5275c
equal deleted inserted replaced
0:4a89fe0a20c8 1:b65a1f2d420d
     3 #include <lemon/smart_graph.h>
     3 #include <lemon/smart_graph.h>
     4 #include <lemon/bin_heap.h>
     4 #include <lemon/bin_heap.h>
     5 #include <lemon/graph_reader.h>
     5 #include <lemon/graph_reader.h>
     6 #include <lemon/graph_to_eps.h>
     6 #include <lemon/graph_to_eps.h>
     7 
     7 
       
     8 #include <fstream>
       
     9 #include <iostream>
       
    10 
       
    11 
     8 using namespace std;
    12 using namespace std;
     9 using namespace lemon;
    13 using namespace lemon;
    10 
    14 
    11 int main() {
    15 int main(int argc, char *argv[]) 
       
    16 {
       
    17   if(argc<2)
       
    18   {
       
    19       std::cerr << "USAGE: coloring <input_file.lgf>" << std::endl;
       
    20       std::cerr << "The file 'input_file.lgf' has to contain a graph in LEMON format together with a nodemap called 'coords' to draw the graph (e.g. sample.lgf is not such a file)." << std::endl;
       
    21       return 0;
       
    22   }
       
    23 
       
    24 
       
    25   //input stream to read the graph from
       
    26   std::ifstream is(argv[1]);
       
    27 
    12   typedef UndirSmartGraph Graph;
    28   typedef UndirSmartGraph Graph;
    13   typedef Graph::Node Node;
    29   typedef Graph::Node Node;
    14   typedef Graph::NodeIt NodeIt;
    30   typedef Graph::NodeIt NodeIt;
    15   typedef Graph::UndirEdge UndirEdge;
    31   typedef Graph::UndirEdge UndirEdge;
    16   typedef Graph::IncEdgeIt IncEdgeIt;
    32   typedef Graph::IncEdgeIt IncEdgeIt;
    17 
    33 
    18   Graph graph;
    34   Graph graph;
    19 
    35 
    20   UndirGraphReader<Graph> reader(std::cin, graph);
    36   UndirGraphReader<Graph> reader(is, graph);
    21   Graph::NodeMap<xy<double> > coords(graph);
    37   Graph::NodeMap<xy<double> > coords(graph);
    22   reader.readNodeMap("coords", coords);
    38   reader.readNodeMap("coords", coords);
    23   
    39   
    24   reader.run();
    40   reader.run();
    25 
    41