# HG changeset patch
# User gyorokp
# Date 1269167256 -3600
# Node ID ab0782f0c79f5dcc1418a27fa9b0b1c5255ba21c
# Parent a58356e448fd457162c2365cb57e66cb106f079d
Added constructors PlanarGraph(PlanarEmbedding) and PlaneGraph(PlanarDrawing)
diff -r a58356e448fd -r ab0782f0c79f lemon/planar_graph.h
|
a
|
b
|
|
| 26 | 26 | #include <lemon/core.h> |
| 27 | 27 | #include <lemon/error.h> |
| 28 | 28 | #include <lemon/bits/graph_extender.h> |
| | 29 | #include <lemon/planarity.h> |
| 29 | 30 | |
| 30 | 31 | #include <vector> |
| 31 | 32 | #include <list> |
| … |
… |
|
| 1285 | 1286 | /// |
| 1286 | 1287 | PlanarGraph() {} |
| 1287 | 1288 | |
| | 1289 | ///\brief Constructor that copies a planar embedding |
| | 1290 | |
| | 1291 | ///Constructor that copies a planar embedding. |
| | 1292 | template<typename Graph> |
| | 1293 | PlanarGraph(const Graph &g, const lemon::PlanarEmbedding<Graph> &em) { |
| | 1294 | typename Graph::template NodeMap<Node> nm(g); |
| | 1295 | typename Graph::template ArcMap<Arc> am(g); |
| | 1296 | for (typename Graph::NodeIt it(g); it != INVALID; ++it) { |
| | 1297 | nm[it] = addNode(); |
| | 1298 | } |
| | 1299 | for (typename Graph::ArcIt it(g); it != INVALID; ++it) { |
| | 1300 | am[it] = INVALID; |
| | 1301 | } |
| | 1302 | for (typename Graph::ArcIt it(g); it != INVALID; ++it) { |
| | 1303 | am[it] = INVALID; |
| | 1304 | } |
| | 1305 | for (typename Graph::NodeIt it(g); it != INVALID; ++it) { |
| | 1306 | for (typename Graph::OutArcIt it2(g,it); it2 != INVALID; ++it2) { |
| | 1307 | if (am[it2] == INVALID) { |
| | 1308 | typename Graph::Arc p_u = em.next(it2); |
| | 1309 | while (am[p_u] == INVALID && it2 != p_u) { |
| | 1310 | p_u = em.next(p_u); |
| | 1311 | } |
| | 1312 | typename Graph::Arc ra = g.oppositeArc(it2); |
| | 1313 | typename Graph::Arc p_v = em.next(ra); |
| | 1314 | while (am[p_v] == INVALID && ra != p_v) { |
| | 1315 | p_v = em.next(p_v); |
| | 1316 | } |
| | 1317 | am[it2] = direct(addEdge(nm[g.source(it2)],nm[g.target(it2)], |
| | 1318 | am[p_u],am[p_v]),nm[g.source(it2)]); |
| | 1319 | am[g.oppositeArc(it2)] = oppositeArc(am[it2]); |
| | 1320 | } |
| | 1321 | } |
| | 1322 | } |
| | 1323 | } |
| | 1324 | |
| 1288 | 1325 | typedef Parent::OutArcIt IncEdgeIt; |
| 1289 | 1326 | |
| 1290 | 1327 | /// \brief Add a new node to the graph. |
diff -r a58356e448fd -r ab0782f0c79f lemon/plane_graph.h
|
a
|
b
|
|
| 23 | 23 | ///\file |
| 24 | 24 | ///\brief PlaneGraph classes. UNDER CONSTRUCTION. |
| 25 | 25 | |
| | 26 | #include <lemon/planarity.h> |
| 26 | 27 | #include <lemon/planar_graph.h> |
| 27 | 28 | #include <lemon/dim2.h> |
| 28 | 29 | #include <cmath> |
| … |
… |
|
| 54 | 55 | ///Constructor. |
| 55 | 56 | PlaneGraph() : nodepos(*this) {} |
| 56 | 57 | |
| | 58 | ///\brief Constructor that copies a planar drawing |
| | 59 | |
| | 60 | ///Constructor that copies a planar drawing. |
| | 61 | template<typename Graph> |
| | 62 | PlaneGraph(const Graph &graph, const lemon::PlanarDrawing<Graph> &drawing) : |
| | 63 | nodepos(*this) { |
| | 64 | typename Graph::template NodeMap<Node> nm(graph); |
| | 65 | for (typename Graph::NodeIt it(graph); it != INVALID; ++it) { |
| | 66 | nm[it] = addNode(drawing[it]); |
| | 67 | } |
| | 68 | for (typename Graph::EdgeIt it(graph); it != INVALID; ++it) { |
| | 69 | addEdge(nm[graph.u(it)], nm[graph.v(it)]); |
| | 70 | } |
| | 71 | } |
| | 72 | |
| 57 | 73 | ///Add a new node to the graph. |
| 58 | 74 | |
| 59 | 75 | ///PlaneGraph doesn't support this method. Use the overload that takes a |
| … |
… |
|
| 64 | 80 | |
| 65 | 81 | ///PlaneGraph doesn't support this method. Use the overload that takes only |
| 66 | 82 | ///two node parameters. |
| 67 | | Arc addEdge(Node, Node, Arc, Arc) = delete; |
| | 83 | Edge addEdge(Node, Node, Arc, Arc) = delete; |
| 68 | 84 | |
| 69 | 85 | ///Add a new node to the graph. |
| 70 | 86 | |