Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'how construct a graph' topicStudent Support Forum > General > "how construct a graph"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
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: ,

Subject (listing for 'how construct a graph')
Author Date Posted
how construct a graph Zhiyu Fan 09/20/10 05:41am
Re: how construct a graph Daniel Z-S 09/23/10 3:20pm
Re: Re: how construct a graph Zhiyu Fan 09/24/10 11:12am
Re: Re: Re: how construct a graph Daniel Z-S 09/30/10 11:40am
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic