CS 112 Lab 11: Graph representation

Agenda

We will use HashMap and HashSet datastructures to represent a graph. The graph input is specified as a list of edges. We will see how to perform breadth first search using this representation. BFS will also yield shortest paths from all nodes in the graph to the starting node.

Starting code for today's example is below,

Graph.java

Solutions

Graph.java

URL

http://cs-people.bu.edu/tvashwin/cs112_spring08/lab11.html