[Date Index]
[Thread Index]
[Author Index]
Re: GraphPlot
*To*: mathgroup at smc.vnet.net
*Subject*: [mg114576] Re: GraphPlot
*From*: Daniel Lichtblau <danl at wolfram.com>
*Date*: Wed, 8 Dec 2010 06:41:42 -0500 (EST)
Lou wrote:
> Hi All,
> I hope you can help.
> I'm playing around with the GraphPlot function and would like to
> separate the graphs into different plots (in e.g. a table].
> So when there are 5 graphs plotted in one picture I would like 5
> pictures.
> The trick would be (I thought..) to get the graph data and use gather
> to form the graphs with the vertexes connected but it seems the
> GraphPlot function outsmarts the Gather function. So e.g. Gather will
> disconnect some grahps.
> I used Gather with a test function like OR'ing all the vertexes but it
> seems Gather does not try out all possibilities.
> Any of you other thoughts to solve this question?
> so:
> links = {"a" -> "b", "c" -> "b", "d" -> "b", "b" -> "e", "a1" -> "e",
> "c1" -> "e", "d1" -> "e", "q" -> "z", "r" -> "z", "s" -> "z"}
> with GraphPlot[links] will generate 2 graphs.
>
> Gather will make 3 graphs:
> Gather[links, ((#1[[1]] == #2[[1]]) || (#1[[2]] == #2[[2]]) || (#1[[
> 1]] == #2[[2]]) || (#1[[2]] == #2[[1]])) &]
> outputs to
> {{"a" -> "b", "c" -> "b", "d" -> "b", "b" -> "e"}, {"a1" -> "e",
> "c1" -> "e", "d1" -> "e"}, {"q" -> "z", "r" -> "z", "s" -> "z"}}
> which results in 3 graphs..
Gather as used above will not give a transitive closure.
You can get a start on this by finding the connected components of the
undirected version of your graph.
In[14]:= vertsets = ConnectedComponents[UndirectedGraph[Graph[links]]]
Out[14]= {{"a", "b", "c", "d", "e", "a1", "c1", "d1"}, {"q", "z", "r",
"s"}}
In[15]:= subgraphs = GatherBy[links,
osition[vertsets, #[[1]]][[1, 1]] &]
Out[15]= {{"a" -> "b", "c" -> "b", "d" -> "b", "b" -> "e",
"a1" -> "e", "c1" -> "e", "d1" -> "e"}, {"q" -> "z", "r" -> "z",
"s" -> "z"}}
Now you might do
Map[GraphPlot, subgraphs]
to get separated graphs.
Daniel Lichtblau
Wolfram Research
Prev by Date:
**Re: Replacement Rule with Sqrt in denominator**
Next by Date:
**Re: Counting number of numbers in a large list between two valus**
Previous by thread:
**GraphPlot**
Next by thread:
**ODBC-connection error**
| |