COIN-OR::LEMON - Graph Library

Ignore:
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • lemon/Makefile.am

    r817 r827  
    114114        lemon/smart_graph.h \
    115115        lemon/soplex.h \
     116        lemon/static_graph.h \
    116117        lemon/suurballe.h \
    117118        lemon/time_measure.h \
  • lemon/bits/graph_extender.h

    r732 r825  
    5757    }
    5858
    59     Node fromId(int id, Node) const {
     59    static Node fromId(int id, Node) {
    6060      return Parent::nodeFromId(id);
    6161    }
    6262
    63     Arc fromId(int id, Arc) const {
     63    static Arc fromId(int id, Arc) {
    6464      return Parent::arcFromId(id);
    6565    }
     
    356356    }
    357357
    358     Node fromId(int id, Node) const {
     358    static Node fromId(int id, Node) {
    359359      return Parent::nodeFromId(id);
    360360    }
    361361
    362     Arc fromId(int id, Arc) const {
     362    static Arc fromId(int id, Arc) {
    363363      return Parent::arcFromId(id);
    364364    }
    365365
    366     Edge fromId(int id, Edge) const {
     366    static Edge fromId(int id, Edge) {
    367367      return Parent::edgeFromId(id);
    368368    }
  • lemon/edge_set.h

    r717 r825  
    868868    }
    869869
    870     void next(Arc& arc) const {
     870    static void next(Arc& arc) {
    871871      --arc.id;
    872872    }
     
    11741174    }
    11751175
    1176     void next(Arc& arc) const {
     1176    static void next(Arc& arc) {
    11771177      --arc.id;
    11781178    }
     
    11821182    }
    11831183
    1184     void next(Edge& arc) const {
     1184    static void next(Edge& arc) {
    11851185      --arc.id;
    11861186    }
  • lemon/full_graph.h

    r782 r827  
    5252
    5353    Node operator()(int ix) const { return Node(ix); }
    54     int index(const Node& node) const { return node._id; }
     54    static int index(const Node& node) { return node._id; }
    5555
    5656    Arc arc(const Node& s, const Node& t) const {
     
    214214    /// the range <tt>[0..nodeNum()-1]</tt>.
    215215    /// \sa operator()()
    216     int index(Node node) const { return Parent::index(node); }
     216    static int index(const Node& node) { return Parent::index(node); }
    217217
    218218    /// \brief Returns the arc connecting the given nodes.
     
    288288
    289289    Node operator()(int ix) const { return Node(ix); }
    290     int index(const Node& node) const { return node._id; }
     290    static int index(const Node& node) { return node._id; }
    291291
    292292    Edge edge(const Node& u, const Node& v) const {
     
    589589    /// the range <tt>[0..nodeNum()-1]</tt>.
    590590    /// \sa operator()()
    591     int index(Node node) const { return Parent::index(node); }
     591    static int index(const Node& node) { return Parent::index(node); }
    592592
    593593    /// \brief Returns the arc connecting the given nodes.
  • lemon/hypercube_graph.h

    r784 r827  
    263263    }
    264264
    265     int index(Node node) const {
     265    static int index(Node node) {
    266266      return node._id;
    267267    }
     
    357357    /// Gives back the index of the given node.
    358358    /// The lower bits of the integer describes the node.
    359     int index(Node node) const {
     359    static int index(Node node) {
    360360      return Parent::index(node);
    361361    }
  • lemon/smart_graph.h

    r783 r827  
    498498    }
    499499
    500     void next(Node& node) const {
     500    static void next(Node& node) {
    501501      --node._id;
    502502    }
     
    506506    }
    507507
    508     void next(Arc& arc) const {
     508    static void next(Arc& arc) {
    509509      --arc._id;
    510510    }
     
    514514    }
    515515
    516     void next(Edge& arc) const {
     516    static void next(Edge& arc) {
    517517      --arc._id;
    518518    }
  • test/digraph_test.cc

    r787 r827  
    2020#include <lemon/list_graph.h>
    2121#include <lemon/smart_graph.h>
     22#include <lemon/static_graph.h>
    2223#include <lemon/full_graph.h>
    2324
     
    329330    checkConcept<ClearableDigraphComponent<>, SmartDigraph>();
    330331  }
     332  { // Checking StaticDigraph
     333    checkConcept<Digraph, StaticDigraph>();
     334    checkConcept<ClearableDigraphComponent<>, StaticDigraph>();
     335  }
    331336  { // Checking FullDigraph
    332337    checkConcept<Digraph, FullDigraph>();
     
    382387  check(!g.valid(g.nodeFromId(-1)), "Wrong validity check");
    383388  check(!g.valid(g.arcFromId(-1)), "Wrong validity check");
     389}
     390
     391void checkStaticDigraph() {
     392  SmartDigraph g;
     393  SmartDigraph::NodeMap<StaticDigraph::Node> nref(g);
     394  SmartDigraph::ArcMap<StaticDigraph::Arc> aref(g);
     395 
     396  StaticDigraph G;
     397 
     398  checkGraphNodeList(G, 0);
     399  checkGraphArcList(G, 0);
     400
     401  G.build(g, nref, aref);
     402
     403  checkGraphNodeList(G, 0);
     404  checkGraphArcList(G, 0);
     405
     406  SmartDigraph::Node
     407    n1 = g.addNode(),
     408    n2 = g.addNode(),
     409    n3 = g.addNode();
     410
     411  G.build(g, nref, aref);
     412
     413  checkGraphNodeList(G, 3);
     414  checkGraphArcList(G, 0);
     415
     416  SmartDigraph::Arc a1 = g.addArc(n1, n2);
     417
     418  G.build(g, nref, aref);
     419
     420  check(G.source(aref[a1]) == nref[n1] && G.target(aref[a1]) == nref[n2],
     421        "Wrong arc or wrong references");
     422  checkGraphNodeList(G, 3);
     423  checkGraphArcList(G, 1);
     424
     425  checkGraphOutArcList(G, nref[n1], 1);
     426  checkGraphOutArcList(G, nref[n2], 0);
     427  checkGraphOutArcList(G, nref[n3], 0);
     428
     429  checkGraphInArcList(G, nref[n1], 0);
     430  checkGraphInArcList(G, nref[n2], 1);
     431  checkGraphInArcList(G, nref[n3], 0);
     432
     433  checkGraphConArcList(G, 1);
     434
     435  SmartDigraph::Arc
     436    a2 = g.addArc(n2, n1),
     437    a3 = g.addArc(n2, n3),
     438    a4 = g.addArc(n2, n3);
     439
     440  digraphCopy(g, G).nodeRef(nref).run();
     441
     442  checkGraphNodeList(G, 3);
     443  checkGraphArcList(G, 4);
     444
     445  checkGraphOutArcList(G, nref[n1], 1);
     446  checkGraphOutArcList(G, nref[n2], 3);
     447  checkGraphOutArcList(G, nref[n3], 0);
     448
     449  checkGraphInArcList(G, nref[n1], 1);
     450  checkGraphInArcList(G, nref[n2], 1);
     451  checkGraphInArcList(G, nref[n3], 2);
     452
     453  checkGraphConArcList(G, 4);
     454
     455  std::vector<std::pair<int,int> > arcs;
     456  arcs.push_back(std::make_pair(0,1));
     457  arcs.push_back(std::make_pair(0,2));
     458  arcs.push_back(std::make_pair(1,3));
     459  arcs.push_back(std::make_pair(1,2));
     460  arcs.push_back(std::make_pair(3,0));
     461  arcs.push_back(std::make_pair(3,3));
     462  arcs.push_back(std::make_pair(4,2));
     463  arcs.push_back(std::make_pair(4,3));
     464  arcs.push_back(std::make_pair(4,1));
     465
     466  G.build(6, arcs.begin(), arcs.end());
     467 
     468  checkGraphNodeList(G, 6);
     469  checkGraphArcList(G, 9);
     470
     471  checkGraphOutArcList(G, G.node(0), 2);
     472  checkGraphOutArcList(G, G.node(1), 2);
     473  checkGraphOutArcList(G, G.node(2), 0);
     474  checkGraphOutArcList(G, G.node(3), 2);
     475  checkGraphOutArcList(G, G.node(4), 3);
     476  checkGraphOutArcList(G, G.node(5), 0);
     477
     478  checkGraphInArcList(G, G.node(0), 1);
     479  checkGraphInArcList(G, G.node(1), 2);
     480  checkGraphInArcList(G, G.node(2), 3);
     481  checkGraphInArcList(G, G.node(3), 3);
     482  checkGraphInArcList(G, G.node(4), 0);
     483  checkGraphInArcList(G, G.node(5), 0);
     484
     485  checkGraphConArcList(G, 9);
     486
     487  checkNodeIds(G);
     488  checkArcIds(G);
     489  checkGraphNodeMap(G);
     490  checkGraphArcMap(G);
     491 
     492  int n = G.nodeNum();
     493  int m = G.arcNum();
     494  check(G.index(G.node(n-1)) == n-1, "Wrong index.");
     495  check(G.index(G.arc(m-1)) == m-1, "Wrong index.");
    384496}
    385497
     
    436548    checkDigraphValidity<SmartDigraph>();
    437549  }
     550  { // Checking StaticDigraph
     551    checkStaticDigraph();
     552  }
    438553  { // Checking FullDigraph
    439554    checkFullDigraph(8);
Note: See TracChangeset for help on using the changeset viewer.