Homework 4: Due 9/27


Add code to Ladders.java so that it outputs all connected components of size 2 and size 3. A connected components is a portion of the graph that is connected, but is disconnected from the rest of the graph. In Quiz 4(b) you were asked to enumerate the isolated vertices of the ladders graph; these are the size-1 connected components of the graph. A size-2 connected component would be pair of vertices that have no neighbors other than each other. A size-3 connected component can either be a path of length 2 that is disconnected from the rest of the graph or a triangle that this disconnected from the rest of the graph.

Hint: To enumerate all size-2 connected components, generate all pairs of vertices using two nested for-loops and to enumerate all size-3 connected components, generate all triples of vertices using three nested for-loops.

Submit Ladders.java and a Ladders.readme file.