Iterate over vector of pair
Solution 1:
There are at least three errors in the loop.
for ( vector < pair<float,pair<int,int>> >::const_iterator it = edges.begin() ; itt != edges.end; it++){
cout >> it.first;
}
First of all you have to use edges.end()
instead of edges.end
. And inside the body there has to be
cout << it->first;
instead of
cout >> it.first;
To escape such errors you could write simply
for ( const pair<float, pair<int,int> > &edge : edges )
{
std::cout << edge.first;
}
Solution 2:
for ( vector < pair<float,pair<int,int>> >::const_iterator it = edges.begin() ;
it != edges.end () ; // Use (), and assuming itt was a typo
it++)
{
cout << it->first; // Use ->
}
Also, you might want to add a custom comparator for std::sort
Solution 3:
C++14 iterators are a lot simpler
for (const auto& pair : edges)
{
std::cout << pair.first;
}
or
for (const auto& [first, sec] : edges)
{
std::cout << first;
}