Skip to content

Commit 764ee18

Browse files
authored
Merge pull request #32 from Debashis08/feature-graph-implementation
fix: used references instead copy of obj
2 parents 8b20ebd + 5ec46b5 commit 764ee18

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

SourceCodes/0003_Graph/0007_MinimumSpanningTreeKruskalAlgorithm.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,17 @@ namespace MinimumSpanningTreeKruskalAlgorithm
8181
this->_adjlist[nodeV].push_back(nodeU);
8282
this->_edgeList.push_back(new Edge(nodeU, nodeV, weight));
8383
}
84+
8485
void Graph::FindMinimumSpanningTreeKruskalAlgorithm()
8586
{
86-
for (auto iterator : this->_nodeMap)
87+
for (auto& iterator : this->_nodeMap)
8788
{
8889
this->MakeSet(iterator.second);
8990
}
9091

9192
sort(this->_edgeList.begin(), this->_edgeList.end(), [](Edge* edgeX, Edge* edgeY) { return edgeX->weight < edgeY->weight; });
9293

93-
for (auto edge : this->_edgeList)
94+
for (auto& edge : this->_edgeList)
9495
{
9596
if (this->FindSet(edge->nodeU) != this->FindSet(edge->nodeV))
9697
{

0 commit comments

Comments
 (0)