0
2
0
... | ... |
@@ -821,49 +821,51 @@ |
821 | 821 |
|
822 | 822 |
class Edge { |
823 | 823 |
friend class ListGraphBase; |
824 | 824 |
protected: |
825 | 825 |
|
826 | 826 |
int id; |
827 | 827 |
explicit Edge(int pid) { id = pid;} |
828 | 828 |
|
829 | 829 |
public: |
830 | 830 |
Edge() {} |
831 | 831 |
Edge (Invalid) { id = -1; } |
832 | 832 |
bool operator==(const Edge& edge) const {return id == edge.id;} |
833 | 833 |
bool operator!=(const Edge& edge) const {return id != edge.id;} |
834 | 834 |
bool operator<(const Edge& edge) const {return id < edge.id;} |
835 | 835 |
}; |
836 | 836 |
|
837 | 837 |
class Arc { |
838 | 838 |
friend class ListGraphBase; |
839 | 839 |
protected: |
840 | 840 |
|
841 | 841 |
int id; |
842 | 842 |
explicit Arc(int pid) { id = pid;} |
843 | 843 |
|
844 | 844 |
public: |
845 |
operator Edge() const { |
|
845 |
operator Edge() const { |
|
846 |
return id != -1 ? edgeFromId(id / 2) : INVALID; |
|
847 |
} |
|
846 | 848 |
|
847 | 849 |
Arc() {} |
848 | 850 |
Arc (Invalid) { id = -1; } |
849 | 851 |
bool operator==(const Arc& arc) const {return id == arc.id;} |
850 | 852 |
bool operator!=(const Arc& arc) const {return id != arc.id;} |
851 | 853 |
bool operator<(const Arc& arc) const {return id < arc.id;} |
852 | 854 |
}; |
853 | 855 |
|
854 | 856 |
|
855 | 857 |
|
856 | 858 |
ListGraphBase() |
857 | 859 |
: nodes(), first_node(-1), |
858 | 860 |
first_free_node(-1), arcs(), first_free_arc(-1) {} |
859 | 861 |
|
860 | 862 |
|
861 | 863 |
int maxNodeId() const { return nodes.size()-1; } |
862 | 864 |
int maxEdgeId() const { return arcs.size() / 2 - 1; } |
863 | 865 |
int maxArcId() const { return arcs.size()-1; } |
864 | 866 |
|
865 | 867 |
Node source(Arc e) const { return Node(arcs[e.id ^ 1].target); } |
866 | 868 |
Node target(Arc e) const { return Node(arcs[e.id].target); } |
867 | 869 |
|
868 | 870 |
Node u(Edge e) const { return Node(arcs[2 * e.id].target); } |
869 | 871 |
Node v(Edge e) const { return Node(arcs[2 * e.id + 1].target); } |
... | ... |
@@ -444,49 +444,51 @@ |
444 | 444 |
|
445 | 445 |
class Edge { |
446 | 446 |
friend class SmartGraphBase; |
447 | 447 |
protected: |
448 | 448 |
|
449 | 449 |
int _id; |
450 | 450 |
explicit Edge(int id) { _id = id;} |
451 | 451 |
|
452 | 452 |
public: |
453 | 453 |
Edge() {} |
454 | 454 |
Edge (Invalid) { _id = -1; } |
455 | 455 |
bool operator==(const Edge& arc) const {return _id == arc._id;} |
456 | 456 |
bool operator!=(const Edge& arc) const {return _id != arc._id;} |
457 | 457 |
bool operator<(const Edge& arc) const {return _id < arc._id;} |
458 | 458 |
}; |
459 | 459 |
|
460 | 460 |
class Arc { |
461 | 461 |
friend class SmartGraphBase; |
462 | 462 |
protected: |
463 | 463 |
|
464 | 464 |
int _id; |
465 | 465 |
explicit Arc(int id) { _id = id;} |
466 | 466 |
|
467 | 467 |
public: |
468 |
operator Edge() const { |
|
468 |
operator Edge() const { |
|
469 |
return _id != -1 ? edgeFromId(_id / 2) : INVALID; |
|
470 |
} |
|
469 | 471 |
|
470 | 472 |
Arc() {} |
471 | 473 |
Arc (Invalid) { _id = -1; } |
472 | 474 |
bool operator==(const Arc& arc) const {return _id == arc._id;} |
473 | 475 |
bool operator!=(const Arc& arc) const {return _id != arc._id;} |
474 | 476 |
bool operator<(const Arc& arc) const {return _id < arc._id;} |
475 | 477 |
}; |
476 | 478 |
|
477 | 479 |
|
478 | 480 |
|
479 | 481 |
SmartGraphBase() |
480 | 482 |
: nodes(), arcs() {} |
481 | 483 |
|
482 | 484 |
|
483 | 485 |
int maxNodeId() const { return nodes.size()-1; } |
484 | 486 |
int maxEdgeId() const { return arcs.size() / 2 - 1; } |
485 | 487 |
int maxArcId() const { return arcs.size()-1; } |
486 | 488 |
|
487 | 489 |
Node source(Arc e) const { return Node(arcs[e._id ^ 1].target); } |
488 | 490 |
Node target(Arc e) const { return Node(arcs[e._id].target); } |
489 | 491 |
|
490 | 492 |
Node u(Edge e) const { return Node(arcs[2 * e._id].target); } |
491 | 493 |
Node v(Edge e) const { return Node(arcs[2 * e._id + 1].target); } |
492 | 494 |
|
0 comments (0 inline)