Graph representation
A grid can be viewed as a special case of a graph.

Properties of graphs
A graph-based pathfinding algorithm needs to know what the locations are and also which locations are connected to which other ones. You typically know a lot more than this, like the size and coordinates of the locations, but the algorithm doesn’t actually know about these aspects. It only knows what the connections are.
A mathematical graph is a set of nodes and edges. The nodes (also called vertices or objects) are connected together by the edges (also called links or connections or arrows or arcs). For any graph we need to know two things:
- Set of nodes in the graph
- Set of edges from each node
What does the above graph look like?
- Set of nodes: .
- Set of edges from each node:
Note that the layout of the graph is not part of the graph. The graph in the above diagram and the graph shown below are the same graph: