andres::graph
complete-graph.hxx
1 #pragma once
2 #ifndef ANDRES_GRAPH_COMPLETE_GRAPH_HXX
3 #define ANDRES_GRAPH_COMPLETE_GRAPH_HXX
4 
5 #include <cassert>
6 #include <cstddef>
7 #include <cmath>
8 #include <iterator>
9 
10 #include "adjacency.hxx"
11 #include "visitor.hxx"
12 
13 namespace andres {
14 namespace graph {
15 
17 template<typename VISITOR = IdleGraphVisitor<std::size_t> >
19 public:
20  typedef VISITOR Visitor;
22 
23  // \cond SUPPRESS_DOXYGEN
24  class AdjacencyIterator
25  : public std::iterator <
26  std::random_access_iterator_tag,
27  const AdjacencyType
28  > {
29  public:
30  typedef CompleteGraph<Visitor> GraphType;
31  typedef std::iterator <
32  std::random_access_iterator_tag,
33  const AdjacencyType
34  > Base;
35  typedef typename Base::iterator_category iterator_category;
36  typedef typename Base::value_type value_type;
37  typedef typename Base::difference_type difference_type;
38  typedef typename Base::pointer pointer;
39  typedef typename Base::reference reference;
40 
41  AdjacencyIterator();
42  AdjacencyIterator(const GraphType&);
43  AdjacencyIterator(const GraphType&, const std::size_t);
44  AdjacencyIterator(const GraphType&, const std::size_t, const std::size_t);
45 
46  // increment and decrement
47  AdjacencyIterator& operator+=(const difference_type);
48  AdjacencyIterator& operator-=(const difference_type);
49  AdjacencyIterator& operator++(); // prefix
50  AdjacencyIterator& operator--(); // prefix
51  AdjacencyIterator operator++(int); // postfix
52  AdjacencyIterator operator--(int); // postfix
53  AdjacencyIterator operator+(const difference_type) const;
54  AdjacencyIterator operator-(const difference_type) const;
55  difference_type operator-(const AdjacencyIterator&) const;
56 
57  // comparison
58  bool operator==(const AdjacencyIterator&) const;
59  bool operator!=(const AdjacencyIterator&) const;
60  bool operator<(const AdjacencyIterator&) const;
61  bool operator<=(const AdjacencyIterator&) const;
62  bool operator>(const AdjacencyIterator&) const;
63  bool operator>=(const AdjacencyIterator&) const;
64 
65  // access
66  reference operator*();
67  pointer operator->();
68  reference operator[](const std::size_t);
69 
70  protected:
71  const GraphType* graph_;
72  std::size_t vertex_;
73  std::size_t adjacencyIndex_;
74  AdjacencyType adjacency_;
75  };
76 
77  class VertexIterator
78  : public AdjacencyIterator {
79  public:
80  typedef CompleteGraph<Visitor> GraphType;
81  typedef AdjacencyIterator Base;
82  typedef typename Base::iterator_category iterator_category;
83  typedef typename Base::difference_type difference_type;
84  typedef const std::size_t value_type;
85  typedef value_type* pointer;
86  typedef value_type& reference;
87 
88  VertexIterator();
89  VertexIterator(const VertexIterator&);
90  VertexIterator(const AdjacencyIterator&);
91  VertexIterator(const GraphType&);
92  VertexIterator(const GraphType&, const std::size_t);
93  VertexIterator(const GraphType&, const std::size_t, const std::size_t);
94 
95  // access
96  value_type operator*() const;
97  value_type operator[](const std::size_t) const;
98  private:
99  pointer operator->() const;
100  };
101 
102  class EdgeIterator
103  : public AdjacencyIterator {
104  public:
105  typedef CompleteGraph<Visitor> GraphType;
106  typedef AdjacencyIterator Base;
107  typedef typename Base::iterator_category iterator_category;
108  typedef typename Base::difference_type difference_type;
109  typedef const std::size_t value_type;
110  typedef value_type* pointer;
111  typedef value_type& reference;
112 
113  EdgeIterator();
114  EdgeIterator(const EdgeIterator&);
115  EdgeIterator(const AdjacencyIterator&);
116  EdgeIterator(const GraphType&);
117  EdgeIterator(const GraphType&, const std::size_t);
118  EdgeIterator(const GraphType&, const std::size_t, const std::size_t);
119 
120  // access
121  value_type operator*() const;
122  value_type operator[](const std::size_t) const;
123  private:
124  pointer operator->() const;
125  };
126  // \endcond
127 
128  // construction
129  CompleteGraph(const Visitor& = Visitor());
130  CompleteGraph(const std::size_t, const Visitor& = Visitor());
131  void assign(const Visitor& = Visitor());
132  void assign(const std::size_t, const Visitor& = Visitor());
133 
134  // iterator access (compatible with Digraph)
135  VertexIterator verticesFromVertexBegin(const std::size_t) const;
136  VertexIterator verticesFromVertexEnd(const std::size_t) const;
137  VertexIterator verticesToVertexBegin(const std::size_t) const;
138  VertexIterator verticesToVertexEnd(const std::size_t) const;
139  EdgeIterator edgesFromVertexBegin(const std::size_t) const;
140  EdgeIterator edgesFromVertexEnd(const std::size_t) const;
141  EdgeIterator edgesToVertexBegin(const std::size_t) const;
142  EdgeIterator edgesToVertexEnd(const std::size_t) const;
143  AdjacencyIterator adjacenciesFromVertexBegin(const std::size_t) const;
144  AdjacencyIterator adjacenciesFromVertexEnd(const std::size_t) const;
145  AdjacencyIterator adjacenciesToVertexBegin(const std::size_t) const;
146  AdjacencyIterator adjacenciesToVertexEnd(const std::size_t) const;
147 
148  // access (compatible with Digraph)
149  std::size_t numberOfVertices() const;
150  std::size_t numberOfEdges() const;
151  std::size_t numberOfEdgesFromVertex(const std::size_t) const;
152  std::size_t numberOfEdgesToVertex(const std::size_t) const;
153  std::size_t vertexOfEdge(const std::size_t, const std::size_t) const;
154  std::size_t edgeFromVertex(const std::size_t, const std::size_t) const;
155  std::size_t edgeToVertex(const std::size_t, const std::size_t) const;
156  std::size_t vertexFromVertex(const std::size_t, const std::size_t) const;
157  std::size_t vertexToVertex(const std::size_t, const std::size_t) const;
158  AdjacencyType adjacencyFromVertex(const std::size_t, const std::size_t) const;
159  AdjacencyType adjacencyToVertex(const std::size_t, const std::size_t) const;
160  std::pair<bool, std::size_t> findEdge(const std::size_t, const std::size_t) const;
161  bool multipleEdgesEnabled() const;
162 
163 private:
164  std::size_t edgeOfStrictlyIncreasingPairOfVertices(const std::size_t, const std::size_t) const;
165 
166  std::size_t numberOfVertices_;
167  Visitor visitor_;
168 };
169 
174 template<typename VISITOR>
175 inline
177  const Visitor& visitor
178 )
179 : numberOfVertices_(0),
180  visitor_(visitor)
181 {}
182 
188 template<typename VISITOR>
189 inline
191  const std::size_t numberOfVertices,
192  const Visitor& visitor
193 )
194 : numberOfVertices_(numberOfVertices),
195  visitor_(visitor)
196 {}
197 
202 template<typename VISITOR>
203 inline void
205  const Visitor& visitor
206 ) {
207  numberOfVertices_ = 0;
208  visitor_ = visitor;
209 }
210 
216 template<typename VISITOR>
217 inline void
219  const std::size_t numberOfVertices,
220  const Visitor& visitor
221 ) {
222  numberOfVertices_ = numberOfVertices;
223  visitor_ = visitor;
224 }
225 
233 template<typename VISITOR>
236  const std::size_t vertex
237 ) const {
238  return VertexIterator(*this, vertex, 0);
239 }
240 
248 template<typename VISITOR>
251  const std::size_t vertex
252 ) const {
253  return VertexIterator(*this, vertex, numberOfEdgesFromVertex(vertex));
254 }
255 
263 template<typename VISITOR>
266  const std::size_t vertex
267 ) const {
268  return VertexIterator(*this, vertex, 0);
269 }
270 
278 template<typename VISITOR>
281  const std::size_t vertex
282 ) const {
283  return VertexIterator(*this, vertex, numberOfEdgesFromVertex(vertex));
284 }
285 
293 template<typename VISITOR>
296  const std::size_t vertex
297 ) const {
298  return EdgeIterator(*this, vertex, 0);
299 }
300 
308 template<typename VISITOR>
311  const std::size_t vertex
312 ) const {
313  return EdgeIterator(*this, vertex, numberOfEdgesFromVertex(vertex));
314 }
315 
323 template<typename VISITOR>
326  const std::size_t vertex
327 ) const {
328  return EdgeIterator(*this, vertex, 0);
329 }
330 
338 template<typename VISITOR>
341  const std::size_t vertex
342 ) const {
343  return EdgeIterator(*this, vertex, numberOfEdgesFromVertex(vertex));
344 }
345 
353 template<typename VISITOR>
356  const std::size_t vertex
357 ) const {
358  return AdjacencyIterator(*this, vertex, 0);
359 }
360 
368 template<typename VISITOR>
371  const std::size_t vertex
372 ) const {
373  return AdjacencyIterator(*this, vertex, numberOfEdgesFromVertex(vertex));
374 }
375 
383 template<typename VISITOR>
386  const std::size_t vertex
387 ) const {
388  return AdjacencyIterator(*this, vertex, 0);
389 }
390 
398 template<typename VISITOR>
401  const std::size_t vertex
402 ) const {
403  return AdjacencyIterator(*this, vertex, numberOfEdgesFromVertex(vertex));
404 }
405 
408 template<typename VISITOR>
409 inline std::size_t
411  return numberOfVertices_;
412 }
413 
416 template<typename VISITOR>
417 inline std::size_t
419  return numberOfVertices() * (numberOfVertices() - 1) / 2;
420 }
421 
428 template<typename VISITOR>
429 inline std::size_t
431  const std::size_t vertex
432 ) const {
433  assert(vertex < numberOfVertices());
434  return numberOfVertices() - 1;
435 }
436 
443 template<typename VISITOR>
444 inline std::size_t
446  const std::size_t vertex
447 ) const {
448  assert(vertex < numberOfVertices());
449  return numberOfVertices() - 1;
450 }
451 
457 template<typename VISITOR>
458 inline std::size_t
460  const std::size_t edge,
461  const std::size_t j
462 ) const {
463  assert(edge < numberOfEdges());
464  assert(j < 2);
465  double p = static_cast<double>(numberOfVertices() * 2 - 1) / 2;
466  double q = static_cast<double>(edge) * 2;
467  std::size_t vertex0 = static_cast<std::size_t>(p - std::sqrt(p * p - q));
468  if(j == 0) {
469  return vertex0;
470  }
471  else {
472  return edge + vertex0 * (vertex0 + 1) / 2 - (numberOfVertices() - 1) * vertex0 + 1;
473  }
474 }
475 
483 template<typename VISITOR>
484 inline std::size_t
486  const std::size_t vertex,
487  const std::size_t j
488 ) const {
489  assert(j < numberOfEdgesFromVertex(vertex));
490  if(j < vertex) {
491  const std::size_t vertexAdjacent = j;
492  const std::size_t edgeAdjacent = edgeOfStrictlyIncreasingPairOfVertices(vertexAdjacent, vertex);
493  return edgeAdjacent;
494  }
495  else {
496  const std::size_t vertexAdjacent = j + 1;
497  const std::size_t edgeAdjacent = edgeOfStrictlyIncreasingPairOfVertices(vertex, vertexAdjacent);
498  return edgeAdjacent;
499  }
500 }
501 
509 template<typename VISITOR>
510 inline std::size_t
512  const std::size_t vertex,
513  const std::size_t j
514 ) const {
515  assert(j < numberOfEdgesToVertex(vertex));
516  return edgeFromVertex(vertex, j);
517 }
518 
526 template<typename VISITOR>
527 inline std::size_t
529  const std::size_t vertex,
530  const std::size_t j
531 ) const {
532  assert(j < numberOfEdgesFromVertex(vertex));
533  if(j < vertex) {
534  return j;
535  }
536  else {
537  return j + 1;
538  }
539 }
540 
548 template<typename VISITOR>
549 inline std::size_t
551  const std::size_t vertex,
552  const std::size_t j
553 ) const {
554  assert(j < numberOfEdgesToVertex(vertex));
555  return vertexFromVertex(vertex, j);
556 }
557 
563 template<typename VISITOR>
566  const std::size_t vertex,
567  const std::size_t j
568 ) const {
569  assert(j < numberOfEdgesToVertex(vertex));
570  if(j < vertex) {
571  const std::size_t vertexAdjacent = j;
572  const std::size_t edgeAdjacent = edgeOfStrictlyIncreasingPairOfVertices(vertexAdjacent, vertex);
573  return AdjacencyType(vertexAdjacent, edgeAdjacent);
574  }
575  else {
576  const std::size_t vertexAdjacent = j + 1;
577  const std::size_t edgeAdjacent = edgeOfStrictlyIncreasingPairOfVertices(vertex, vertexAdjacent);
578  return AdjacencyType(vertexAdjacent, edgeAdjacent);
579  }
580 }
581 
587 template<typename VISITOR>
590  const std::size_t vertex,
591  const std::size_t j
592 ) const {
593  return adjacencyFromVertex(vertex, j);
594 }
595 
610 template<typename VISITOR>
611 inline std::pair<bool, std::size_t>
613  const std::size_t vertex0,
614  const std::size_t vertex1
615 ) const {
616  assert(vertex0 < numberOfVertices());
617  assert(vertex1 < numberOfVertices());
618  if(vertex0 == vertex1) {
619  return std::pair<bool, std::size_t>(false, 0);
620  }
621  else if(vertex0 < vertex1) {
622  return std::pair<bool, std::size_t>(true, edgeOfStrictlyIncreasingPairOfVertices(vertex0, vertex1));
623  }
624  else {
625  return std::pair<bool, std::size_t>(true, edgeOfStrictlyIncreasingPairOfVertices(vertex1, vertex0));
626  }
627 }
628 
633 template<typename VISITOR>
634 inline bool
636  return false;
637 }
638 
639 // private
640 template<typename VISITOR>
641 inline std::size_t
643  const std::size_t vertex0,
644  const std::size_t vertex1
645 ) const {
646  assert(vertex1 < numberOfVertices());
647  assert(vertex0 < vertex1);
648  return (numberOfVertices() - 1) * vertex0 - vertex0 * (vertex0 + 1) / 2 + vertex1 - 1;
649 }
650 
651 // \cond SUPPRESS_DOXYGEN
652 
653 // implementation of AdjacencyIterator
654 
655 template<typename VISITOR>
656 inline
657 CompleteGraph<VISITOR>::AdjacencyIterator::AdjacencyIterator()
658 : graph_(0),
659  vertex_(0),
660  adjacencyIndex_(0),
661  adjacency_()
662 {}
663 
664 template<typename VISITOR>
665 inline
666 CompleteGraph<VISITOR>::AdjacencyIterator::AdjacencyIterator(
667  const GraphType& graph
668 )
669 : graph_(&graph),
670  vertex_(0),
671  adjacencyIndex_(0),
672  adjacency_()
673 {}
674 
675 template<typename VISITOR>
676 inline
677 CompleteGraph<VISITOR>::AdjacencyIterator::AdjacencyIterator(
678  const GraphType& graph,
679  const std::size_t vertex
680 )
681 : graph_(&graph),
682  vertex_(vertex),
683  adjacencyIndex_(0),
684  adjacency_()
685 {
686  assert(vertex < graph.numberOfVertices());
687 }
688 
689 template<typename VISITOR>
690 inline
691 CompleteGraph<VISITOR>::AdjacencyIterator::AdjacencyIterator(
692  const GraphType& graph,
693  const std::size_t vertex,
694  const std::size_t adjacencyIndex
695 )
696 : graph_(&graph),
697  vertex_(vertex),
698  adjacencyIndex_(adjacencyIndex),
699  adjacency_()
700 {
701  assert(vertex < graph.numberOfVertices());
702  assert(adjacencyIndex <= graph.numberOfVertices());
703 }
704 
705 template<typename VISITOR>
706 inline typename CompleteGraph<VISITOR>::AdjacencyIterator&
707 CompleteGraph<VISITOR>::AdjacencyIterator::operator+=(
708  const difference_type d
709 ) {
710  adjacencyIndex_ += d;
711  return *this;
712 }
713 
714 template<typename VISITOR>
715 inline typename CompleteGraph<VISITOR>::AdjacencyIterator&
716 CompleteGraph<VISITOR>::AdjacencyIterator::operator-=(
717  const difference_type d
718 ) {
719  adjacencyIndex_ -= d;
720  return *this;
721 }
722 
723 template<typename VISITOR>
724 inline typename CompleteGraph<VISITOR>::AdjacencyIterator&
725 CompleteGraph<VISITOR>::AdjacencyIterator::operator++() {
726  ++adjacencyIndex_;
727  return *this;
728 }
729 
730 template<typename VISITOR>
731 inline typename CompleteGraph<VISITOR>::AdjacencyIterator&
732 CompleteGraph<VISITOR>::AdjacencyIterator::operator--() {
733  --adjacencyIndex_;
734  return *this;
735 }
736 
737 template<typename VISITOR>
738 inline typename CompleteGraph<VISITOR>::AdjacencyIterator
739 CompleteGraph<VISITOR>::AdjacencyIterator::operator++(int) {
740  AdjacencyIterator copy = *this;
741  ++adjacencyIndex_;
742  return copy;
743 }
744 
745 template<typename VISITOR>
746 inline typename CompleteGraph<VISITOR>::AdjacencyIterator
747 CompleteGraph<VISITOR>::AdjacencyIterator::operator--(int) {
748  AdjacencyIterator copy = *this;
749  --adjacencyIndex_;
750  return copy;
751 }
752 
753 template<typename VISITOR>
754 inline typename CompleteGraph<VISITOR>::AdjacencyIterator
755 CompleteGraph<VISITOR>::AdjacencyIterator::operator+(
756  const difference_type d
757 ) const {
758  AdjacencyIterator copy = *this;
759  copy += d;
760  return copy;
761 }
762 
763 template<typename VISITOR>
764 inline typename CompleteGraph<VISITOR>::AdjacencyIterator
765 CompleteGraph<VISITOR>::AdjacencyIterator::operator-(
766  const difference_type d
767 ) const {
768  AdjacencyIterator copy = *this;
769  copy -= d;
770  return copy;
771 }
772 
773 template<typename VISITOR>
774 inline typename CompleteGraph<VISITOR>::AdjacencyIterator::difference_type
775 CompleteGraph<VISITOR>::AdjacencyIterator::operator-(
776  const AdjacencyIterator& adjacencyIterator
777 ) const {
778  return adjacencyIndex_ - adjacencyIterator.adjacencyIndex_;
779 }
780 
781 template<typename VISITOR>
782 inline bool
783 CompleteGraph<VISITOR>::AdjacencyIterator::operator==(
784  const AdjacencyIterator& other
785 ) const {
786  return adjacencyIndex_ == other.adjacencyIndex_
787  && vertex_ == other.vertex_
788  && graph_ == other.graph_;
789 }
790 
791 template<typename VISITOR>
792 inline bool
793 CompleteGraph<VISITOR>::AdjacencyIterator::operator!=(
794  const AdjacencyIterator& other
795 ) const {
796  return adjacencyIndex_ != other.adjacencyIndex_
797  || vertex_ != other.vertex_
798  || graph_ != other.graph_;
799 }
800 
801 template<typename VISITOR>
802 inline bool
803 CompleteGraph<VISITOR>::AdjacencyIterator::operator<(
804  const AdjacencyIterator& other
805 ) const {
806  return adjacencyIndex_ < other.adjacencyIndex_
807  && vertex_ == other.vertex_
808  && graph_ == other.graph_;
809 }
810 
811 template<typename VISITOR>
812 inline bool
813 CompleteGraph<VISITOR>::AdjacencyIterator::operator<=(
814  const AdjacencyIterator& other
815 ) const {
816  return adjacencyIndex_ <= other.adjacencyIndex_
817  && vertex_ == other.vertex_
818  && graph_ == other.graph_;
819 }
820 
821 
822 template<typename VISITOR>
823 inline bool
824 CompleteGraph<VISITOR>::AdjacencyIterator::operator>(
825  const AdjacencyIterator& other
826 ) const {
827  return adjacencyIndex_ > other.adjacencyIndex_
828  && vertex_ == other.vertex_
829  && graph_ == other.graph_;
830 }
831 
832 template<typename VISITOR>
833 inline bool
834 CompleteGraph<VISITOR>::AdjacencyIterator::operator>=(
835  const AdjacencyIterator& other
836 ) const {
837  return adjacencyIndex_ >= other.adjacencyIndex_
838  && vertex_ == other.vertex_
839  && graph_ == other.graph_;
840 }
841 
842 template<typename VISITOR>
843 inline typename CompleteGraph<VISITOR>::AdjacencyIterator::reference
844 CompleteGraph<VISITOR>::AdjacencyIterator::operator*() {
845  adjacency_ = graph_->adjacencyFromVertex(vertex_, adjacencyIndex_);
846  return adjacency_;
847 }
848 
849 template<typename VISITOR>
850 inline typename CompleteGraph<VISITOR>::AdjacencyIterator::pointer
851 CompleteGraph<VISITOR>::AdjacencyIterator::operator->() {
852  adjacency_ = graph_->adjacencyFromVertex(vertex_, adjacencyIndex_);
853  return &adjacency_;
854 }
855 
856 template<typename VISITOR>
857 inline typename CompleteGraph<VISITOR>::AdjacencyIterator::reference
858 CompleteGraph<VISITOR>::AdjacencyIterator::operator[](
859  const std::size_t j
860 ) {
861  adjacency_ = graph_->adjacencyFromVertex(vertex_, adjacencyIndex_ + j);
862  return adjacency_;
863 }
864 
865 // implementation of VertexIterator
866 
867 template<typename VISITOR>
868 inline
869 CompleteGraph<VISITOR>::VertexIterator::VertexIterator()
870 : Base()
871 {}
872 
873 template<typename VISITOR>
874 inline
875 CompleteGraph<VISITOR>::VertexIterator::VertexIterator(
876  const GraphType& graph
877 )
878 : Base(graph)
879 {}
880 
881 template<typename VISITOR>
882 inline
883 CompleteGraph<VISITOR>::VertexIterator::VertexIterator(
884  const GraphType& graph,
885  const std::size_t vertex
886 )
887 : Base(graph, vertex)
888 {}
889 
890 template<typename VISITOR>
891 inline
892 CompleteGraph<VISITOR>::VertexIterator::VertexIterator(
893  const GraphType& graph,
894  const std::size_t vertex,
895  const std::size_t adjacencyIndex
896 )
897 : Base(graph, vertex, adjacencyIndex)
898 {}
899 
900 template<typename VISITOR>
901 inline
902 CompleteGraph<VISITOR>::VertexIterator::VertexIterator(
903  const VertexIterator& it
904 )
905 : Base(*(it.graph_), it.vertex_, it.adjacencyIndex_)
906 {}
907 
908 template<typename VISITOR>
909 inline
910 CompleteGraph<VISITOR>::VertexIterator::VertexIterator(
911  const AdjacencyIterator& it
912 )
913 : Base(it)
914 {}
915 
916 template<typename VISITOR>
917 inline typename CompleteGraph<VISITOR>::VertexIterator::value_type
918 CompleteGraph<VISITOR>::VertexIterator::operator*() const {
919  return Base::graph_->vertexFromVertex(Base::vertex_, Base::adjacencyIndex_);
920 }
921 
922 template<typename VISITOR>
923 inline typename CompleteGraph<VISITOR>::VertexIterator::value_type
924 CompleteGraph<VISITOR>::VertexIterator::operator[](
925  const std::size_t j
926 ) const {
927  return Base::graph_->vertexFromVertex(Base::vertex_, Base::adjacencyIndex_ + j);
928 }
929 
930 // implementation of EdgeIterator
931 
932 template<typename VISITOR>
933 inline
934 CompleteGraph<VISITOR>::EdgeIterator::EdgeIterator()
935 : Base()
936 {}
937 
938 template<typename VISITOR>
939 inline
940 CompleteGraph<VISITOR>::EdgeIterator::EdgeIterator(
941  const GraphType& graph
942 )
943 : Base(graph)
944 {}
945 
946 template<typename VISITOR>
947 inline
948 CompleteGraph<VISITOR>::EdgeIterator::EdgeIterator(
949  const GraphType& graph,
950  const std::size_t vertex
951 )
952 : Base(graph, vertex)
953 {}
954 
955 template<typename VISITOR>
956 inline
957 CompleteGraph<VISITOR>::EdgeIterator::EdgeIterator(
958  const GraphType& graph,
959  const std::size_t vertex,
960  const std::size_t adjacencyIndex
961 )
962 : Base(graph, vertex, adjacencyIndex)
963 {}
964 
965 template<typename VISITOR>
966 inline
967 CompleteGraph<VISITOR>::EdgeIterator::EdgeIterator(
968  const EdgeIterator& it
969 )
970 : Base(*(it.graph_), it.vertex_, it.adjacencyIndex_)
971 {}
972 
973 template<typename VISITOR>
974 inline
975 CompleteGraph<VISITOR>::EdgeIterator::EdgeIterator(
976  const AdjacencyIterator& it
977 )
978 : Base(it)
979 {}
980 
981 template<typename VISITOR>
982 inline typename CompleteGraph<VISITOR>::EdgeIterator::value_type
983 CompleteGraph<VISITOR>::EdgeIterator::operator*() const {
984  return Base::graph_->edgeFromVertex(Base::vertex_, Base::adjacencyIndex_);
985 }
986 
987 template<typename VISITOR>
988 inline typename CompleteGraph<VISITOR>::EdgeIterator::value_type
989 CompleteGraph<VISITOR>::EdgeIterator::operator[](
990  const std::size_t j
991 ) const {
992  return Base::graph_->edgeFromVertex(Base::vertex_, Base::adjacencyIndex_ + j);
993 }
994 
995 // \endcond
996 
997 } // namespace graph
998 } // namespace andres
999 
1000 #endif // #ifndef ANDRES_GRAPH_COMPLETE_GRAPH_HXX