Re: Re: GraphPlot
- To: mathgroup at smc.vnet.net
- Subject: [mg70830] Re: [mg70809] Re: [mg70775] GraphPlot
- From: Carl Woll <carlw at wolfram.com>
- Date: Sat, 28 Oct 2006 23:38:06 -0400 (EDT)
- References: <7490715.316071162046101346.JavaMail.root@vms075.mailsrvcs.net>
Bruce Colletti wrote: >Carl > >In v5.2, why does: > > GraphPlot[{...}, VertexStyleFunction -> (Text[#, #] &) > >fail when {0,-1} is the Text offset? > > GraphPlot[{1 -> 2, 2 -> 3, 3 -> 1, 3 -> 4, 5 -> 6, 6 -> 5}, >VertexStyleFunction -> (Text[#, #,{0,-1}] &) > >Thankx. > >Bruce > > I don't know the answer, sorry. Apparently there is a problem with the code that substitutes coordinates for coordinate labels in 3 or 4 argument Text objects. If you want to draw labels so that they are not obstructed, you could instead add a couple more graphics directives, e.g.: GraphPlot[{1 -> 2, 2 -> 3, 3 -> 1, 3 -> 4, 5 -> 6, 6 -> 5}, VertexStyleFunction -> ({Yellow, Disk[#, .2], Black, Circle[#, .2], Text[#, #]} &)] Carl Woll Wolfram Research > > > >===================== >From: Carl Woll <carlw at wolfram.com> To: mathgroup at smc.vnet.net >Subject: [mg70830] [mg70809] Re: [mg70775] GraphPlot > >Matt Curcio wrote: > > > >>Carl, >> Thanks for your reply. Sorry I was unclear, let me try to >>explain better with a simpler example. When you run the code: >> >><< DiscreteMath`GraphPlot`; >>GraphPlot[{1 -> 2, 2 -> 3, 3 -> 1, 3 -> 4, 5 -> 6, 6 -> 5}, >>VertexStyleFunction -> (Text[#, #] &) >> >> >>You see two graphs with the vertices labeled. The rightmost graph is >>composed of the components {5->6, 6->5}. But the only way I know >>that is because I've labeled the vertices and my dataset above is so >>small. What I would like is a function that does the following: >> >>MagicalGraphCoordinatesFunction[ {1 -> 2, 2 -> 3, 3 -> 1, 3 -> 4, 5 - >> >> >>>6, 6 -> 5} ]; >>> >>> >>which returns: >>{{1 -> 2, 2 -> 3, 3 -> 1, 3 -> 4}, {5 -> 6, 6 -> 5}} >> >>i.e. A list with the elements of the two directed graphs in my data. >>I am essentially using GraphPlot to discover how many directed graph >>clusters are in my data. Its great to visualize them, but I would >>really like to know which elements make up the subgraphs. >> >>Thanks again, >>Matt >> >> > >Did you try the code I gave in my last post? Trying it out on this >example, we have: > >gr={1 -> 2, 2 -> 3, 3 -> 1, 3 -> 4, 5 -> 6, 6 -> 5} > >In[9]:= >StrongComponents[Join[gr, Reverse /@ gr]] >Out[9]= >{{1, 2, 3, 4}, {5, 6}} > >This isn't quite what you asked for, but it's close. > >Carl Woll >Wolfram Research > > > >> >>On Oct 27, 2006, at 5:13 AM, Carl Woll wrote: >> >> >> >>>Matt Curcio wrote: >>> >>> >>> >>>>Hi, >>>> I have a question about extracting data from the internals of >>>>GraphPlot. For example, the following code plots multiple >>>>subplots of disconnected clusters. >>>> >>>><< DiscreteMath`GraphPlot` >>>>n = 129; >>>>d = Table[i -> Mod[i^2, n], {i, 0, n - 1}]; >>>>GraphPlot[d]; >>>> >>>>However, I would like to know the subsets that are being plotted. >>>>I know you can plot the vertex labels on the chart, but my dataset >>>>is ~50,000 connected vertices and GraphPlot outputs ~100 clusters, >>>>so vertex labeling is unrealistic. It would be very interesting >>>>to know which vertices GraphPlot has associated. There maybe a >>>>way to do this using some functions from "Combninatorica" but I >>>>have not been able to find them. Can anyone help? >>>> >>>>Thanks, >>>>Matt >>>> >>>> >>>> >>>I'm not clear on what you want, but have you tried StrongComponents >>>from the GraphPlot package? This function will give you a list of >>>the vertices in each disconnected cluster (assuming the graph is >>>undirected). In your example, we would convert d to an undirected >>>graph and then use StrongComponents: >>> >>>comps = StrongComponents[ Join[d, Reverse/@d] ]; >>> >>>In[30]:= >>>Length[comps] >>>Out[30]= >>>14 >>> >>>Carl Woll >>> >>>