Graphs, Representation and Connectivity
Font: wikipedia Graph-theoretic data structures Main article: Graph (data structure)
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.
An incidence matrix is a matrix that shows the relationship between two classes of objects. If the first class is X and the second is Y, the matrix has one row for each element of X and one column for each element of Y. The entry in row x and column y is 1 if x and y are related (called incident in this context) and 0 if they are not.
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).
Laplacian matrix or "Kirchhoff matrix" or "Admittance matrix"
This is defined as D − A, where D is the diagonal degree matrix. It explicitly contains both adjacency information and degree information. (However, there are other, similar matrices that are also called "Laplacian matrices" of a graph.)
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 a(x,y) is 1 (or in general the number of x|y edges), otherwise it is 0. In computing, this matrix makes it easy to find subgraphs, and to reverse a directed graph.
A symmetric n by n matrix D, where n is the number of vertices in the graph. The element d(x,y) is the length of a shortest path between x and y; if there is no such path dx,y
- Undirected graph
- Direct graph
- Complet graph
- Empty graph