lemon/bits/graph_extender.h
changeset 1130 0759d974de81
parent 1092 dceba191c00d
equal deleted inserted replaced
21:05143ab1b458 22:5274d0e7374d
    25 #include <lemon/bits/default_map.h>
    25 #include <lemon/bits/default_map.h>
    26 
    26 
    27 #include <lemon/concept_check.h>
    27 #include <lemon/concept_check.h>
    28 #include <lemon/concepts/maps.h>
    28 #include <lemon/concepts/maps.h>
    29 
    29 
       
    30 #include <lemon/bits/stl_iterators.h>
       
    31 
    30 //\ingroup graphbits
    32 //\ingroup graphbits
    31 //\file
    33 //\file
    32 //\brief Extenders for the graph types
    34 //\brief Extenders for the graph types
    33 namespace lemon {
    35 namespace lemon {
    34 
    36 
   114         return *this;
   116         return *this;
   115       }
   117       }
   116 
   118 
   117     };
   119     };
   118 
   120 
       
   121     LemonRangeWrapper1<NodeIt, Digraph> nodes() const {
       
   122       return LemonRangeWrapper1<NodeIt, Digraph>(*this);
       
   123     }
       
   124 
   119 
   125 
   120     class ArcIt : public Arc {
   126     class ArcIt : public Arc {
   121       const Digraph* _digraph;
   127       const Digraph* _digraph;
   122     public:
   128     public:
   123 
   129 
   136         _digraph->next(*this);
   142         _digraph->next(*this);
   137         return *this;
   143         return *this;
   138       }
   144       }
   139 
   145 
   140     };
   146     };
       
   147 
       
   148     LemonRangeWrapper1<ArcIt, Digraph> arcs() const {
       
   149       return LemonRangeWrapper1<ArcIt, Digraph>(*this);
       
   150     }
   141 
   151 
   142 
   152 
   143     class OutArcIt : public Arc {
   153     class OutArcIt : public Arc {
   144       const Digraph* _digraph;
   154       const Digraph* _digraph;
   145     public:
   155     public:
   161         return *this;
   171         return *this;
   162       }
   172       }
   163 
   173 
   164     };
   174     };
   165 
   175 
       
   176     LemonRangeWrapper2<OutArcIt, Digraph, Node> outArcs(const Node& u) const {
       
   177       return LemonRangeWrapper2<OutArcIt, Digraph, Node>(*this, u);
       
   178     }
       
   179 
   166 
   180 
   167     class InArcIt : public Arc {
   181     class InArcIt : public Arc {
   168       const Digraph* _digraph;
   182       const Digraph* _digraph;
   169     public:
   183     public:
   170 
   184 
   184         _digraph->nextIn(*this);
   198         _digraph->nextIn(*this);
   185         return *this;
   199         return *this;
   186       }
   200       }
   187 
   201 
   188     };
   202     };
       
   203 
       
   204     LemonRangeWrapper2<InArcIt, Digraph, Node> inArcs(const Node& u) const {
       
   205       return LemonRangeWrapper2<InArcIt, Digraph, Node>(*this, u);
       
   206     }
   189 
   207 
   190     // \brief Base node of the iterator
   208     // \brief Base node of the iterator
   191     //
   209     //
   192     // Returns the base node (i.e. the source in this case) of the iterator
   210     // Returns the base node (i.e. the source in this case) of the iterator
   193     Node baseNode(const OutArcIt &arc) const {
   211     Node baseNode(const OutArcIt &arc) const {
   434         return *this;
   452         return *this;
   435       }
   453       }
   436 
   454 
   437     };
   455     };
   438 
   456 
       
   457     LemonRangeWrapper1<NodeIt, Graph> nodes() const {
       
   458       return LemonRangeWrapper1<NodeIt, Graph>(*this);
       
   459     }
       
   460 
   439 
   461 
   440     class ArcIt : public Arc {
   462     class ArcIt : public Arc {
   441       const Graph* _graph;
   463       const Graph* _graph;
   442     public:
   464     public:
   443 
   465 
   456         _graph->next(*this);
   478         _graph->next(*this);
   457         return *this;
   479         return *this;
   458       }
   480       }
   459 
   481 
   460     };
   482     };
       
   483 
       
   484     LemonRangeWrapper1<ArcIt, Graph> arcs() const {
       
   485       return LemonRangeWrapper1<ArcIt, Graph>(*this);
       
   486     }
   461 
   487 
   462 
   488 
   463     class OutArcIt : public Arc {
   489     class OutArcIt : public Arc {
   464       const Graph* _graph;
   490       const Graph* _graph;
   465     public:
   491     public:
   481         return *this;
   507         return *this;
   482       }
   508       }
   483 
   509 
   484     };
   510     };
   485 
   511 
       
   512     LemonRangeWrapper2<OutArcIt, Graph, Node> outArcs(const Node& u) const {
       
   513       return LemonRangeWrapper2<OutArcIt, Graph, Node>(*this, u);
       
   514     }
       
   515 
   486 
   516 
   487     class InArcIt : public Arc {
   517     class InArcIt : public Arc {
   488       const Graph* _graph;
   518       const Graph* _graph;
   489     public:
   519     public:
   490 
   520 
   505         return *this;
   535         return *this;
   506       }
   536       }
   507 
   537 
   508     };
   538     };
   509 
   539 
       
   540     LemonRangeWrapper2<InArcIt, Graph, Node> inArcs(const Node& u) const {
       
   541       return LemonRangeWrapper2<InArcIt, Graph, Node>(*this, u);
       
   542     }
       
   543 
   510 
   544 
   511     class EdgeIt : public Parent::Edge {
   545     class EdgeIt : public Parent::Edge {
   512       const Graph* _graph;
   546       const Graph* _graph;
   513     public:
   547     public:
   514 
   548 
   527         _graph->next(*this);
   561         _graph->next(*this);
   528         return *this;
   562         return *this;
   529       }
   563       }
   530 
   564 
   531     };
   565     };
       
   566 
       
   567     LemonRangeWrapper1<EdgeIt, Graph> edges() const {
       
   568       return LemonRangeWrapper1<EdgeIt, Graph>(*this);
       
   569     }
       
   570 
   532 
   571 
   533     class IncEdgeIt : public Parent::Edge {
   572     class IncEdgeIt : public Parent::Edge {
   534       friend class GraphExtender;
   573       friend class GraphExtender;
   535       const Graph* _graph;
   574       const Graph* _graph;
   536       bool _direction;
   575       bool _direction;
   552       IncEdgeIt& operator++() {
   591       IncEdgeIt& operator++() {
   553         _graph->nextInc(*this, _direction);
   592         _graph->nextInc(*this, _direction);
   554         return *this;
   593         return *this;
   555       }
   594       }
   556     };
   595     };
       
   596 
       
   597     LemonRangeWrapper2<IncEdgeIt, Graph, Node> incEdges(const Node& u) const {
       
   598       return LemonRangeWrapper2<IncEdgeIt, Graph, Node>(*this, u);
       
   599     }
       
   600 
   557 
   601 
   558     // \brief Base node of the iterator
   602     // \brief Base node of the iterator
   559     //
   603     //
   560     // Returns the base node (ie. the source in this case) of the iterator
   604     // Returns the base node (ie. the source in this case) of the iterator
   561     Node baseNode(const OutArcIt &arc) const {
   605     Node baseNode(const OutArcIt &arc) const {
   901         return *this;
   945         return *this;
   902       }
   946       }
   903 
   947 
   904     };
   948     };
   905 
   949 
       
   950     LemonRangeWrapper1<NodeIt, BpGraph> nodes() const {
       
   951       return LemonRangeWrapper1<NodeIt, BpGraph>(*this);
       
   952     }
       
   953 
       
   954 
   906     class RedNodeIt : public RedNode {
   955     class RedNodeIt : public RedNode {
   907       const BpGraph* _graph;
   956       const BpGraph* _graph;
   908     public:
   957     public:
   909 
   958 
   910       RedNodeIt() {}
   959       RedNodeIt() {}
   923         return *this;
   972         return *this;
   924       }
   973       }
   925 
   974 
   926     };
   975     };
   927 
   976 
       
   977     LemonRangeWrapper1<RedNodeIt, BpGraph> redNodes() const {
       
   978       return LemonRangeWrapper1<RedNodeIt, BpGraph>(*this);
       
   979     }
       
   980 
       
   981 
   928     class BlueNodeIt : public BlueNode {
   982     class BlueNodeIt : public BlueNode {
   929       const BpGraph* _graph;
   983       const BpGraph* _graph;
   930     public:
   984     public:
   931 
   985 
   932       BlueNodeIt() {}
   986       BlueNodeIt() {}
   945         return *this;
   999         return *this;
   946       }
  1000       }
   947 
  1001 
   948     };
  1002     };
   949 
  1003 
       
  1004     LemonRangeWrapper1<BlueNodeIt, BpGraph> blueNodes() const {
       
  1005       return LemonRangeWrapper1<BlueNodeIt, BpGraph>(*this);
       
  1006     }
       
  1007 
       
  1008 
   950 
  1009 
   951     class ArcIt : public Arc {
  1010     class ArcIt : public Arc {
   952       const BpGraph* _graph;
  1011       const BpGraph* _graph;
   953     public:
  1012     public:
   954 
  1013 
   967         _graph->next(*this);
  1026         _graph->next(*this);
   968         return *this;
  1027         return *this;
   969       }
  1028       }
   970 
  1029 
   971     };
  1030     };
       
  1031 
       
  1032     LemonRangeWrapper1<ArcIt, BpGraph> arcs() const {
       
  1033       return LemonRangeWrapper1<ArcIt, BpGraph>(*this);
       
  1034     }
   972 
  1035 
   973 
  1036 
   974     class OutArcIt : public Arc {
  1037     class OutArcIt : public Arc {
   975       const BpGraph* _graph;
  1038       const BpGraph* _graph;
   976     public:
  1039     public:
   992         return *this;
  1055         return *this;
   993       }
  1056       }
   994 
  1057 
   995     };
  1058     };
   996 
  1059 
       
  1060     LemonRangeWrapper2<OutArcIt, BpGraph, Node> outArcs(const Node& u) const {
       
  1061       return LemonRangeWrapper2<OutArcIt, BpGraph, Node>(*this, u);
       
  1062     }
       
  1063 
   997 
  1064 
   998     class InArcIt : public Arc {
  1065     class InArcIt : public Arc {
   999       const BpGraph* _graph;
  1066       const BpGraph* _graph;
  1000     public:
  1067     public:
  1001 
  1068 
  1016         return *this;
  1083         return *this;
  1017       }
  1084       }
  1018 
  1085 
  1019     };
  1086     };
  1020 
  1087 
       
  1088     LemonRangeWrapper2<InArcIt, BpGraph, Node> inArcs(const Node& u) const {
       
  1089       return LemonRangeWrapper2<InArcIt, BpGraph, Node>(*this, u);
       
  1090     }
       
  1091 
  1021 
  1092 
  1022     class EdgeIt : public Parent::Edge {
  1093     class EdgeIt : public Parent::Edge {
  1023       const BpGraph* _graph;
  1094       const BpGraph* _graph;
  1024     public:
  1095     public:
  1025 
  1096 
  1038         _graph->next(*this);
  1109         _graph->next(*this);
  1039         return *this;
  1110         return *this;
  1040       }
  1111       }
  1041 
  1112 
  1042     };
  1113     };
       
  1114 
       
  1115     LemonRangeWrapper1<EdgeIt, BpGraph> edges() const {
       
  1116       return LemonRangeWrapper1<EdgeIt, BpGraph>(*this);
       
  1117     }
       
  1118 
  1043 
  1119 
  1044     class IncEdgeIt : public Parent::Edge {
  1120     class IncEdgeIt : public Parent::Edge {
  1045       friend class BpGraphExtender;
  1121       friend class BpGraphExtender;
  1046       const BpGraph* _graph;
  1122       const BpGraph* _graph;
  1047       bool _direction;
  1123       bool _direction;
  1063       IncEdgeIt& operator++() {
  1139       IncEdgeIt& operator++() {
  1064         _graph->nextInc(*this, _direction);
  1140         _graph->nextInc(*this, _direction);
  1065         return *this;
  1141         return *this;
  1066       }
  1142       }
  1067     };
  1143     };
       
  1144 
       
  1145     LemonRangeWrapper2<IncEdgeIt, BpGraph, Node> incEdges(const Node& u) const {
       
  1146       return LemonRangeWrapper2<IncEdgeIt, BpGraph, Node>(*this, u);
       
  1147     }
       
  1148 
  1068 
  1149 
  1069     // \brief Base node of the iterator
  1150     // \brief Base node of the iterator
  1070     //
  1151     //
  1071     // Returns the base node (ie. the source in this case) of the iterator
  1152     // Returns the base node (ie. the source in this case) of the iterator
  1072     Node baseNode(const OutArcIt &arc) const {
  1153     Node baseNode(const OutArcIt &arc) const {