1.1 --- a/lemon/full_graph.h Thu Jan 26 15:42:13 2006 +0000
1.2 +++ b/lemon/full_graph.h Thu Jan 26 16:24:40 2006 +0000
1.3 @@ -403,11 +403,11 @@
1.4 };
1.5
1.6
1.7 - class FullUBipartiteGraphBase {
1.8 + class FullBpUGraphBase {
1.9 protected:
1.10
1.11 - int _upperNodeNum;
1.12 - int _lowerNodeNum;
1.13 + int _aNodeNum;
1.14 + int _bNodeNum;
1.15
1.16 int _edgeNum;
1.17
1.18 @@ -415,12 +415,12 @@
1.19
1.20 class NodeSetError : public LogicError {
1.21 virtual const char* exceptionName() const {
1.22 - return "lemon::FullUBipartiteGraph::NodeSetError";
1.23 + return "lemon::FullBpUGraph::NodeSetError";
1.24 }
1.25 };
1.26
1.27 class Node {
1.28 - friend class FullUBipartiteGraphBase;
1.29 + friend class FullBpUGraphBase;
1.30 protected:
1.31 int id;
1.32
1.33 @@ -434,7 +434,7 @@
1.34 };
1.35
1.36 class Edge {
1.37 - friend class FullUBipartiteGraphBase;
1.38 + friend class FullBpUGraphBase;
1.39 protected:
1.40 int id;
1.41
1.42 @@ -447,39 +447,39 @@
1.43 bool operator<(const Edge i) const {return id<i.id;}
1.44 };
1.45
1.46 - void construct(int upperNodeNum, int lowerNodeNum) {
1.47 - _upperNodeNum = upperNodeNum;
1.48 - _lowerNodeNum = lowerNodeNum;
1.49 - _edgeNum = upperNodeNum * lowerNodeNum;
1.50 + void construct(int aNodeNum, int bNodeNum) {
1.51 + _aNodeNum = aNodeNum;
1.52 + _bNodeNum = bNodeNum;
1.53 + _edgeNum = aNodeNum * bNodeNum;
1.54 }
1.55
1.56 - void firstUpper(Node& node) const {
1.57 - node.id = 2 * _upperNodeNum - 2;
1.58 + void firstANode(Node& node) const {
1.59 + node.id = 2 * _aNodeNum - 2;
1.60 if (node.id < 0) node.id = -1;
1.61 }
1.62 - void nextUpper(Node& node) const {
1.63 + void nextANode(Node& node) const {
1.64 node.id -= 2;
1.65 if (node.id < 0) node.id = -1;
1.66 }
1.67
1.68 - void firstLower(Node& node) const {
1.69 - node.id = 2 * _lowerNodeNum - 1;
1.70 + void firstBNode(Node& node) const {
1.71 + node.id = 2 * _bNodeNum - 1;
1.72 }
1.73 - void nextLower(Node& node) const {
1.74 + void nextBNode(Node& node) const {
1.75 node.id -= 2;
1.76 }
1.77
1.78 void first(Node& node) const {
1.79 - if (_upperNodeNum > 0) {
1.80 - node.id = 2 * _upperNodeNum - 2;
1.81 + if (_aNodeNum > 0) {
1.82 + node.id = 2 * _aNodeNum - 2;
1.83 } else {
1.84 - node.id = 2 * _lowerNodeNum - 1;
1.85 + node.id = 2 * _bNodeNum - 1;
1.86 }
1.87 }
1.88 void next(Node& node) const {
1.89 node.id -= 2;
1.90 if (node.id == -2) {
1.91 - node.id = 2 * _lowerNodeNum - 1;
1.92 + node.id = 2 * _bNodeNum - 1;
1.93 }
1.94 }
1.95
1.96 @@ -490,21 +490,21 @@
1.97 --edge.id;
1.98 }
1.99
1.100 - void firstDown(Edge& edge, const Node& node) const {
1.101 + void firstOut(Edge& edge, const Node& node) const {
1.102 LEMON_ASSERT((node.id & 1) == 0, NodeSetError());
1.103 - edge.id = (node.id >> 1) * _lowerNodeNum;
1.104 + edge.id = (node.id >> 1) * _bNodeNum;
1.105 }
1.106 - void nextDown(Edge& edge) const {
1.107 + void nextOut(Edge& edge) const {
1.108 ++(edge.id);
1.109 - if (edge.id % _lowerNodeNum == 0) edge.id = -1;
1.110 + if (edge.id % _bNodeNum == 0) edge.id = -1;
1.111 }
1.112
1.113 - void firstUp(Edge& edge, const Node& node) const {
1.114 + void firstIn(Edge& edge, const Node& node) const {
1.115 LEMON_ASSERT((node.id & 1) == 1, NodeSetError());
1.116 edge.id = (node.id >> 1);
1.117 }
1.118 - void nextUp(Edge& edge) const {
1.119 - edge.id += _lowerNodeNum;
1.120 + void nextIn(Edge& edge) const {
1.121 + edge.id += _bNodeNum;
1.122 if (edge.id >= _edgeNum) edge.id = -1;
1.123 }
1.124
1.125 @@ -515,8 +515,8 @@
1.126 return Node(id);
1.127 }
1.128 int maxNodeId() const {
1.129 - return _upperNodeNum > _lowerNodeNum ?
1.130 - _upperNodeNum * 2 - 2 : _lowerNodeNum * 2 - 1;
1.131 + return _aNodeNum > _bNodeNum ?
1.132 + _aNodeNum * 2 - 2 : _bNodeNum * 2 - 1;
1.133 }
1.134
1.135 static int id(const Edge& edge) {
1.136 @@ -529,66 +529,77 @@
1.137 return _edgeNum - 1;
1.138 }
1.139
1.140 - static int upperId(const Node& node) {
1.141 + static int aNodeId(const Node& node) {
1.142 return node.id >> 1;
1.143 }
1.144 - static Node fromUpperId(int id, Node) {
1.145 + static Node fromANodeId(int id, Node) {
1.146 return Node(id << 1);
1.147 }
1.148 - int maxUpperId() const {
1.149 - return _upperNodeNum;
1.150 + int maxANodeId() const {
1.151 + return _aNodeNum;
1.152 }
1.153
1.154 - static int lowerId(const Node& node) {
1.155 + static int bNodeId(const Node& node) {
1.156 return node.id >> 1;
1.157 }
1.158 - static Node fromLowerId(int id) {
1.159 + static Node fromBNodeId(int id) {
1.160 return Node((id << 1) + 1);
1.161 }
1.162 - int maxLowerId() const {
1.163 - return _lowerNodeNum;
1.164 + int maxBNodeId() const {
1.165 + return _bNodeNum;
1.166 }
1.167
1.168 - Node upperNode(const Edge& edge) const {
1.169 - return Node((edge.id / _lowerNodeNum) << 1);
1.170 + Node aNode(const Edge& edge) const {
1.171 + return Node((edge.id / _bNodeNum) << 1);
1.172 }
1.173 - Node lowerNode(const Edge& edge) const {
1.174 - return Node(((edge.id % _lowerNodeNum) << 1) + 1);
1.175 + Node bNode(const Edge& edge) const {
1.176 + return Node(((edge.id % _bNodeNum) << 1) + 1);
1.177 }
1.178
1.179 - static bool upper(const Node& node) {
1.180 + static bool aNode(const Node& node) {
1.181 return (node.id & 1) == 0;
1.182 }
1.183
1.184 - static bool lower(const Node& node) {
1.185 + static bool bNode(const Node& node) {
1.186 return (node.id & 1) == 1;
1.187 }
1.188
1.189 - static Node upperNode(int index) {
1.190 + static Node aNode(int index) {
1.191 return Node(index << 1);
1.192 }
1.193
1.194 - static Node lowerNode(int index) {
1.195 + static Node bNode(int index) {
1.196 return Node((index << 1) + 1);
1.197 }
1.198
1.199 };
1.200
1.201
1.202 - typedef StaticMappableUBipartiteGraphExtender<
1.203 - IterableUBipartiteGraphExtender<
1.204 - AlterableUBipartiteGraphExtender<
1.205 - UBipartiteGraphExtender <
1.206 - FullUBipartiteGraphBase> > > >
1.207 - ExtendedFullUBipartiteGraphBase;
1.208 + typedef StaticMappableBpUGraphExtender<
1.209 + IterableBpUGraphExtender<
1.210 + AlterableBpUGraphExtender<
1.211 + BpUGraphExtender <
1.212 + FullBpUGraphBase> > > >
1.213 + ExtendedFullBpUGraphBase;
1.214
1.215
1.216 - class FullUBipartiteGraph :
1.217 - public ExtendedFullUBipartiteGraphBase {
1.218 + /// \ingroup graphs
1.219 + ///
1.220 + /// \brief An undirected full bipartite graph class.
1.221 + ///
1.222 + /// This is a simple and fast bipartite undirected full graph implementation.
1.223 + /// It is completely static, so you can neither add nor delete either
1.224 + /// edges or nodes.
1.225 + ///
1.226 + /// \sa FullGraph
1.227 + ///
1.228 + /// \author Balazs Dezso
1.229 + class FullBpUGraph :
1.230 + public ExtendedFullBpUGraphBase {
1.231 public:
1.232 - typedef ExtendedFullUBipartiteGraphBase Parent;
1.233 - FullUBipartiteGraph(int upperNodeNum, int lowerNodeNum) {
1.234 - Parent::construct(upperNodeNum, lowerNodeNum);
1.235 + typedef ExtendedFullBpUGraphBase Parent;
1.236 + FullBpUGraph(int aNodeNum, int bNodeNum) {
1.237 + Parent::construct(aNodeNum, bNodeNum);
1.238 }
1.239 };
1.240