Docsity

CSC 222 Programming Project: Shortest Paths in Graphs using Dijkstra's Algorithm, Study Guides, Projects, Research of Computer Science

Toggle sidebar
bg1
CSC 222: Programming Project # 2: Shortest Paths in Graphs
Instructor: V. Pa´ul Pauca
due date: December 4
In this programing project we are going to implement Dijkstra’s algorithm for finding shortest paths in
undirected graphs G= (V, E ) whose edge lengths `eare positive integers. Recall that, like breadth-first
search, the complexity of Dijkstra’s algorithm is O(|V|+|E|).
Algorithm. A pseudo-code implementation of Dijkstra’s algorithm appears in page 110 of the textbook.
This implementation requires operations on a priority queue. We will use a binary heap, as described in
pages 113–115, to implement our priority queue and associated operations.
The Graphs. We’ll attempt to apply Dijkstra’s algorithm to two fairly large graphs (New York City and
Rome99) from the 9th DIMACS Implementation Challenge sponsored by NSF, which can be downloaded
from the following link:
http://www.dis.uniroma1.it/˜challenge9/download.shtml
The New York City graph contains 264,346 vertices and 733,846 edges. The Rome99 graph contains
3,353 vertices and 8,870 edges. Edge lengths indicate physical distance. You can also download this data
from our course webpage.
Programming.
1. Implement the binary heap data structure described in the textbook. You will need to support the
following operations:
•insert( element ): inserts a new node (vertex,distance-from-s) into the binary heap, while
maintaining the heap property.
•decreaseKey( node, d ): decreases key of node to value d, while maintaining the heap property.
•deleteMin(): removes the root node from the binary heap, restores the heap property, and
returns the removed node.
Verify your binary heap implementation using appropriate test code.
2. Implement the following operations for a priority queue:
•makeQueue( V, dist ): where Vis the set of vertices and dist is an integer array of length |V|.
•decreaseKey( node, d): decrease key of node in the priority queue.
•deleteMin() returns the node with the smallest key and removes it from the the priority queue.
3. Implement Dijkstra’s algorithm as described in the textbook.
4. Implement a function that will enable you to read in the DIMACS graphs into an integer array in
memory.
5. Implement a function that outputs the shortest path (edges in the path and the distance) between any
two given nodes in the graph.
What to turn in.
•Working source code for this programming project.
•The shortest path and its distance for two sets of nodes to be specified by the instructor in class.
•Average time to compute shortest paths for each downloaded graph.
CSC 222
Fall 2008
1

Partial preview of the text

Download CSC 222 Programming Project: Shortest Paths in Graphs using Dijkstra's Algorithm and more Study Guides, Projects, Research Computer Science in PDF only on Docsity!

CSC 222: Programming Project # 2: Shortest Paths in Graphs

Instructor: V. Pa´ul Pauca

due date: December 4

In this programing project we are going to implement Dijkstra’s algorithm for finding shortest paths in undirected graphs G = (V, E) whose edge lengths `e are positive integers. Recall that, like breadth-first search, the complexity of Dijkstra’s algorithm is O(|V | + |E|).

Algorithm. A pseudo-code implementation of Dijkstra’s algorithm appears in page 110 of the textbook. This implementation requires operations on a priority queue. We will use a binary heap, as described in pages 113–115, to implement our priority queue and associated operations.

The Graphs. We’ll attempt to apply Dijkstra’s algorithm to two fairly large graphs (New York City and Rome99) from the 9th DIMACS Implementation Challenge sponsored by NSF, which can be downloaded from the following link: http://www.dis.uniroma1.it/˜challenge9/download.shtml The New York City graph contains 264,346 vertices and 733,846 edges. The Rome99 graph contains 3,353 vertices and 8,870 edges. Edge lengths indicate physical distance. You can also download this data from our course webpage.

Programming.

  1. Implement the binary heap data structure described in the textbook. You will need to support the following operations: - insert( element ): inserts a new node (vertex,distance-from-s) into the binary heap, while maintaining the heap property. - decreaseKey( node, d ): decreases key of node to value d, while maintaining the heap property. - deleteMin(): removes the root node from the binary heap, restores the heap property, and returns the removed node.

Verify your binary heap implementation using appropriate test code.

  1. Implement the following operations for a priority queue:
    • makeQueue( V, dist ): where V is the set of vertices and dist is an integer array of length |V |.
    • decreaseKey( node, d): decrease key of node in the priority queue.
    • deleteMin() returns the node with the smallest key and removes it from the the priority queue.
  2. Implement Dijkstra’s algorithm as described in the textbook.
  3. Implement a function that will enable you to read in the DIMACS graphs into an integer array in memory.
  4. Implement a function that outputs the shortest path (edges in the path and the distance) between any two given nodes in the graph.

What to turn in.

  • Working source code for this programming project.
  • The shortest path and its distance for two sets of nodes to be specified by the instructor in class.
  • Average time to compute shortest paths for each downloaded graph.

CSC 222 Fall 2008 1