Click on any exercise below to see the source code, program output and explanation of the code.  The exercises in this section make use of graphs. A graph is a set of nodes (called vertices) together with a set of edges that connect pairs of distinct vertices (with at most one edge connecting any pair of nodes).

Available Exercises

Exercise 8.1. Write a program, which given inputs as integer pairs representing edges, creates an adjacency matrix for a graph.

Exercise 8.2. Write a program, which given inputs as integer pairs representing edges, creates an adjacency list for a graph.

Exercise 8.3. Write a suitable declaration for a graph ADT interface that can be used to study graph algorithms