| |||||||||||||||||
![]() |
![]() |
![]() |
|||||||||||||||
|
Adjacency Matrix of a Graph
The graph family argues that one of the best ways to represent them into a matrix is by counting the number of edge between two adjacent vertices. Two vertices is said to be adjacent or neighbor if it support at least one common edge. Let us start with example Graph below has three vertices. Thus, we make adjacency matrix of size 3 by 3. Then we put the name of vertices on the side of the matrix. Look at the picture and we start with an empty matrix. Only the names of vertices are there
To fill the adjacency matrix, we look at the name of the vertex in row and column. If those vertices are connected by an edge or more, we count number of edges and put this number as matrix element. Vertex
Vertex
Similarly, vertex
There is no other edge on the graph, thus we put the rest of unfilled cells in the matrix as zero
The matrix to represent a graph in this way is called Adjacency matrix .
The size of adjacency matrix is equal to the number of vertices in the graph. It is a square matrix (that is the number of rows is equal to the number of columns). The adjacency matrix of a graph is symmetric because it has no direction. Two vertices share the same edge can be called from the first one to the second one, or from the second one to the first one. For example, Vertex
Let us try another example:
Can you make the adjacency matrix of this graph? Try it first before you look at the answer below. The graph has 3 vertices, thus we make a matrix size 3 by 3. We put the name of vertices on the side of the matrix.
Now look at the vertex
Look at vertex
Next, you look at vertex
Since there is no other edge in the graph, we can fill the empty cell with zeros. Thus, we have the answer
Some of you may ask about the diagonal part of the matrix, are these cells always zero? No, if you find the graph has some loop in some vertices, you can fill the diagonal element of adjacency matrix with the number of loop. If a graph has some vertex that is not connected to any other vertices, the adjacency matrix correspond to that single vertex is zero.
Please do some practice to represent graph below into adjacency matrix.
(See the answer in the previous page)
Given the adjacency matrix, can you draw back the graph?
Check example application of graph theory in Q-Learning Tutorial
These tutorial is copyrighted. Preferable reference for this tutorial is Teknomo, Kardi. Pictorial Introduction to Graph Theory. http:\\people.revoledu.com\kardi\ tutorial\GraphTheory\
|
|||||||||||||||
© 2006 Kardi Teknomo. All Rights Reserved. Designed by CNV Media |
||||||||||||||||