0
6
0
| ... | ... |
@@ -47,29 +47,29 @@ |
| 47 | 47 |
|
| 48 | 48 |
typedef typename Parent::Node Node; |
| 49 | 49 |
typedef typename Parent::Arc Arc; |
| 50 | 50 |
|
| 51 | 51 |
int maxId(Node) const {
|
| 52 | 52 |
return Parent::maxNodeId(); |
| 53 | 53 |
} |
| 54 | 54 |
|
| 55 | 55 |
int maxId(Arc) const {
|
| 56 | 56 |
return Parent::maxArcId(); |
| 57 | 57 |
} |
| 58 | 58 |
|
| 59 |
Node fromId(int id, Node) |
|
| 59 |
static Node fromId(int id, Node) {
|
|
| 60 | 60 |
return Parent::nodeFromId(id); |
| 61 | 61 |
} |
| 62 | 62 |
|
| 63 |
Arc fromId(int id, Arc) |
|
| 63 |
static Arc fromId(int id, Arc) {
|
|
| 64 | 64 |
return Parent::arcFromId(id); |
| 65 | 65 |
} |
| 66 | 66 |
|
| 67 | 67 |
Node oppositeNode(const Node &node, const Arc &arc) const {
|
| 68 | 68 |
if (node == Parent::source(arc)) |
| 69 | 69 |
return Parent::target(arc); |
| 70 | 70 |
else if(node == Parent::target(arc)) |
| 71 | 71 |
return Parent::source(arc); |
| 72 | 72 |
else |
| 73 | 73 |
return INVALID; |
| 74 | 74 |
} |
| 75 | 75 |
|
| ... | ... |
@@ -346,33 +346,33 @@ |
| 346 | 346 |
int maxId(Node) const {
|
| 347 | 347 |
return Parent::maxNodeId(); |
| 348 | 348 |
} |
| 349 | 349 |
|
| 350 | 350 |
int maxId(Arc) const {
|
| 351 | 351 |
return Parent::maxArcId(); |
| 352 | 352 |
} |
| 353 | 353 |
|
| 354 | 354 |
int maxId(Edge) const {
|
| 355 | 355 |
return Parent::maxEdgeId(); |
| 356 | 356 |
} |
| 357 | 357 |
|
| 358 |
Node fromId(int id, Node) |
|
| 358 |
static Node fromId(int id, Node) {
|
|
| 359 | 359 |
return Parent::nodeFromId(id); |
| 360 | 360 |
} |
| 361 | 361 |
|
| 362 |
Arc fromId(int id, Arc) |
|
| 362 |
static Arc fromId(int id, Arc) {
|
|
| 363 | 363 |
return Parent::arcFromId(id); |
| 364 | 364 |
} |
| 365 | 365 |
|
| 366 |
Edge fromId(int id, Edge) |
|
| 366 |
static Edge fromId(int id, Edge) {
|
|
| 367 | 367 |
return Parent::edgeFromId(id); |
| 368 | 368 |
} |
| 369 | 369 |
|
| 370 | 370 |
Node oppositeNode(const Node &n, const Edge &e) const {
|
| 371 | 371 |
if( n == Parent::u(e)) |
| 372 | 372 |
return Parent::v(e); |
| 373 | 373 |
else if( n == Parent::v(e)) |
| 374 | 374 |
return Parent::u(e); |
| 375 | 375 |
else |
| 376 | 376 |
return INVALID; |
| 377 | 377 |
} |
| 378 | 378 |
| ... | ... |
@@ -858,25 +858,25 @@ |
| 858 | 858 |
void first(Node& node) const {
|
| 859 | 859 |
_graph->first(node); |
| 860 | 860 |
} |
| 861 | 861 |
|
| 862 | 862 |
void next(Node& node) const {
|
| 863 | 863 |
_graph->next(node); |
| 864 | 864 |
} |
| 865 | 865 |
|
| 866 | 866 |
void first(Arc& arc) const {
|
| 867 | 867 |
arc.id = arcs.size() - 1; |
| 868 | 868 |
} |
| 869 | 869 |
|
| 870 |
void next(Arc& arc) |
|
| 870 |
static void next(Arc& arc) {
|
|
| 871 | 871 |
--arc.id; |
| 872 | 872 |
} |
| 873 | 873 |
|
| 874 | 874 |
void firstOut(Arc& arc, const Node& node) const {
|
| 875 | 875 |
arc.id = (*_nodes)[node].first_out; |
| 876 | 876 |
} |
| 877 | 877 |
|
| 878 | 878 |
void nextOut(Arc& arc) const {
|
| 879 | 879 |
arc.id = arcs[arc.id].next_out; |
| 880 | 880 |
} |
| 881 | 881 |
|
| 882 | 882 |
void firstIn(Arc& arc, const Node& node) const {
|
| ... | ... |
@@ -1164,33 +1164,33 @@ |
| 1164 | 1164 |
void first(Node& node) const {
|
| 1165 | 1165 |
_graph->first(node); |
| 1166 | 1166 |
} |
| 1167 | 1167 |
|
| 1168 | 1168 |
void next(Node& node) const {
|
| 1169 | 1169 |
_graph->next(node); |
| 1170 | 1170 |
} |
| 1171 | 1171 |
|
| 1172 | 1172 |
void first(Arc& arc) const {
|
| 1173 | 1173 |
arc.id = arcs.size() - 1; |
| 1174 | 1174 |
} |
| 1175 | 1175 |
|
| 1176 |
void next(Arc& arc) |
|
| 1176 |
static void next(Arc& arc) {
|
|
| 1177 | 1177 |
--arc.id; |
| 1178 | 1178 |
} |
| 1179 | 1179 |
|
| 1180 | 1180 |
void first(Edge& arc) const {
|
| 1181 | 1181 |
arc.id = arcs.size() / 2 - 1; |
| 1182 | 1182 |
} |
| 1183 | 1183 |
|
| 1184 |
void next(Edge& arc) |
|
| 1184 |
static void next(Edge& arc) {
|
|
| 1185 | 1185 |
--arc.id; |
| 1186 | 1186 |
} |
| 1187 | 1187 |
|
| 1188 | 1188 |
void firstOut(Arc& arc, const Node& node) const {
|
| 1189 | 1189 |
arc.id = (*_nodes)[node].first_out; |
| 1190 | 1190 |
} |
| 1191 | 1191 |
|
| 1192 | 1192 |
void nextOut(Arc& arc) const {
|
| 1193 | 1193 |
arc.id = arcs[arc.id].next_out; |
| 1194 | 1194 |
} |
| 1195 | 1195 |
|
| 1196 | 1196 |
void firstIn(Arc& arc, const Node& node) const {
|
| ... | ... |
@@ -42,25 +42,25 @@ |
| 42 | 42 |
int _arc_num; |
| 43 | 43 |
|
| 44 | 44 |
FullDigraphBase() {}
|
| 45 | 45 |
|
| 46 | 46 |
void construct(int n) { _node_num = n; _arc_num = n * n; }
|
| 47 | 47 |
|
| 48 | 48 |
public: |
| 49 | 49 |
|
| 50 | 50 |
typedef True NodeNumTag; |
| 51 | 51 |
typedef True ArcNumTag; |
| 52 | 52 |
|
| 53 | 53 |
Node operator()(int ix) const { return Node(ix); }
|
| 54 |
int index(const Node& node) |
|
| 54 |
static int index(const Node& node) { return node._id; }
|
|
| 55 | 55 |
|
| 56 | 56 |
Arc arc(const Node& s, const Node& t) const {
|
| 57 | 57 |
return Arc(s._id * _node_num + t._id); |
| 58 | 58 |
} |
| 59 | 59 |
|
| 60 | 60 |
int nodeNum() const { return _node_num; }
|
| 61 | 61 |
int arcNum() const { return _arc_num; }
|
| 62 | 62 |
|
| 63 | 63 |
int maxNodeId() const { return _node_num - 1; }
|
| 64 | 64 |
int maxArcId() const { return _arc_num - 1; }
|
| 65 | 65 |
|
| 66 | 66 |
Node source(Arc arc) const { return arc._id / _node_num; }
|
| ... | ... |
@@ -200,25 +200,25 @@ |
| 200 | 200 |
/// Returns the node with the given index. Since it is a static |
| 201 | 201 |
/// digraph its nodes can be indexed with integers from the range |
| 202 | 202 |
/// <tt>[0..nodeNum()-1]</tt>. |
| 203 | 203 |
/// \sa index() |
| 204 | 204 |
Node operator()(int ix) const { return Parent::operator()(ix); }
|
| 205 | 205 |
|
| 206 | 206 |
/// \brief Returns the index of the given node. |
| 207 | 207 |
/// |
| 208 | 208 |
/// Returns the index of the given node. Since it is a static |
| 209 | 209 |
/// digraph its nodes can be indexed with integers from the range |
| 210 | 210 |
/// <tt>[0..nodeNum()-1]</tt>. |
| 211 | 211 |
/// \sa operator() |
| 212 |
int index(const Node& node) |
|
| 212 |
static int index(const Node& node) { return Parent::index(node); }
|
|
| 213 | 213 |
|
| 214 | 214 |
/// \brief Returns the arc connecting the given nodes. |
| 215 | 215 |
/// |
| 216 | 216 |
/// Returns the arc connecting the given nodes. |
| 217 | 217 |
Arc arc(const Node& u, const Node& v) const {
|
| 218 | 218 |
return Parent::arc(u, v); |
| 219 | 219 |
} |
| 220 | 220 |
|
| 221 | 221 |
/// \brief Number of nodes. |
| 222 | 222 |
int nodeNum() const { return Parent::nodeNum(); }
|
| 223 | 223 |
/// \brief Number of arcs. |
| 224 | 224 |
int arcNum() const { return Parent::arcNum(); }
|
| ... | ... |
@@ -274,25 +274,25 @@ |
| 274 | 274 |
|
| 275 | 275 |
int _eid(int u, int v) const {
|
| 276 | 276 |
if (u < (_node_num - 1) / 2) {
|
| 277 | 277 |
return u * _node_num + v; |
| 278 | 278 |
} else {
|
| 279 | 279 |
return (_node_num - 1 - u) * _node_num - v - 1; |
| 280 | 280 |
} |
| 281 | 281 |
} |
| 282 | 282 |
|
| 283 | 283 |
public: |
| 284 | 284 |
|
| 285 | 285 |
Node operator()(int ix) const { return Node(ix); }
|
| 286 |
int index(const Node& node) |
|
| 286 |
static int index(const Node& node) { return node._id; }
|
|
| 287 | 287 |
|
| 288 | 288 |
Edge edge(const Node& u, const Node& v) const {
|
| 289 | 289 |
if (u._id < v._id) {
|
| 290 | 290 |
return Edge(_eid(u._id, v._id)); |
| 291 | 291 |
} else if (u._id != v._id) {
|
| 292 | 292 |
return Edge(_eid(v._id, u._id)); |
| 293 | 293 |
} else {
|
| 294 | 294 |
return INVALID; |
| 295 | 295 |
} |
| 296 | 296 |
} |
| 297 | 297 |
|
| 298 | 298 |
Arc arc(const Node& s, const Node& t) const {
|
| ... | ... |
@@ -571,25 +571,25 @@ |
| 571 | 571 |
/// Returns the node with the given index. Since it is a static |
| 572 | 572 |
/// graph its nodes can be indexed with integers from the range |
| 573 | 573 |
/// <tt>[0..nodeNum()-1]</tt>. |
| 574 | 574 |
/// \sa index() |
| 575 | 575 |
Node operator()(int ix) const { return Parent::operator()(ix); }
|
| 576 | 576 |
|
| 577 | 577 |
/// \brief Returns the index of the given node. |
| 578 | 578 |
/// |
| 579 | 579 |
/// Returns the index of the given node. Since it is a static |
| 580 | 580 |
/// graph its nodes can be indexed with integers from the range |
| 581 | 581 |
/// <tt>[0..nodeNum()-1]</tt>. |
| 582 | 582 |
/// \sa operator() |
| 583 |
int index(const Node& node) |
|
| 583 |
static int index(const Node& node) { return Parent::index(node); }
|
|
| 584 | 584 |
|
| 585 | 585 |
/// \brief Returns the arc connecting the given nodes. |
| 586 | 586 |
/// |
| 587 | 587 |
/// Returns the arc connecting the given nodes. |
| 588 | 588 |
Arc arc(const Node& s, const Node& t) const {
|
| 589 | 589 |
return Parent::arc(s, t); |
| 590 | 590 |
} |
| 591 | 591 |
|
| 592 | 592 |
/// \brief Returns the edge connects the given nodes. |
| 593 | 593 |
/// |
| 594 | 594 |
/// Returns the edge connects the given nodes. |
| 595 | 595 |
Edge edge(const Node& u, const Node& v) const {
|
| ... | ... |
@@ -253,25 +253,25 @@ |
| 253 | 253 |
bool projection(Node node, int n) const {
|
| 254 | 254 |
return static_cast<bool>(node._id & (1 << n)); |
| 255 | 255 |
} |
| 256 | 256 |
|
| 257 | 257 |
int dimension(Edge edge) const {
|
| 258 | 258 |
return edge._id >> (_dim-1); |
| 259 | 259 |
} |
| 260 | 260 |
|
| 261 | 261 |
int dimension(Arc arc) const {
|
| 262 | 262 |
return arc._id >> _dim; |
| 263 | 263 |
} |
| 264 | 264 |
|
| 265 |
int index(Node node) |
|
| 265 |
static int index(Node node) {
|
|
| 266 | 266 |
return node._id; |
| 267 | 267 |
} |
| 268 | 268 |
|
| 269 | 269 |
Node operator()(int ix) const {
|
| 270 | 270 |
return Node(ix); |
| 271 | 271 |
} |
| 272 | 272 |
|
| 273 | 273 |
private: |
| 274 | 274 |
int _dim; |
| 275 | 275 |
int _node_num, _edge_num; |
| 276 | 276 |
}; |
| 277 | 277 |
|
| ... | ... |
@@ -328,25 +328,25 @@ |
| 328 | 328 |
/// \brief The dimension id of an arc. |
| 329 | 329 |
/// |
| 330 | 330 |
/// Gives back the dimension id of the given arc. |
| 331 | 331 |
/// It is in the [0..dim-1] range. |
| 332 | 332 |
int dimension(Arc arc) const {
|
| 333 | 333 |
return Parent::dimension(arc); |
| 334 | 334 |
} |
| 335 | 335 |
|
| 336 | 336 |
/// \brief The index of a node. |
| 337 | 337 |
/// |
| 338 | 338 |
/// Gives back the index of the given node. |
| 339 | 339 |
/// The lower bits of the integer describes the node. |
| 340 |
int index(Node node) |
|
| 340 |
static int index(Node node) {
|
|
| 341 | 341 |
return Parent::index(node); |
| 342 | 342 |
} |
| 343 | 343 |
|
| 344 | 344 |
/// \brief Gives back a node by its index. |
| 345 | 345 |
/// |
| 346 | 346 |
/// Gives back a node by its index. |
| 347 | 347 |
Node operator()(int ix) const {
|
| 348 | 348 |
return Parent::operator()(ix); |
| 349 | 349 |
} |
| 350 | 350 |
|
| 351 | 351 |
/// \brief Number of nodes. |
| 352 | 352 |
int nodeNum() const { return Parent::nodeNum(); }
|
| ... | ... |
@@ -499,41 +499,41 @@ |
| 499 | 499 |
static bool direction(Arc e) {
|
| 500 | 500 |
return (e._id & 1) == 1; |
| 501 | 501 |
} |
| 502 | 502 |
|
| 503 | 503 |
static Arc direct(Edge e, bool d) {
|
| 504 | 504 |
return Arc(e._id * 2 + (d ? 1 : 0)); |
| 505 | 505 |
} |
| 506 | 506 |
|
| 507 | 507 |
void first(Node& node) const {
|
| 508 | 508 |
node._id = nodes.size() - 1; |
| 509 | 509 |
} |
| 510 | 510 |
|
| 511 |
void next(Node& node) |
|
| 511 |
static void next(Node& node) {
|
|
| 512 | 512 |
--node._id; |
| 513 | 513 |
} |
| 514 | 514 |
|
| 515 | 515 |
void first(Arc& arc) const {
|
| 516 | 516 |
arc._id = arcs.size() - 1; |
| 517 | 517 |
} |
| 518 | 518 |
|
| 519 |
void next(Arc& arc) |
|
| 519 |
static void next(Arc& arc) {
|
|
| 520 | 520 |
--arc._id; |
| 521 | 521 |
} |
| 522 | 522 |
|
| 523 | 523 |
void first(Edge& arc) const {
|
| 524 | 524 |
arc._id = arcs.size() / 2 - 1; |
| 525 | 525 |
} |
| 526 | 526 |
|
| 527 |
void next(Edge& arc) |
|
| 527 |
static void next(Edge& arc) {
|
|
| 528 | 528 |
--arc._id; |
| 529 | 529 |
} |
| 530 | 530 |
|
| 531 | 531 |
void firstOut(Arc &arc, const Node& v) const {
|
| 532 | 532 |
arc._id = nodes[v._id].first_out; |
| 533 | 533 |
} |
| 534 | 534 |
void nextOut(Arc &arc) const {
|
| 535 | 535 |
arc._id = arcs[arc._id].next_out; |
| 536 | 536 |
} |
| 537 | 537 |
|
| 538 | 538 |
void firstIn(Arc &arc, const Node& v) const {
|
| 539 | 539 |
arc._id = ((nodes[v._id].first_out) ^ 1); |
| ... | ... |
@@ -83,30 +83,30 @@ |
| 83 | 83 |
void first(Arc& e) const { e.id = arc_num - 1; }
|
| 84 | 84 |
static void next(Arc& e) { --e.id; }
|
| 85 | 85 |
|
| 86 | 86 |
void firstOut(Arc& e, const Node& n) const {
|
| 87 | 87 |
e.id = node_first_out[n.id] != node_first_out[n.id + 1] ? |
| 88 | 88 |
node_first_out[n.id] : -1; |
| 89 | 89 |
} |
| 90 | 90 |
void nextOut(Arc& e) const { e.id = arc_next_out[e.id]; }
|
| 91 | 91 |
|
| 92 | 92 |
void firstIn(Arc& e, const Node& n) const { e.id = node_first_in[n.id]; }
|
| 93 | 93 |
void nextIn(Arc& e) const { e.id = arc_next_in[e.id]; }
|
| 94 | 94 |
|
| 95 |
int id(const Node& n) const { return n.id; }
|
|
| 96 |
Node nodeFromId(int id) const { return Node(id); }
|
|
| 95 |
static int id(const Node& n) { return n.id; }
|
|
| 96 |
static Node nodeFromId(int id) { return Node(id); }
|
|
| 97 | 97 |
int maxNodeId() const { return node_num - 1; }
|
| 98 | 98 |
|
| 99 |
int id(const Arc& e) const { return e.id; }
|
|
| 100 |
Arc arcFromId(int id) const { return Arc(id); }
|
|
| 99 |
static int id(const Arc& e) { return e.id; }
|
|
| 100 |
static Arc arcFromId(int id) { return Arc(id); }
|
|
| 101 | 101 |
int maxArcId() const { return arc_num - 1; }
|
| 102 | 102 |
|
| 103 | 103 |
typedef True NodeNumTag; |
| 104 | 104 |
typedef True ArcNumTag; |
| 105 | 105 |
|
| 106 | 106 |
int nodeNum() const { return node_num; }
|
| 107 | 107 |
int arcNum() const { return arc_num; }
|
| 108 | 108 |
|
| 109 | 109 |
private: |
| 110 | 110 |
|
| 111 | 111 |
template <typename Digraph, typename NodeRefMap> |
| 112 | 112 |
class ArcLess {
|
| ... | ... |
@@ -259,43 +259,43 @@ |
| 259 | 259 |
|
| 260 | 260 |
public: |
| 261 | 261 |
|
| 262 | 262 |
/// \brief Constructor |
| 263 | 263 |
/// |
| 264 | 264 |
/// Default constructor. |
| 265 | 265 |
StaticDigraph() : Parent() {}
|
| 266 | 266 |
|
| 267 | 267 |
/// \brief The node with the given index. |
| 268 | 268 |
/// |
| 269 | 269 |
/// This function returns the node with the given index. |
| 270 | 270 |
/// \sa index() |
| 271 |
Node node(int ix) |
|
| 271 |
static Node node(int ix) { return Parent::nodeFromId(ix); }
|
|
| 272 | 272 |
|
| 273 | 273 |
/// \brief The arc with the given index. |
| 274 | 274 |
/// |
| 275 | 275 |
/// This function returns the arc with the given index. |
| 276 | 276 |
/// \sa index() |
| 277 |
Arc arc(int ix) |
|
| 277 |
static Arc arc(int ix) { return Parent::arcFromId(ix); }
|
|
| 278 | 278 |
|
| 279 | 279 |
/// \brief The index of the given node. |
| 280 | 280 |
/// |
| 281 | 281 |
/// This function returns the index of the the given node. |
| 282 | 282 |
/// \sa node() |
| 283 |
int index(Node node) |
|
| 283 |
static int index(Node node) { return Parent::id(node); }
|
|
| 284 | 284 |
|
| 285 | 285 |
/// \brief The index of the given arc. |
| 286 | 286 |
/// |
| 287 | 287 |
/// This function returns the index of the the given arc. |
| 288 | 288 |
/// \sa arc() |
| 289 |
int index(Arc arc) |
|
| 289 |
static int index(Arc arc) { return Parent::id(arc); }
|
|
| 290 | 290 |
|
| 291 | 291 |
/// \brief Number of nodes. |
| 292 | 292 |
/// |
| 293 | 293 |
/// This function returns the number of nodes. |
| 294 | 294 |
int nodeNum() const { return node_num; }
|
| 295 | 295 |
|
| 296 | 296 |
/// \brief Number of arcs. |
| 297 | 297 |
/// |
| 298 | 298 |
/// This function returns the number of arcs. |
| 299 | 299 |
int arcNum() const { return arc_num; }
|
| 300 | 300 |
|
| 301 | 301 |
/// \brief Build the digraph copying another digraph. |
0 comments (0 inline)