| Author |
Comment/Response |
Zhiyu Fan
|
09/24/10 11:12am
In Response To 'Re: how construct a graph' --------- thank for your suggestion.
points = Flatten[Table[{x, y}, {x, 3}, {y, 3}], 1]
{{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}}
i believe Norm[points[[i]] - #] calculate the distance between the two vertices, if {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}} are the same as the coordinate of every vertex. In this case the vertex coordinate in Graph g = GridGraph[3,3]are same as the list points.
connectingPoints =
Table[Select[points, Norm[points[[i]] - #] <= 1 &], {i, Length@points}]
Therefore i believe that
pointsSet =
Flatten[Table[
Map[{points[[i]], #} &, connectingPoints[[i]]], {i, Length@points}], 1]
calculate only the vertices coordinate set not the edges set.
URL: , |
|