Information about assignment 4 for cs 303, which involves working with undirected graphs, adjacency matrices and lists, minimum spanning trees, and shortest path trees. Students are required to write the adjacency matrix and list representations of a given graph, implement breadth first search and depth first search, and find a spanning tree that connects all vertices. Bonus problem asks for adjacency list representation of graph with all the functionality. Submission includes written homework, source code, and a writing assignment.
Download CS 303 Assignment 4: Graph Theory and Spanning Trees and more Assignments Computer Science in PDF only on Docsity!
CS 303 - Assignment 4
Written Homework:
Write the adjacency matrix and adjacency list representation of the following undirected graph:
How can Linked List data structure be used for adjacency list representation of graph?
Which of the following finds the lowest-cost way to connect all of the vertices? a) Minimum Spanning Tree b) Shortest Path Tree
Which of the following finds the lowest-cost path between two given vertices? a) Minimum Spanning Tree b) Shortest Path Tree
Programming Problem:
Implement the Adjacency Matrix representation of Graph. Input will be provided as a multidimensional array. eg: input = {{1,2}, {2,4}, {3,2}, {3,4}, {4,5}, {0,1}};
The required task is to read each of such pairs and store in adjacency matrix. The nodes are represented by integers starting from 0 and increasing sequentially. So these numbers can be used to identify the nodes, without need of labels.
Add functionality to perform Breadth First Search and Depth First Search in the graph, given start node and a node to be searched. After the node is found also print the path from start node to the search node. Given a node as a starting point, find a spanning tree that spans all the vertices of the graph. While visiting the nodes, you may need to maintain the list of nodes that have already been visited so that infinite loop will not occur. Spanning tree: Given a connected, undirected graph, a spanning tree of that graph is a sub-graph which is a tree (non-cyclic) and connects all the vertices. Hence, a graph may have many different spanning trees. The following Figures illustrate two different spanning trees. Bonus Problem: Write a program for Adjacency List representation of Graph with all the functionality above. You may use the suitable data structure you created in past lab or provided by java for the underlying storage.