Hi Friends,
I have a graph in text file (origin, destin, link_id) such as
1 2 1
1 3 2
1 5 3
2 1 4
2 3 5
2 4 6
2 5 7
3 1 8
3 2 9
3 4 10
4 2 11
4 3 12
4 5 13
5 1 14
5 2 15
5 4 16
I declared,
vector<int>pathway;
multimap<int,vector<int>> allpathsmap;
multimap<int,vector<int>>:: iterator itapm;
typedef pair<int,vector<int>> pairapm;
In addition I found all paths from a given Source to Destination.
and I stored them in multimap 'allpathsmap'
And I wrote the code to display them as follows:
for(itapm=allpathsmap.begin(); itapm!=allpathsmap.end(); ++itapm)
{
cout << endl << itapm->first <<" => ";
for(size_t n=1; n<(*itapm).second.size(); ++n)
{
cout <<" "<<itapm->second[n-1]<<"->"<<itapm->second[n];
}
}
Eg:
If Source is 1 and Destination is 4,
1 2 4
1 3 4
1 5 4
1 2 3 4
1 2 5 4
1 3 2 4
1 5 2 4
1 3 2 5 4
1 5 2 3 4
then it displays,
1->2 2->4
1->3 3->4
1->5 5->4
1->2 2->3 3->4
1->2 2->5 5->4
1->3 3->2 2->4
1->5 5->2 2->4
1->3 3->2 2->5 5->4
1->5 5->2 2->3 3->4
Can you help me how to get the link_id of two nodes on a path?
eg:
1, 6
2, 10
3, 16
1, 5, 10
1, 7, 16
2, 9, 6
3, 15, 6
2, 9, 7, 16
3, 15, 5, 10