COIN-OR::LEMON - Graph Library

Ticket #363: lemon_rev970_ab0782f0c79f.patch

File lemon_rev970_ab0782f0c79f.patch, 3.5 KB (added by gyorokp, 9 years ago)
  • lemon/planar_graph.h

    # 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  
    2626#include <lemon/core.h>
    2727#include <lemon/error.h>
    2828#include <lemon/bits/graph_extender.h>
     29#include <lemon/planarity.h>
    2930
    3031#include <vector>
    3132#include <list>
     
    12851286    ///
    12861287    PlanarGraph() {}
    12871288
     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
    12881325    typedef Parent::OutArcIt IncEdgeIt;
    12891326
    12901327    /// \brief Add a new node to the graph.
  • lemon/plane_graph.h

    diff -r a58356e448fd -r ab0782f0c79f lemon/plane_graph.h
    a b  
    2323///\file
    2424///\brief PlaneGraph classes. UNDER CONSTRUCTION.
    2525
     26#include <lemon/planarity.h>
    2627#include <lemon/planar_graph.h>
    2728#include <lemon/dim2.h>
    2829#include <cmath>
     
    5455    ///Constructor.
    5556    PlaneGraph() : nodepos(*this) {}
    5657
     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
    5773    ///Add a new node to the graph.
    5874
    5975    ///PlaneGraph doesn't support this method. Use the overload that takes a
     
    6480
    6581    ///PlaneGraph doesn't support this method. Use the overload that takes only
    6682    ///two node parameters.
    67     Arc addEdge(Node, Node, Arc, Arc) = delete;
     83    Edge addEdge(Node, Node, Arc, Arc) = delete;
    6884
    6985    ///Add a new node to the graph.
    7086