| Author |
Comment/Response |
Zhiyu Fan
|
09/09/10 09:19am
Hallo All,
we can show a GridGraph with e.g.
g=GridGraph[3,3]
ShowGraph[g]
with help of AdjacencyMatrix we could get the adjacent matrix of the graph g,
In[217]= adm = ToAdjacencyMatrix[g]
Out[217]= {{0, 1, 0, 1, 0, 0, 0, 0, 0}, {1, 0, 1, 0, 1, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 1, 0, 0, 0}, {1, 0, 0, 0, 1, 0, 1, 0, 0}, {0, 1, 0, 1, 0, 1, 0, 1, 0}, {0, 0, 1, 0, 1, 0, 0, 0, 1}, {0, 0, 0, 1, 0, 0, 0, 1, 0}, {0, 0, 0, 0, 1, 0, 1, 0, 1}, {0, 0, 0, 0, 0, 1, 0, 1, 0}}
then i changed a few value in the adjacent matrix.
adm = {{0, 1, 1, 1, 1, 1, 0, 0, 0}, {1, 0, 1, 0, 1, 0, 0, 0, 0}, {0,
1, 0, 0, 0, 1, 0, 0, 0}, {1, 0, 0, 0, 1, 0, 1, 0, 0}, {0, 1, 0, 1,
0, 1, 0, 1, 0}, {0, 0, 1, 0, 1, 0, 0, 0, 1}, {0, 0, 0, 1, 0, 0, 0,
1, 0}, {0, 0, 0, 0, 1, 0, 1, 0, 1}, {0, 0, 0, 0, 0, 1, 0, 1, 0}}
Out[220]= {{0, 1, 1, 1, 1, 1, 0, 0, 0}, {1, 0, 1, 0, 1, 0, 0, 0,
0}, {0, 1, 0, 0, 0, 1, 0, 0, 0}, {1, 0, 0, 0, 1, 0, 1, 0, 0}, {0, 1,
0, 1, 0, 1, 0, 1, 0}, {0, 0, 1, 0, 1, 0, 0, 0, 1}, {0, 0, 0, 1, 0,
0, 0, 1, 0}, {0, 0, 0, 0, 1, 0, 1, 0, 1}, {0, 0, 0, 0, 0, 1, 0, 1,
0}}
so i have a new graph g1
g1= FraomAdjaencyMatrix[adm]
and then i will show it like as g
ShowGraph[g1, VertexLabel -> True]
but the graph will not show like as graph g, because the FromAdjacencyMatrix constructs a graph using a circular embedding.
how can i show the new graph g1 like as g (GridGraph)
thank you in advances
Zhiyu
URL: , |
|