MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Locators with complete graph, Kn

  • To: mathgroup at smc.vnet.net
  • Subject: [mg95055] Re: Locators with complete graph, Kn
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Sun, 4 Jan 2009 07:35:06 -0500 (EST)
  • References: <g3038u$mei$1@smc.vnet.net> <200806151014.GAA12332@smc.vnet.net> <gjng66$2l8$1@smc.vnet.net>

Hi,

makelines[from_, to_] := Line[{from, #}] & /@ to

completeGraph[pnts_] := Module[{lst = pnts, tmp = pnts},
   (tmp = DeleteCases[tmp, #]; makelines[#, tmp]) & /@ lst]

Manipulate[
  DynamicModule[{pnts, vars, lgraph},
   pnts = Table[{Cos[t], Sin[t]}, {t, 0., 2 Pi - 0.00001, 2 Pi/n}];
   vars = Table[Unique["p"], {n}];
   lgraph = completeGraph[vars];
   Manipulate @@ {Graphics[lgraph, PlotRange -> 1.2],
     Sequence @@ ({#, Locator} & /@ Transpose[{vars, pnts}]),
     Paneled -> False}
   ]
  , {{n, 3}, 2, 16, 1}]



??

Regards
   Jens


Jamie Coventry wrote:
> Hi All,
> 
> I'm trying to create a complete graph with n vertices, with each  
> vertex having a locator, so that I can drag the vertices to show  
> isomorphic graphs to Kn. I'm able to create locators at specific  
> locations (p1, p2 etc...), but am going round in circles trying to  
> improve the code so that can dynamically generate locators at p1,  
> p2, ..., pn. I've tried working with DynamicModule, but the code below  
> seems like the closest to a solution.
> 
> Manipulate[
>   ptpairs = Tuples[Table[{Cos[t], Sin[t]}, {t, 0, 2 Pi, 2 Pi/n}], 2];
>   pts = Tuples[Table[{Cos[t], Sin[t]}, {t, 0, 2 Pi, 2 Pi/n}], 1];
> 
>   Graphics[
>    Line[{p1, p2}],
>    PlotRange -> 2
>    ],
> 
>   {{p1, pts[[1]][[1]]}, Locator},
>   {{p2, pts[[2]][[1]]}, Locator},
>   {n, 2, 10, 1}]
> 
> Any ideas or thoughts would be appreciated.
> 
> Thanks in advance,
> 
> Jamie
> 


  • Prev by Date: Re: Fourier Transform Graph Coordinates
  • Next by Date: Re: sector-based analysis using FInancialData[]
  • Previous by thread: Locators with complete graph, Kn
  • Next by thread: Re: Re: Locators with complete graph, Kn