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

I was doing something similiar in matlab, where a had a huge data file with few thousand rows and about 15 colomns. I had to filter it so for example if value in column1 is 2 and in column2 is 4 then return the number in column 3. I think this will work with you as well, where you check according to your source and the connection next to it. Does this answer your question?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.