471,073 Members | 1,116 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,073 software developers and data experts.

Use Dijktra's Algorithm & design C++ program

Given a topology and a certain node X, find the shortest path tree
with X as the root.

* Input: a topology file similar to the following (which is a three-node

Nodes: (3) // there are three nodes (node 0, 1 and 2)

Edges: (3)
ID node node cost
0 0 1 100 // there is an bidirectional edge between
node 0 & 1, the edge ID is 0, and the cost is 100
1 1 2 50
2 2 0 100

* Output: Description of the tree as following, the order should be
based on breadth-first search
0(0) 1(0) 2(0)

where A(B) means the parent of node A is node B

* Requirements:
- Use standard C++
- Use of Dijkstra's algorithm is required when finding shortest paths
- No GUI
- Platform independent (can be compile under both Windows and Linux)
- The code must be compilable
- Use of STL is recommended (but not required)
- Use of class is required
Jan 24 '09 #1
2 4456
2,425 Expert 2GB
What is Dijkstra's Algorithm?
Jan 24 '09 #2
Dijkstra's algorithm, conceived by Dutch computer scientist Edsger Dijkstra in 1959, [1] is a graph search algorithm that solves the single-source shortest path problem for a graph with non negative edge path costs, outputting a shortest path tree. This algorithm is often used in routing.
For a given source vertex (node) in the graph, the algorithm finds the path with lowest cost (i.e. the shortest path) between that vertex and every other vertex. It can also be used for finding costs of shortest paths from a single vertex to a single destination vertex by stopping the algorithm once the shortest path to the destination vertex has been determined. For example, if the vertices of the graph represent cities and edge path costs represent driving distances between pairs of cities connected by a direct road, Dijkstra's algorithm can be used to find the shortest route between one city and all other cities. As a result, the shortest path first is widely used in network routing protocols, most notably IS-IS and OSPF (Open Shortest Path First
Jan 24 '09 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by greenflame | last post: by
reply views Thread by YellowFin Announcements | last post: by
10 posts views Thread by Sunway | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.