Mathematics | ![]() ![]() |
Graphing Using Adjacency Matrices
MATLAB's gplot
function creates a graph based on an adjacency matrix and a related array of coordinates. To try
gplot
, create the adjacency matrix shown above by entering
A = [0 1 0 1; 1 0 1 0; 0 1 0 1; 1 0 1 0];
The columns of gplot
's coordinate array contain the Cartesian coordinates for the corresponding node. For the diamond example, create the array by entering
xy = [1 3; 2 1; 3 3; 2 5];
This places the first node at location (1,3)
, the second at location (2,1)
, the third at location (3,3)
, and the fourth at location (2,5)
. To view the resulting graph, enter
gplot(A,xy)
![]() | Introduction to Adjacency Matrices | The Bucky Ball | ![]() |