Getting ready

First, we need to create an abstract class, Graph, declaring the virtual methods that every graph representation implements. It is done this way because no matter how the vertices and edges are represented internally, the path-finding algorithms remain high level, thereby avoiding implementation of the algorithms for each type of graph representation.

This class works as a parent class for the different representations to be learned in the chapter and is a good starting point if you want to implement graph representations not covered in the book.

Then, we will implement a graph sub-class that handles itself internally as a grid.