@@ -41,7 +41,7 @@ Graph<T>::Graph() {
4141
4242template <typename T>
4343Graph<T>::Graph(const T_EdgeSet<T> &edgeSet) {
44- for (auto edgeIt : edgeSet) {
44+ for (const auto & edgeIt : edgeSet) {
4545 this ->edgeSet .insert (edgeIt);
4646 }
4747 /* Caching the adjacency matrix */
@@ -62,7 +62,7 @@ T_EdgeVector<T> Graph<T>::getEdgeVector() const {
6262template <typename T>
6363void Graph<T>::setEdgeSet(const T_EdgeSet<T> &edgeSet) {
6464 this ->edgeSet .clear ();
65- for (auto edgeIt : edgeSet) {
65+ for (const auto & edgeIt : edgeSet) {
6666 this ->edgeSet .insert (edgeIt);
6767 }
6868 /* Caching the adjacency matrix */
@@ -169,7 +169,7 @@ void Graph<T>::removeEdge(const CXXGraph::id_t edgeId) {
169169 int delIndex = -1 ;
170170 int i = 0 ;
171171 /* Removing the edge from the cached adjacency lists */
172- for (auto elem : (*cachedAdjListOut)[from]) {
172+ for (const auto & elem : (*cachedAdjListOut)[from]) {
173173 if (elem.second .get ()->getId () == edgeId) {
174174 delIndex = i;
175175 break ;
@@ -186,7 +186,7 @@ void Graph<T>::removeEdge(const CXXGraph::id_t edgeId) {
186186
187187 delIndex = -1 ;
188188 i = 0 ;
189- for (auto elem : (*cachedAdjListIn)[to]) {
189+ for (const auto & elem : (*cachedAdjListIn)[to]) {
190190 if (elem.second .get ()->getId () == edgeId) {
191191 delIndex = i;
192192 break ;
@@ -205,7 +205,7 @@ void Graph<T>::removeEdge(const CXXGraph::id_t edgeId) {
205205 if (!edgeOpt.value ().get ()->isDirected ().value_or (false )) {
206206 delIndex = -1 ;
207207 i = 0 ;
208- for (auto elem : (*cachedAdjListOut)[to]) {
208+ for (const auto & elem : (*cachedAdjListOut)[to]) {
209209 if (elem.second .get ()->getId () == edgeId) {
210210 delIndex = i;
211211 break ;
@@ -222,7 +222,7 @@ void Graph<T>::removeEdge(const CXXGraph::id_t edgeId) {
222222
223223 delIndex = -1 ;
224224 i = 0 ;
225- for (auto elem : (*cachedAdjListIn)[from]) {
225+ for (const auto & elem : (*cachedAdjListIn)[from]) {
226226 if (elem.second .get ()->getId () == edgeId) {
227227 delIndex = i;
228228 break ;
@@ -282,7 +282,7 @@ bool Graph<T>::findEdge(shared<const Node<T>> v1, shared<const Node<T>> v2,
282282 if (cachedAdjListOut.get () != NULL && cachedAdjListOut->size () != 0 ) {
283283 /* Searching for the edge using cached adjacency list out */
284284
285- for (auto elem : (*cachedAdjListOut)[v1]) {
285+ for (const auto & elem : (*cachedAdjListOut)[v1]) {
286286 if (elem.first == v2) {
287287 id = elem.second .get ()->getId ();
288288 return true ;
@@ -291,7 +291,7 @@ bool Graph<T>::findEdge(shared<const Node<T>> v1, shared<const Node<T>> v2,
291291 } else {
292292 /* Searching for the edge using edgeset */
293293
294- for (auto e : this ->edgeSet ) {
294+ for (const auto & e : this ->edgeSet ) {
295295 if ((e->getNodePair ().first == v1) && (e->getNodePair ().second == v2)) {
296296 id = e->getId ();
297297 return true ;
@@ -661,7 +661,7 @@ Graph<T>::outNotInNeighbors(shared<const Node<T>> node) const {
661661 auto nodeEdgePairsOut = cachedAdjListOut->at (node);
662662
663663 std::unordered_set<shared<const Node<T>>, nodeHash<T>> outNotInNeighbors;
664- for (auto pair : nodeEdgePairsOut) {
664+ for (const auto & pair : nodeEdgePairsOut) {
665665 if (pair.second ->isDirected ().value_or (false )) {
666666 outNotInNeighbors.insert (pair.first );
667667 }
@@ -687,7 +687,7 @@ Graph<T>::inNotOutNeighbors(shared<const Node<T>> node) const {
687687 auto nodeEdgePairsIn = cachedAdjListIn->at (node);
688688
689689 std::unordered_set<shared<const Node<T>>, nodeHash<T>> inNotOutNeighbors;
690- for (auto pair : nodeEdgePairsIn) {
690+ for (const auto & pair : nodeEdgePairsIn) {
691691 if (pair.second ->isDirected ().value_or (false )) {
692692 inNotOutNeighbors.insert (pair.first );
693693 }
@@ -715,13 +715,13 @@ Graph<T>::inOrOutNeighbors(shared<const Node<T>> node) const {
715715 std::unordered_set<shared<const Node<T>>, nodeHash<T>> inOrOutNeighbors;
716716 if (cachedAdjListOut->find (node) != cachedAdjListOut->end ()) {
717717 auto nodeEdgePairsOut = cachedAdjListOut->at (node);
718- for (auto pair : nodeEdgePairsOut) {
718+ for (const auto & pair : nodeEdgePairsOut) {
719719 inOrOutNeighbors.insert (pair.first );
720720 }
721721 }
722722 if (cachedAdjListIn->find (node) != cachedAdjListIn->end ()) {
723723 auto nodeEdgePairsIn = cachedAdjListIn->at (node);
724- for (auto pair : nodeEdgePairsIn) {
724+ for (const auto & pair : nodeEdgePairsIn) {
725725 inOrOutNeighbors.insert (pair.first );
726726 }
727727 }
@@ -746,7 +746,7 @@ Graph<T>::outNotInEdges(shared<const Node<T>> node) const {
746746 auto nodeEdgePairsOut = cachedAdjListOut->at (node);
747747
748748 std::unordered_set<shared<const Edge<T>>, edgeHash<T>> outNotInEdges;
749- for (auto pair : nodeEdgePairsOut) {
749+ for (const auto & pair : nodeEdgePairsOut) {
750750 if (pair.second ->isDirected ().value_or (false )) {
751751 outNotInEdges.insert (pair.second );
752752 }
@@ -772,7 +772,7 @@ Graph<T>::inNotOutEdges(shared<const Node<T>> node) const {
772772 auto nodeEdgePairsIn = cachedAdjListIn->at (node);
773773
774774 std::unordered_set<shared<const Edge<T>>, edgeHash<T>> inNotOutEdges;
775- for (auto pair : nodeEdgePairsIn) {
775+ for (const auto & pair : nodeEdgePairsIn) {
776776 if (pair.second ->isDirected ().value_or (false )) {
777777 inNotOutEdges.insert (pair.second );
778778 }
@@ -800,13 +800,13 @@ Graph<T>::inOrOutEdges(shared<const Node<T>> node) const {
800800 std::unordered_set<shared<const Edge<T>>, edgeHash<T>> inOrOutEdges;
801801 if (cachedAdjListOut->find (node) != cachedAdjListOut->end ()) {
802802 auto nodeEdgePairsOut = cachedAdjListOut->at (node);
803- for (auto pair : nodeEdgePairsOut) {
803+ for (const auto & pair : nodeEdgePairsOut) {
804804 inOrOutEdges.insert (pair.second );
805805 }
806806 }
807807 if (cachedAdjListIn->find (node) != cachedAdjListIn->end ()) {
808808 auto nodeEdgePairsIn = cachedAdjListIn->at (node);
809- for (auto pair : nodeEdgePairsIn) {
809+ for (const auto & pair : nodeEdgePairsIn) {
810810 inOrOutEdges.insert (pair.second );
811811 }
812812 }
0 commit comments