26 |
26 |
27 |
27 |
28 using namespace std; |
28 using namespace std; |
29 using namespace lemon; |
29 using namespace lemon; |
30 |
30 |
31 int main(int argc, char *argv[]) |
31 int main() { |
32 { |
|
33 if(argc<2) |
|
34 { |
|
35 std::cerr << "USAGE: coloring input_file.lgf" << std::endl; |
|
36 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; |
|
37 return 0; |
|
38 } |
|
39 |
|
40 |
|
41 //input stream to read the graph from |
|
42 std::ifstream is(argv[1]); |
|
43 |
32 |
44 typedef UndirSmartGraph Graph; |
33 typedef UndirSmartGraph Graph; |
45 typedef Graph::Node Node; |
34 typedef Graph::Node Node; |
46 typedef Graph::NodeIt NodeIt; |
35 typedef Graph::NodeIt NodeIt; |
47 typedef Graph::UndirEdge UndirEdge; |
36 typedef Graph::UndirEdge UndirEdge; |
48 typedef Graph::IncEdgeIt IncEdgeIt; |
37 typedef Graph::IncEdgeIt IncEdgeIt; |
49 |
38 |
|
39 std::cout << "Six coloring of a plan graph" << std::endl; |
|
40 std::cout << "Input file: coloring.lgf" << std::endl; |
|
41 std::cout << "Output file: coloring.eps" << std::endl; |
|
42 |
50 Graph graph; |
43 Graph graph; |
51 |
44 |
52 UndirGraphReader<Graph> reader(is, graph); |
45 UndirGraphReader<Graph> reader("coloring.lgf", graph); |
53 Graph::NodeMap<xy<double> > coords(graph); |
46 Graph::NodeMap<xy<double> > coords(graph); |
54 reader.readNodeMap("coords", coords); |
47 reader.readNodeMap("coords", coords); |
55 |
48 |
56 reader.run(); |
49 reader.run(); |
57 |
50 |
92 color[order[i]] = current; |
85 color[order[i]] = current; |
93 } |
86 } |
94 |
87 |
95 ColorSet colorSet; |
88 ColorSet colorSet; |
96 |
89 |
97 graphToEps(graph, "six_coloring.eps"). |
90 graphToEps(graph, "coloring.eps"). |
98 title("Six Colored Graph").copyright("(C) 2005 LEMON Project"). |
91 title("Six Colored Plan Graph").copyright("(C) 2005 LEMON Project"). |
99 coords(coords).nodeColors(composeMap(colorSet, color)). |
92 coords(coords).nodeColors(composeMap(colorSet, color)). |
100 scaleToA4().run(); |
93 nodeScale(5.0).scaleToA4().run(); |
101 |
94 |
102 return 0; |
95 return 0; |
103 } |
96 } |