Adjacency Matrix
Adjacency Matrix
To represent a graph, we just need the set of vertices, and for each vertex
the neighbors of the vertex (vertices which is directly connected to it by an
edge). If it is a weighted graph, then the weight will be associated with each
edge.
1. Adjacency Matrix
Self loop :
Characteristics of the adjacency matrix are:
The size of the matrix is determined by the number of vertices in the
graph.
The number of nodes in the graph determines the size of the matrix.
The number of edges in the graph is simply calculated.
If the graph has few edges, the matrix will be sparse.