|
ADJACENCY MATRIXName:
We make a distinction between undirected and directed adjacency matrices. For the undirected case, the order of the edges does not matter. So an edge between vertex i and vertex j means that both Aij and Aji will be set to 1. In the directed case, the order is relevant. So if Aij = 1, this does not imply that Aji = 1. Adjaency matrices are most useful when dealing with dense graphs with a relatively modest number of vertices.
where <edge1> is a variable that identifies the first vertex in the edge; <edge2> is a variable that identifies the second vertex in the edge; and <mat> is a matrix where the adjacency matrix is saved. This syntax is used for the undirected case.
where <edge1> is a variable that identifies the first vertex in the edge; <edge2> is a variable that identifies the second vertex in the edge; and <mat> is a matrix where the adjacency matrix is saved. This syntax is used for the directed case.
dimension 100 columns
read edge1 edge2
2 3
4 7
1 9
7 11
5 8
2 5
6 10
2 8
3 8
4 11
end of data
.
let nvert = 14
let adj = adjacency matrix edge1 edge2 nvert
.
set write format 14F5.0
print adj
Date created: 9/8/2010 |