Please help. Weighted Directed Graph?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • qiubg
    New Member
    • Mar 2008
    • 1

    Please help. Weighted Directed Graph?

    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*w eight. 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...) anyone can provide VC++ code for this?

    Is this a weighted Directed Graph?
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    The way this sounds, it could be either Weighted Undirected or Weighted Directed. Either way, check out Dijkstra's algorithm for the Shortest Path.

    Comment

    Working...