Re: problem For with GraphPlot

*To*: mathgroup at smc.vnet.net*Subject*: [mg78086] Re: problem For with GraphPlot*From*: Bill Rowe <readnewsciv at sbcglobal.net>*Date*: Fri, 22 Jun 2007 06:48:34 -0400 (EDT)

On 6/21/07 at 6:02 AM, christophe.lucarz at epfl.ch (Christophe Lucarz) wrote: >When I do this : GraphPlot[g], it draws correctly the graph When I >want to iterate the drawing of the same graph 4 times, it doesn't >work : For[i = 0, i < 4, i++, GraphPlot[g]] I assume you are using version 6. In this case you need to explicitly Print the graph i.e., For[i = 0, i < 4, i++, Print@GraphPlot[g]] Note, while this does work, in general it isn't a good idea to use For loops in Mathematica. They tend to be much slower than other means of creating the same output For example, consider In[12]:= sum = 0; Timing[For[i = 0, i <= 100000, i++, sum += i]; sum] Out[13]= {0.946288,5000050000} versus In[11]:= Timing[Plus @@ Range[100000]] Out[11]= {0.119796,5000050000} For doing the same thing several times where the value of the counter isn't used in the loop such as your particular example using Table would be better, i.e., Table[GraphPlot[g],{4}] And if you don't want the output as a list, use GraphicsRow, GraphicsColumn or TableForm -- To reply via email subtract one hundred and four