1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
3 * This file is a part of LEMON, a generic C++ optimization library.
5 * Copyright (C) 2003-2010
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 #ifndef LEMON_FULL_GRAPH_H
20 #define LEMON_FULL_GRAPH_H
22 #include <lemon/core.h>
23 #include <lemon/bits/graph_extender.h>
27 ///\brief FullDigraph and FullGraph classes.
31 class FullDigraphBase {
34 typedef FullDigraphBase Digraph;
46 void construct(int n) { _node_num = n; _arc_num = n * n; }
50 typedef True NodeNumTag;
51 typedef True ArcNumTag;
53 Node operator()(int ix) const { return Node(ix); }
54 static int index(const Node& node) { return node._id; }
56 Arc arc(const Node& s, const Node& t) const {
57 return Arc(s._id * _node_num + t._id);
60 int nodeNum() const { return _node_num; }
61 int arcNum() const { return _arc_num; }
63 int maxNodeId() const { return _node_num - 1; }
64 int maxArcId() const { return _arc_num - 1; }
66 Node source(Arc arc) const { return arc._id / _node_num; }
67 Node target(Arc arc) const { return arc._id % _node_num; }
69 static int id(Node node) { return node._id; }
70 static int id(Arc arc) { return arc._id; }
72 static Node nodeFromId(int id) { return Node(id);}
73 static Arc arcFromId(int id) { return Arc(id);}
75 typedef True FindArcTag;
77 Arc findArc(Node s, Node t, Arc prev = INVALID) const {
78 return prev == INVALID ? arc(s, t) : INVALID;
82 friend class FullDigraphBase;
86 Node(int id) : _id(id) {}
89 Node (Invalid) : _id(-1) {}
90 bool operator==(const Node node) const {return _id == node._id;}
91 bool operator!=(const Node node) const {return _id != node._id;}
92 bool operator<(const Node node) const {return _id < node._id;}
96 friend class FullDigraphBase;
99 int _id; // _node_num * source + target;
101 Arc(int id) : _id(id) {}
105 Arc (Invalid) { _id = -1; }
106 bool operator==(const Arc arc) const {return _id == arc._id;}
107 bool operator!=(const Arc arc) const {return _id != arc._id;}
108 bool operator<(const Arc arc) const {return _id < arc._id;}
111 void first(Node& node) const {
112 node._id = _node_num - 1;
115 static void next(Node& node) {
119 void first(Arc& arc) const {
120 arc._id = _arc_num - 1;
123 static void next(Arc& arc) {
127 void firstOut(Arc& arc, const Node& node) const {
128 arc._id = (node._id + 1) * _node_num - 1;
131 void nextOut(Arc& arc) const {
132 if (arc._id % _node_num == 0) arc._id = 0;
136 void firstIn(Arc& arc, const Node& node) const {
137 arc._id = _arc_num + node._id - _node_num;
140 void nextIn(Arc& arc) const {
141 arc._id -= _node_num;
142 if (arc._id < 0) arc._id = -1;
147 typedef DigraphExtender<FullDigraphBase> ExtendedFullDigraphBase;
151 /// \brief A directed full graph class.
153 /// FullDigraph is a simple and fast implmenetation of directed full
154 /// (complete) graphs. It contains an arc from each node to each node
155 /// (including a loop for each node), therefore the number of arcs
156 /// is the square of the number of nodes.
157 /// This class is completely static and it needs constant memory space.
158 /// Thus you can neither add nor delete nodes or arcs, however
159 /// the structure can be resized using resize().
161 /// This type fully conforms to the \ref concepts::Digraph "Digraph concept".
162 /// Most of its member functions and nested classes are documented
163 /// only in the concept class.
165 /// This class provides constant time counting for nodes and arcs.
167 /// \note FullDigraph and FullGraph classes are very similar,
168 /// but there are two differences. While this class conforms only
169 /// to the \ref concepts::Digraph "Digraph" concept, FullGraph
170 /// conforms to the \ref concepts::Graph "Graph" concept,
171 /// moreover FullGraph does not contain a loop for each
172 /// node as this class does.
175 class FullDigraph : public ExtendedFullDigraphBase {
176 typedef ExtendedFullDigraphBase Parent;
180 /// \brief Default constructor.
182 /// Default constructor. The number of nodes and arcs will be zero.
183 FullDigraph() { construct(0); }
185 /// \brief Constructor
188 /// \param n The number of the nodes.
189 FullDigraph(int n) { construct(n); }
191 /// \brief Resizes the digraph
193 /// This function resizes the digraph. It fully destroys and
194 /// rebuilds the structure, therefore the maps of the digraph will be
195 /// reallocated automatically and the previous values will be lost.
197 Parent::notifier(Arc()).clear();
198 Parent::notifier(Node()).clear();
200 Parent::notifier(Node()).build();
201 Parent::notifier(Arc()).build();
204 /// \brief Returns the node with the given index.
206 /// Returns the node with the given index. Since this structure is
207 /// completely static, the nodes can be indexed with integers from
208 /// the range <tt>[0..nodeNum()-1]</tt>.
209 /// The index of a node is the same as its ID.
211 Node operator()(int ix) const { return Parent::operator()(ix); }
213 /// \brief Returns the index of the given node.
215 /// Returns the index of the given node. Since this structure is
216 /// completely static, the nodes can be indexed with integers from
217 /// the range <tt>[0..nodeNum()-1]</tt>.
218 /// The index of a node is the same as its ID.
220 static int index(const Node& node) { return Parent::index(node); }
222 /// \brief Returns the arc connecting the given nodes.
224 /// Returns the arc connecting the given nodes.
225 Arc arc(Node u, Node v) const {
226 return Parent::arc(u, v);
229 /// \brief Number of nodes.
230 int nodeNum() const { return Parent::nodeNum(); }
231 /// \brief Number of arcs.
232 int arcNum() const { return Parent::arcNum(); }
236 class FullGraphBase {
239 typedef FullGraphBase Graph;
252 void construct(int n) { _node_num = n; _edge_num = n * (n - 1) / 2; }
254 int _uid(int e) const {
255 int u = e / _node_num;
256 int v = e % _node_num;
257 return u < v ? u : _node_num - 2 - u;
260 int _vid(int e) const {
261 int u = e / _node_num;
262 int v = e % _node_num;
263 return u < v ? v : _node_num - 1 - v;
266 void _uvid(int e, int& u, int& v) const {
270 u = _node_num - 2 - u;
271 v = _node_num - 1 - v;
275 void _stid(int a, int& s, int& t) const {
283 int _eid(int u, int v) const {
284 if (u < (_node_num - 1) / 2) {
285 return u * _node_num + v;
287 return (_node_num - 1 - u) * _node_num - v - 1;
293 Node operator()(int ix) const { return Node(ix); }
294 static int index(const Node& node) { return node._id; }
296 Edge edge(const Node& u, const Node& v) const {
298 return Edge(_eid(u._id, v._id));
299 } else if (u._id != v._id) {
300 return Edge(_eid(v._id, u._id));
306 Arc arc(const Node& s, const Node& t) const {
308 return Arc((_eid(s._id, t._id) << 1) | 1);
309 } else if (s._id != t._id) {
310 return Arc(_eid(t._id, s._id) << 1);
316 typedef True NodeNumTag;
317 typedef True ArcNumTag;
318 typedef True EdgeNumTag;
320 int nodeNum() const { return _node_num; }
321 int arcNum() const { return 2 * _edge_num; }
322 int edgeNum() const { return _edge_num; }
324 static int id(Node node) { return node._id; }
325 static int id(Arc arc) { return arc._id; }
326 static int id(Edge edge) { return edge._id; }
328 int maxNodeId() const { return _node_num-1; }
329 int maxArcId() const { return 2 * _edge_num-1; }
330 int maxEdgeId() const { return _edge_num-1; }
332 static Node nodeFromId(int id) { return Node(id);}
333 static Arc arcFromId(int id) { return Arc(id);}
334 static Edge edgeFromId(int id) { return Edge(id);}
336 Node u(Edge edge) const {
337 return Node(_uid(edge._id));
340 Node v(Edge edge) const {
341 return Node(_vid(edge._id));
344 Node source(Arc arc) const {
345 return Node((arc._id & 1) == 1 ?
346 _uid(arc._id >> 1) : _vid(arc._id >> 1));
349 Node target(Arc arc) const {
350 return Node((arc._id & 1) == 1 ?
351 _vid(arc._id >> 1) : _uid(arc._id >> 1));
354 typedef True FindEdgeTag;
355 typedef True FindArcTag;
357 Edge findEdge(Node u, Node v, Edge prev = INVALID) const {
358 return prev != INVALID ? INVALID : edge(u, v);
361 Arc findArc(Node s, Node t, Arc prev = INVALID) const {
362 return prev != INVALID ? INVALID : arc(s, t);
366 friend class FullGraphBase;
370 Node(int id) : _id(id) {}
373 Node (Invalid) { _id = -1; }
374 bool operator==(const Node node) const {return _id == node._id;}
375 bool operator!=(const Node node) const {return _id != node._id;}
376 bool operator<(const Node node) const {return _id < node._id;}
380 friend class FullGraphBase;
386 Edge(int id) : _id(id) {}
390 Edge (Invalid) { _id = -1; }
392 bool operator==(const Edge edge) const {return _id == edge._id;}
393 bool operator!=(const Edge edge) const {return _id != edge._id;}
394 bool operator<(const Edge edge) const {return _id < edge._id;}
398 friend class FullGraphBase;
403 Arc(int id) : _id(id) {}
407 Arc (Invalid) { _id = -1; }
409 operator Edge() const { return Edge(_id != -1 ? (_id >> 1) : -1); }
411 bool operator==(const Arc arc) const {return _id == arc._id;}
412 bool operator!=(const Arc arc) const {return _id != arc._id;}
413 bool operator<(const Arc arc) const {return _id < arc._id;}
416 static bool direction(Arc arc) {
417 return (arc._id & 1) == 1;
420 static Arc direct(Edge edge, bool dir) {
421 return Arc((edge._id << 1) | (dir ? 1 : 0));
424 void first(Node& node) const {
425 node._id = _node_num - 1;
428 static void next(Node& node) {
432 void first(Arc& arc) const {
433 arc._id = (_edge_num << 1) - 1;
436 static void next(Arc& arc) {
440 void first(Edge& edge) const {
441 edge._id = _edge_num - 1;
444 static void next(Edge& edge) {
448 void firstOut(Arc& arc, const Node& node) const {
449 int s = node._id, t = _node_num - 1;
451 arc._id = (_eid(s, t) << 1) | 1;
454 arc._id = (t != -1 ? (_eid(t, s) << 1) : -1);
458 void nextOut(Arc& arc) const {
460 _stid(arc._id, s, t);
463 arc._id = (_eid(s, t) << 1) | 1;
466 arc._id = (t != -1 ? (_eid(t, s) << 1) : -1);
470 void firstIn(Arc& arc, const Node& node) const {
471 int s = _node_num - 1, t = node._id;
473 arc._id = (_eid(t, s) << 1);
476 arc._id = (s != -1 ? (_eid(s, t) << 1) | 1 : -1);
480 void nextIn(Arc& arc) const {
482 _stid(arc._id, s, t);
485 arc._id = (_eid(t, s) << 1);
488 arc._id = (s != -1 ? (_eid(s, t) << 1) | 1 : -1);
492 void firstInc(Edge& edge, bool& dir, const Node& node) const {
493 int u = node._id, v = _node_num - 1;
495 edge._id = _eid(u, v);
499 edge._id = (v != -1 ? _eid(v, u) : -1);
504 void nextInc(Edge& edge, bool& dir) const {
507 _uvid(edge._id, u, v);
510 edge._id = _eid(u, v);
513 edge._id = (v != -1 ? _eid(v, u) : -1);
517 _uvid(edge._id, v, u);
519 edge._id = (v != -1 ? _eid(v, u) : -1);
525 typedef GraphExtender<FullGraphBase> ExtendedFullGraphBase;
529 /// \brief An undirected full graph class.
531 /// FullGraph is a simple and fast implmenetation of undirected full
532 /// (complete) graphs. It contains an edge between every distinct pair
533 /// of nodes, therefore the number of edges is <tt>n(n-1)/2</tt>.
534 /// This class is completely static and it needs constant memory space.
535 /// Thus you can neither add nor delete nodes or edges, however
536 /// the structure can be resized using resize().
538 /// This type fully conforms to the \ref concepts::Graph "Graph concept".
539 /// Most of its member functions and nested classes are documented
540 /// only in the concept class.
542 /// This class provides constant time counting for nodes, edges and arcs.
544 /// \note FullDigraph and FullGraph classes are very similar,
545 /// but there are two differences. While FullDigraph
546 /// conforms only to the \ref concepts::Digraph "Digraph" concept,
547 /// this class conforms to the \ref concepts::Graph "Graph" concept,
548 /// moreover this class does not contain a loop for each
549 /// node as FullDigraph does.
552 class FullGraph : public ExtendedFullGraphBase {
553 typedef ExtendedFullGraphBase Parent;
557 /// \brief Default constructor.
559 /// Default constructor. The number of nodes and edges will be zero.
560 FullGraph() { construct(0); }
562 /// \brief Constructor
565 /// \param n The number of the nodes.
566 FullGraph(int n) { construct(n); }
568 /// \brief Resizes the graph
570 /// This function resizes the graph. It fully destroys and
571 /// rebuilds the structure, therefore the maps of the graph will be
572 /// reallocated automatically and the previous values will be lost.
574 Parent::notifier(Arc()).clear();
575 Parent::notifier(Edge()).clear();
576 Parent::notifier(Node()).clear();
578 Parent::notifier(Node()).build();
579 Parent::notifier(Edge()).build();
580 Parent::notifier(Arc()).build();
583 /// \brief Returns the node with the given index.
585 /// Returns the node with the given index. Since this structure is
586 /// completely static, the nodes can be indexed with integers from
587 /// the range <tt>[0..nodeNum()-1]</tt>.
588 /// The index of a node is the same as its ID.
590 Node operator()(int ix) const { return Parent::operator()(ix); }
592 /// \brief Returns the index of the given node.
594 /// Returns the index of the given node. Since this structure is
595 /// completely static, the nodes can be indexed with integers from
596 /// the range <tt>[0..nodeNum()-1]</tt>.
597 /// The index of a node is the same as its ID.
599 static int index(const Node& node) { return Parent::index(node); }
601 /// \brief Returns the arc connecting the given nodes.
603 /// Returns the arc connecting the given nodes.
604 Arc arc(Node s, Node t) const {
605 return Parent::arc(s, t);
608 /// \brief Returns the edge connecting the given nodes.
610 /// Returns the edge connecting the given nodes.
611 Edge edge(Node u, Node v) const {
612 return Parent::edge(u, v);
615 /// \brief Number of nodes.
616 int nodeNum() const { return Parent::nodeNum(); }
617 /// \brief Number of arcs.
618 int arcNum() const { return Parent::arcNum(); }
619 /// \brief Number of edges.
620 int edgeNum() const { return Parent::edgeNum(); }
624 class FullBpGraphBase {
628 int _red_num, _blue_num;
629 int _node_num, _edge_num;
633 typedef FullBpGraphBase Graph;
640 friend class FullBpGraphBase;
644 explicit Node(int id) { _id = id;}
648 Node (Invalid) { _id = -1; }
649 bool operator==(const Node& node) const {return _id == node._id;}
650 bool operator!=(const Node& node) const {return _id != node._id;}
651 bool operator<(const Node& node) const {return _id < node._id;}
655 friend class FullBpGraphBase;
659 explicit Edge(int id) { _id = id;}
663 Edge (Invalid) { _id = -1; }
664 bool operator==(const Edge& arc) const {return _id == arc._id;}
665 bool operator!=(const Edge& arc) const {return _id != arc._id;}
666 bool operator<(const Edge& arc) const {return _id < arc._id;}
670 friend class FullBpGraphBase;
674 explicit Arc(int id) { _id = id;}
677 operator Edge() const {
678 return _id != -1 ? edgeFromId(_id / 2) : INVALID;
682 Arc (Invalid) { _id = -1; }
683 bool operator==(const Arc& arc) const {return _id == arc._id;}
684 bool operator!=(const Arc& arc) const {return _id != arc._id;}
685 bool operator<(const Arc& arc) const {return _id < arc._id;}
692 : _red_num(0), _blue_num(0), _node_num(0), _edge_num(0) {}
694 void construct(int redNum, int blueNum) {
695 _red_num = redNum; _blue_num = blueNum;
696 _node_num = redNum + blueNum; _edge_num = redNum * blueNum;
701 typedef True NodeNumTag;
702 typedef True EdgeNumTag;
703 typedef True ArcNumTag;
705 int nodeNum() const { return _node_num; }
706 int redNum() const { return _red_num; }
707 int blueNum() const { return _blue_num; }
708 int edgeNum() const { return _edge_num; }
709 int arcNum() const { return 2 * _edge_num; }
711 int maxNodeId() const { return _node_num - 1; }
712 int maxRedId() const { return _red_num - 1; }
713 int maxBlueId() const { return _blue_num - 1; }
714 int maxEdgeId() const { return _edge_num - 1; }
715 int maxArcId() const { return 2 * _edge_num - 1; }
717 bool red(Node n) const { return n._id < _red_num; }
718 bool blue(Node n) const { return n._id >= _red_num; }
720 Node source(Arc a) const {
722 return Node((a._id >> 1) % _red_num);
724 return Node((a._id >> 1) / _red_num + _red_num);
727 Node target(Arc a) const {
729 return Node((a._id >> 1) / _red_num + _red_num);
731 return Node((a._id >> 1) % _red_num);
735 Node redNode(Edge e) const {
736 return Node(e._id % _red_num);
738 Node blueNode(Edge e) const {
739 return Node(e._id / _red_num + _red_num);
742 static bool direction(Arc a) {
743 return (a._id & 1) == 1;
746 static Arc direct(Edge e, bool d) {
747 return Arc(e._id * 2 + (d ? 1 : 0));
750 void first(Node& node) const {
751 node._id = _node_num - 1;
754 static void next(Node& node) {
758 void firstRed(Node& node) const {
759 node._id = _red_num - 1;
762 static void nextRed(Node& node) {
766 void firstBlue(Node& node) const {
767 if (_red_num == _node_num) node._id = -1;
768 else node._id = _node_num - 1;
771 void nextBlue(Node& node) const {
772 if (node._id == _red_num) node._id = -1;
776 void first(Arc& arc) const {
777 arc._id = 2 * _edge_num - 1;
780 static void next(Arc& arc) {
784 void first(Edge& arc) const {
785 arc._id = _edge_num - 1;
788 static void next(Edge& arc) {
792 void firstOut(Arc &a, const Node& v) const {
793 if (v._id < _red_num) {
794 a._id = 2 * (v._id + _red_num * (_blue_num - 1)) + 1;
796 a._id = 2 * (_red_num - 1 + _red_num * (v._id - _red_num));
799 void nextOut(Arc &a) const {
801 a._id -= 2 * _red_num;
802 if (a._id < 0) a._id = -1;
804 if (a._id % (2 * _red_num) == 0) a._id = -1;
809 void firstIn(Arc &a, const Node& v) const {
810 if (v._id < _red_num) {
811 a._id = 2 * (v._id + _red_num * (_blue_num - 1));
813 a._id = 2 * (_red_num - 1 + _red_num * (v._id - _red_num)) + 1;
816 void nextIn(Arc &a) const {
818 if (a._id % (2 * _red_num) == 1) a._id = -1;
821 a._id -= 2 * _red_num;
822 if (a._id < 0) a._id = -1;
826 void firstInc(Edge &e, bool& d, const Node& v) const {
827 if (v._id < _red_num) {
829 e._id = v._id + _red_num * (_blue_num - 1);
832 e._id = _red_num - 1 + _red_num * (v._id - _red_num);
835 void nextInc(Edge &e, bool& d) const {
838 if (e._id < 0) e._id = -1;
840 if (e._id % _red_num == 0) e._id = -1;
845 static int id(Node v) { return v._id; }
846 int redId(Node v) const {
847 LEMON_DEBUG(v._id < _red_num, "Node has to be red");
850 int blueId(Node v) const {
851 LEMON_DEBUG(v._id >= _red_num, "Node has to be blue");
852 return v._id - _red_num;
854 static int id(Arc e) { return e._id; }
855 static int id(Edge e) { return e._id; }
857 static Node nodeFromId(int id) { return Node(id);}
858 static Arc arcFromId(int id) { return Arc(id);}
859 static Edge edgeFromId(int id) { return Edge(id);}
861 bool valid(Node n) const {
862 return n._id >= 0 && n._id < _node_num;
864 bool valid(Arc a) const {
865 return a._id >= 0 && a._id < 2 * _edge_num;
867 bool valid(Edge e) const {
868 return e._id >= 0 && e._id < _edge_num;
871 Node redNode(int index) const {
875 int redIndex(Node n) const {
879 Node blueNode(int index) const {
880 return Node(index + _red_num);
883 int blueIndex(Node n) const {
884 return n._id - _red_num;
888 _red_num = 0; _blue_num = 0;
889 _node_num = 0; _edge_num = 0;
892 Edge edge(const Node& u, const Node& v) const {
893 if (u._id < _red_num) {
894 if (v._id < _red_num) {
897 return Edge(u._id + _red_num * (v._id - _red_num));
900 if (v._id < _red_num) {
901 return Edge(v._id + _red_num * (u._id - _red_num));
908 Arc arc(const Node& u, const Node& v) const {
909 if (u._id < _red_num) {
910 if (v._id < _red_num) {
913 return Arc(2 * (u._id + _red_num * (v._id - _red_num)) + 1);
916 if (v._id < _red_num) {
917 return Arc(2 * (v._id + _red_num * (u._id - _red_num)));
924 typedef True FindEdgeTag;
925 typedef True FindArcTag;
927 Edge findEdge(Node u, Node v, Edge prev = INVALID) const {
928 return prev != INVALID ? INVALID : edge(u, v);
931 Arc findArc(Node s, Node t, Arc prev = INVALID) const {
932 return prev != INVALID ? INVALID : arc(s, t);
937 typedef BpGraphExtender<FullBpGraphBase> ExtendedFullBpGraphBase;
941 /// \brief An undirected full bipartite graph class.
943 /// FullBpGraph is a simple and fast implmenetation of undirected
944 /// full bipartite graphs. It contains an edge between every
945 /// red-blue pairs of nodes, therefore the number of edges is
946 /// <tt>nr*nb</tt>. This class is completely static and it needs
947 /// constant memory space. Thus you can neither add nor delete
948 /// nodes or edges, however the structure can be resized using
951 /// This type fully conforms to the \ref concepts::BpGraph "BpGraph concept".
952 /// Most of its member functions and nested classes are documented
953 /// only in the concept class.
955 /// This class provides constant time counting for nodes, edges and arcs.
958 class FullBpGraph : public ExtendedFullBpGraphBase {
961 typedef ExtendedFullBpGraphBase Parent;
963 /// \brief Default constructor.
965 /// Default constructor. The number of nodes and edges will be zero.
966 FullBpGraph() { construct(0, 0); }
968 /// \brief Constructor
971 /// \param redNum The number of the red nodes.
972 /// \param blueNum The number of the blue nodes.
973 FullBpGraph(int redNum, int blueNum) { construct(redNum, blueNum); }
975 /// \brief Resizes the graph
977 /// This function resizes the graph. It fully destroys and
978 /// rebuilds the structure, therefore the maps of the graph will be
979 /// reallocated automatically and the previous values will be lost.
980 void resize(int redNum, int blueNum) {
981 Parent::notifier(Arc()).clear();
982 Parent::notifier(Edge()).clear();
983 Parent::notifier(Node()).clear();
984 Parent::notifier(BlueNode()).clear();
985 Parent::notifier(RedNode()).clear();
986 construct(redNum, blueNum);
987 Parent::notifier(RedNode()).build();
988 Parent::notifier(BlueNode()).build();
989 Parent::notifier(Node()).build();
990 Parent::notifier(Edge()).build();
991 Parent::notifier(Arc()).build();
994 /// \brief Returns the red node with the given index.
996 /// Returns the red node with the given index. Since this
997 /// structure is completely static, the red nodes can be indexed
998 /// with integers from the range <tt>[0..redNum()-1]</tt>.
1000 Node redNode(int index) const { return Parent::redNode(index); }
1002 /// \brief Returns the index of the given red node.
1004 /// Returns the index of the given red node. Since this structure
1005 /// is completely static, the red nodes can be indexed with
1006 /// integers from the range <tt>[0..redNum()-1]</tt>.
1008 /// \sa operator()()
1009 int redIndex(Node node) const { return Parent::redIndex(node); }
1011 /// \brief Returns the blue node with the given index.
1013 /// Returns the blue node with the given index. Since this
1014 /// structure is completely static, the blue nodes can be indexed
1015 /// with integers from the range <tt>[0..blueNum()-1]</tt>.
1017 Node blueNode(int index) const { return Parent::blueNode(index); }
1019 /// \brief Returns the index of the given blue node.
1021 /// Returns the index of the given blue node. Since this structure
1022 /// is completely static, the blue nodes can be indexed with
1023 /// integers from the range <tt>[0..blueNum()-1]</tt>.
1025 /// \sa operator()()
1026 int blueIndex(Node node) const { return Parent::blueIndex(node); }
1028 /// \brief Returns the edge which connects the given nodes.
1030 /// Returns the edge which connects the given nodes.
1031 Edge edge(const Node& u, const Node& v) const {
1032 return Parent::edge(u, v);
1035 /// \brief Returns the arc which connects the given nodes.
1037 /// Returns the arc which connects the given nodes.
1038 Arc arc(const Node& u, const Node& v) const {
1039 return Parent::arc(u, v);
1042 /// \brief Number of nodes.
1043 int nodeNum() const { return Parent::nodeNum(); }
1044 /// \brief Number of red nodes.
1045 int redNum() const { return Parent::redNum(); }
1046 /// \brief Number of blue nodes.
1047 int blueNum() const { return Parent::blueNum(); }
1048 /// \brief Number of arcs.
1049 int arcNum() const { return Parent::arcNum(); }
1050 /// \brief Number of edges.
1051 int edgeNum() const { return Parent::edgeNum(); }
1058 #endif //LEMON_FULL_GRAPH_H