Build fix.
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2007
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
19 #include <lemon/list_graph.h>
20 #include <lemon/topology.h>
21 #include <lemon/graph_to_eps.h>
22 #include <lemon/graph_reader.h>
23 #include <lemon/dim2.h>
32 /// \brief Demo what shows the result of some topology functions.
34 /// Demo what shows the result of some topology functions.
36 /// \include topology_demo.cc
38 using namespace lemon;
39 using namespace lemon::dim2;
43 Color color(bool val) {
44 return val ? RED : BLUE;
48 void drawConnectedComponents() {
49 typedef ListUGraph Graph;
50 typedef Graph::Node Node;
53 Graph::NodeMap<Point<double> > coords(graph);
55 UGraphReader<Graph>("u_components.lgf", graph).
56 readNodeMap("coordinates_x", xMap(coords)).
57 readNodeMap("coordinates_y", yMap(coords)).
62 Graph::NodeMap<int> compMap(graph);
63 connectedComponents(graph, compMap);
65 graphToEps(graph, "connected_components.eps").undirected().
66 coords(coords).scaleToA4().enableParallel().
67 nodeColors(composeMap(palette, compMap)).run();
69 std::cout << "Result: connected_components.eps" << std::endl;
72 void drawStronglyConnectedComponents() {
73 typedef ListGraph Graph;
74 typedef Graph::Node Node;
77 Graph::NodeMap<Point<double> > coords(graph);
79 GraphReader<Graph>("dir_components.lgf", graph).
80 readNodeMap("coordinates_x", xMap(coords)).
81 readNodeMap("coordinates_y", yMap(coords)).
86 Graph::NodeMap<int> compMap(graph);
87 Graph::EdgeMap<bool> cutMap(graph);
88 stronglyConnectedComponents(graph, compMap);
89 stronglyConnectedCutEdges(graph, cutMap);
91 graphToEps(graph, "strongly_connected_components.eps").
92 coords(coords).scaleToA4().enableParallel().drawArrows().
93 nodeColors(composeMap(palette, compMap)).
94 edgeColors(composeMap(functorMap(&color), cutMap)).run();
96 std::cout << "Result: strongly_connected_components.eps" << std::endl;
99 void drawNodeBiconnectedComponents() {
100 typedef ListUGraph Graph;
101 typedef Graph::Node Node;
102 typedef Graph::UEdge UEdge;
105 Graph::NodeMap<Point<double> > coords(graph);
107 UGraphReader<Graph>("u_components.lgf", graph).
108 readNodeMap("coordinates_x", xMap(coords)).
109 readNodeMap("coordinates_y", yMap(coords)).
114 Graph::UEdgeMap<int> compMap(graph);
115 Graph::NodeMap<bool> cutMap(graph);
116 biNodeConnectedComponents(graph, compMap);
117 biNodeConnectedCutNodes(graph, cutMap);
119 graphToEps(graph, "bi_node_connected_components.eps").undirected().
120 coords(coords).scaleToA4().enableParallel().
121 edgeColors(composeMap(palette, compMap)).
122 nodeColors(composeMap(functorMap(&color), cutMap)).
125 std::cout << "Result: bi_node_connected_components.eps" << std::endl;
128 void drawEdgeBiconnectedComponents() {
129 typedef ListUGraph Graph;
130 typedef Graph::Node Node;
131 typedef Graph::UEdge UEdge;
134 Graph::NodeMap<Point<double> > coords(graph);
136 UGraphReader<Graph>("u_components.lgf", graph).
137 readNodeMap("coordinates_x", xMap(coords)).
138 readNodeMap("coordinates_y", yMap(coords)).
143 Graph::NodeMap<int> compMap(graph);
144 Graph::UEdgeMap<bool> cutMap(graph);
145 biEdgeConnectedComponents(graph, compMap);
146 biEdgeConnectedCutEdges(graph, cutMap);
148 graphToEps(graph, "bi_edge_connected_components.eps").undirected().
149 coords(coords).scaleToA4().enableParallel().
150 nodeColors(composeMap(palette, compMap)).
151 edgeColors(composeMap(functorMap(&color), cutMap)).run();
153 std::cout << "Result: bi_edge_connected_components.eps" << std::endl;
156 void drawBipartitePartitions() {
157 typedef ListUGraph Graph;
158 typedef Graph::Node Node;
159 typedef Graph::UEdge UEdge;
162 Graph::NodeMap<Point<double> > coords(graph);
164 UGraphReader<Graph>("partitions.lgf", graph).
165 readNodeMap("coordinates_x", xMap(coords)).
166 readNodeMap("coordinates_y", yMap(coords)).
171 Graph::NodeMap<bool> partMap(graph);
172 bipartitePartitions(graph, partMap);
174 graphToEps(graph, "bipartite_partitions.eps").undirected().
175 coords(coords).scaleToA4().enableParallel().
176 nodeColors(composeMap(functorMap(&color), partMap)).run();
178 std::cout << "Result: bipartite_partitions.eps" << std::endl;
182 drawConnectedComponents();
183 drawStronglyConnectedComponents();
184 drawNodeBiconnectedComponents();
185 drawEdgeBiconnectedComponents();
186 drawBipartitePartitions();