Documenatation of MapWin.
2 * demo/min_route.cc - Part of LEMON, a generic C++ optimization library
4 * Copyright (C) 2006 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Research Group on Combinatorial Optimization, EGRES).
7 * Permission to use, modify and distribute this software is granted
8 * provided that this copyright notice appears in all copies. For
9 * precise terms see the accompanying LICENSE file.
11 * This software is provided "AS IS" with no warranty of any kind,
12 * express or implied, and with no claim as to its suitability for any
17 #include <lemon/list_graph.h>
18 #include <lemon/topology.h>
19 #include <lemon/graph_to_eps.h>
20 #include <lemon/graph_reader.h>
30 /// \brief Demo what shows the result of some topology functions.
32 /// Demo what shows the result of some topology functions.
34 /// \include topology_demo.cc
36 using namespace lemon;
40 Color color(bool val) {
41 return val ? Color(1.0, 0.0, 0.0) : Color(0.0, 0.0, 1.0);
45 void drawConnectedComponents() {
46 typedef UndirListGraph Graph;
47 typedef Graph::Node Node;
50 Graph::NodeMap<xy<double> > coords(graph);
52 UndirGraphReader<Graph>("undir_components.lgf", graph).
53 readNodeMap("coordinates_x", xMap(coords)).
54 readNodeMap("coordinates_y", yMap(coords)).
59 Graph::NodeMap<int> compMap(graph);
60 connectedComponents(graph, compMap);
62 graphToEps(graph, "connected_components.eps").undir().
63 coords(coords).scaleToA4().enableParallel().
64 parEdgeDist(20.0).edgeWidthScale(2.0).nodeScale(20.0).
65 nodeColors(composeMap(colorSet, compMap)).run();
67 std::cout << "Result: connected_components.eps" << std::endl;
70 void drawStronglyConnectedComponents() {
71 typedef ListGraph Graph;
72 typedef Graph::Node Node;
75 Graph::NodeMap<xy<double> > coords(graph);
77 GraphReader<Graph>("dir_components.lgf", graph).
78 readNodeMap("coordinates_x", xMap(coords)).
79 readNodeMap("coordinates_y", yMap(coords)).
84 Graph::NodeMap<int> compMap(graph);
85 Graph::EdgeMap<bool> cutMap(graph);
86 stronglyConnectedComponents(graph, compMap);
87 stronglyConnectedCutEdges(graph, cutMap);
89 graphToEps(graph, "strongly_connected_components.eps").
90 coords(coords).scaleToA4().enableParallel().
91 drawArrows().arrowWidth(10.0).arrowLength(10.0).
92 parEdgeDist(20.0).edgeWidthScale(2.0).nodeScale(20.0).
93 nodeColors(composeMap(colorSet, compMap)).
94 edgeColors(composeMap(functorMap(&color), cutMap)).run();
96 std::cout << "Result: strongly_connected_components.eps" << std::endl;
99 void drawNodeBiconnectedComponents() {
100 typedef UndirListGraph Graph;
101 typedef Graph::Node Node;
102 typedef Graph::UndirEdge UndirEdge;
105 Graph::NodeMap<xy<double> > coords(graph);
107 UndirGraphReader<Graph>("undir_components.lgf", graph).
108 readNodeMap("coordinates_x", xMap(coords)).
109 readNodeMap("coordinates_y", yMap(coords)).
114 Graph::UndirEdgeMap<int> compMap(graph);
115 Graph::NodeMap<bool> cutMap(graph);
116 biNodeConnectedComponents(graph, compMap);
117 biNodeConnectedCutNodes(graph, cutMap);
118 graphToEps(graph, "bi_node_connected_components.eps").undir().
119 coords(coords).scaleToA4().enableParallel().
120 parEdgeDist(20.0).edgeWidthScale(5.0).nodeScale(20.0).
121 edgeColors(composeMap(colorSet, compMap)).
122 nodeColors(composeMap(functorMap(&color), cutMap)).
125 std::cout << "Result: bi_node_connected_components.eps" << std::endl;
128 void drawEdgeBiconnectedComponents() {
129 typedef UndirListGraph Graph;
130 typedef Graph::Node Node;
131 typedef Graph::UndirEdge UndirEdge;
134 Graph::NodeMap<xy<double> > coords(graph);
136 UndirGraphReader<Graph>("undir_components.lgf", graph).
137 readNodeMap("coordinates_x", xMap(coords)).
138 readNodeMap("coordinates_y", yMap(coords)).
143 Graph::NodeMap<int> compMap(graph);
144 Graph::UndirEdgeMap<bool> cutMap(graph);
145 biEdgeConnectedComponents(graph, compMap);
146 biEdgeConnectedCutEdges(graph, cutMap);
148 graphToEps(graph, "bi_edge_connected_components.eps").undir().
149 coords(coords).scaleToA4().enableParallel().
150 parEdgeDist(20.0).edgeWidthScale(2.0).nodeScale(20.0).
151 nodeColors(composeMap(colorSet, compMap)).
152 edgeColors(composeMap(functorMap(&color), cutMap)).run();
154 std::cout << "Result: bi_edge_connected_components.eps" << std::endl;
157 void drawBipartitePartitions() {
158 typedef UndirListGraph Graph;
159 typedef Graph::Node Node;
160 typedef Graph::UndirEdge UndirEdge;
163 Graph::NodeMap<xy<double> > coords(graph);
165 UndirGraphReader<Graph>("partitions.lgf", graph).
166 readNodeMap("coordinates_x", xMap(coords)).
167 readNodeMap("coordinates_y", yMap(coords)).
172 Graph::NodeMap<bool> partMap(graph);
173 bipartitePartitions(graph, partMap);
175 graphToEps(graph, "bipartite_partitions.eps").undir().
176 coords(coords).scaleToA4().enableParallel().
177 parEdgeDist(20.0).edgeWidthScale(2.0).nodeScale(20.0).
178 nodeColors(composeMap(functorMap(&color), partMap)).run();
180 std::cout << "Result: bipartite_partitions.eps" << std::endl;
186 drawConnectedComponents();
187 drawStronglyConnectedComponents();
188 drawNodeBiconnectedComponents();
189 drawEdgeBiconnectedComponents();
190 drawBipartitePartitions();