qiubg
March 5th, 2008, 08:37 PM
There are many nodes in the map, each of which is connected to other nodes. One way traffic for all edges, for instance, from N1 to either N2 or N3, but from N2 or N3 can’t directly go back to N1. One node can go to maximum two other nodes, and mamimum two nodes can go to the same node. The distance between any connection nodes, for instance, S1 (btw N1&N2), S2 (btw N1&N3), etc... is also important. Each node has its weight. Cost=distance*weight. For instance, from N1 to N2, the travelling cost=S1* weight of N2. There is no node that only has in or out path. (there is no starting or ending nodes). The problem is to find the least cost from any node to another node.
I think I can pair the distance with node ID (say, (S1, N2), (S5, N6), etc...) but how to map the nodes? What kind of data structure you think I should use in C++? Or anyone can provide code for this? Appreciated very much.
I think I can pair the distance with node ID (say, (S1, N2), (S5, N6), etc...) but how to map the nodes? What kind of data structure you think I should use in C++? Or anyone can provide code for this? Appreciated very much.