I'm curious to know if it's possible to easily generate a grid (lattice)
and obtain the adjacency matrix. For example, I would like to display a
3x3 (or 10x10) lattice then then generate the 10 x 10 adjacency matrix
> matrix( 1:9, 3,3, byrow=TRUE )
[,1] [,2] [,3]
[1,] 1 2 3
[2,] 4 5 6
[3,] 7 8 9>
and then use the mathgraph(?) package to generate the adjacency matrix? I've
been able to generate a simple graph as well as some basic graphs like the
one above but have two concatenate lots of simple graphs together,
gr <- c( mathgraph( ~ 1 / c(2,4) ),
mathgraph( ~ 2 / c(1,3,5) ),
mathgraph( ~ 3 / c(2,6) ),
mathgraph( ~ 4 / c(1,5,7) ),
mathgraph( ~ 5 / c(2,4,6,8) ),
mathgraph( ~ 6 / c(3,5,9) ),
mathgraph( ~ 7 / c(4,8) ),
mathgraph( ~ 8 / c(5,7,9) ),
mathgraph( ~ 9 / c(6,8) ) )
and then
plot( gr )
and
adjamat( gr )
which yields a correct adjacency matrix. Since the names of the nodes are
the values in the elements, is there are easier way to accomplish this?
Thanks,
Jeff.
--
Jeff D. Hamann
Forest Informatics, Inc.
PO Box 1421
Corvallis, Oregon 97339-1421
phone 541-754-1428
jeff.hamann at forestinformatics.com
www.forestinformatics.com