III. GRAPH-THEORETIC DATA STRUCTURES
There are different ways to store graphs in a
computer system. The data structure used depends
on both the graph structure and the algorithm used
for manipulating the graph. Theoretically one can
distinguish between list and matrix structures but in
concrete applications the best structure is often a
combination of both. List structures are often
preferred for sparse graphs as they have smaller
memory requirements. Matrix structures on the
other hand provide faster access for some
applications but can consume huge amounts of
memory. [3].
A. List Structures
There are two types of list structures, which are:
1. Incidence list
The edges are represented by an array
containing pairs (tuples if directed) of vertices (that
the edge connects) and possibly weight and other
data. Vertices connected by an edge are said to be
adjacent.
2. Adjacency list
Much like the incidence list, each vertex has a
list of which vertices it is adjacent to. This causes
redundancy in an undirected graph: for example, if
vertices A and B are adjacent, A's adjacency list
contains B, while B's list contains A. Adjacency
queries are faster, at the cost of extra storage space.
B. Matrix Structures
In incidence matrix the graph is represented by
a matrix of size |V (number of vertices) by |E|
(number of edges) where the entry [vertex, edge]
contains the edge's endpoint data (simplest case: 1 -
incident, 0 - not incident).
Adjacency matrix
This is an n by n matrix A, where n is the number
of vertices in the graph. If there is an edge from a
vertex x to a vertex y, then the element ax,y is 1 (or
in general the number of xy edges), otherwise it is
0. In computing, this matrix makes it easy to find
sub graphs, and to reverse a directed graph. [7]
Distance matrix
A symmetric n by n matrix D, where n is the
number of vertices in the graph. The element dx,y is
the length of a shortest path between x and y; if
there is no such path dx,y = infinity. It can be
derived from powers of A.