# Convert GraphPlot[]s with many nodes into something that's human-understandable

This is more of an abstract/creative problem. I think everyone who has played around with GraphPlot, ended up with an image that looks like this, at least once in their life:

I am looking for general solutions to convert many connections -> many connections into something that's human understandable.

Here's my code above:

d = DictionaryLookup[RegularExpression["[a-z]{1,5}"]];
d = Take[d, 1000];
g = {};
Do[Do[If[Abs[StringLength[d[[i]]] - StringLength[d[[j]]]] > 1,
Continue[]];
If[EditDistance[d[[i]], d[[j]]] == 1,
AppendTo[g, d[[i]] -> d[[j]]];
AppendTo[g, d[[j]] -> d[[i]]]], {j, i + 1, Length[d]}], {i, 1,
Length[d]}]

Needs["GraphUtilities"]
s = StrongComponents[g];
sc = Last[SortBy[s, Length]];
gc = Select[g, MemberQ[sc, #[[1]]] &];
GraphPlot[gc,
Arrow[#1, .07]} &)]


I would love something like this, where strongly connected nodes are grouped into single pie-chart vertices which represent the # of node connections over total connections.

-
Your example graph will typically have only a single component of size larger than one, so grouping components into nodes is very likely to just give a star graph in this specific case. –  Szabolcs Feb 16 '12 at 11:18
Well, this one is a connected graph (it has a single connected component). My point was that you could get better answers if you made the question more specific. A hairball is a hairball but sometimes it has some underlying structure. What that structure is and how to extract it will be different from network to network ... I think the question is too broad to get good answers. –  Szabolcs Feb 16 '12 at 12:51
There's no generic way to extract the underlying structure? I mean, if you gave me a hairball list of data, I would immediately apply generic metrics like mean / mediam / sdev / mode/ etc. to better understand it. It's not my field, so I was wondering if there are generic solutions to handle that these network graphs in the same way. Like grouping closely related connections, and outputting them as pie-charts as 'strength' meters (immediate vs total connections); Or group and play with transparency (weakly connected are barely visible). –  Mr. Demetrius Michael Feb 16 '12 at 13:48

Your graph has many vertexes, while the exemplary graph you link to does not and this is why it looks so nice. Styling with pie charts is not a problem at all:

g = RandomGraph[{15, 43}];

vfc[{xc_, yc_}, name_, {w_, h_}] :=
Inset[PieChart[{VertexDegree[g, name], VertexList[g] // Length},
SectorOrigin -> {Automatic, .7},
ChartStyle -> "AvocadoColors"], {xc, yc}, Automatic,
VertexDegree[g, name]/30]

SetProperty[g, VertexShapeFunction -> vfc]


I by the way understand that you want more - to replace "heavy" sub-graphs by nodes reflecting their statistics. That could be done, but it is a bit messy and ambiguous, more of a research question. If I find time I may post a solution.

Here is another angle at a quicker analysis. Automatic spatial layouts Mathematica uses for graph carry a lot of information too. We can use FindClusters to analyse it. I will remove directed and multiple edges for clear picture. To see clustering of regions, after you execute your code do this:

n = 10;(*number of clusters*)
grr = Graph[Union[Sort /@ gc], DirectedEdges -> False, GraphStyle ->
"LargeNetwork", VertexSize -> 0];
cls = ListPlot[FindClusters[AbsoluteOptions[grr, VertexCoordinates][[2]], n],
PlotStyle -> ColorData[3, "ColorList"]];
Show[grr, cls, BaseStyle -> PointSize[.01]]


-
wow looks great! but does this work with GraphPlot? Assuming my Example Graph above is g = GraphPlot[gc] (removed Edge Rendering) and SetProperty[g, VertexShapeFunction -> vfc] –  Mr. Demetrius Michael Feb 17 '12 at 0:39
@Mr.DemetriusMichael Graph has much greater functionality than GraphPlot in the sense that GraphPlot is only graphics while Graph holds complete information about the graph itself and can be operated upon with various graph-related functions. I'd recommend to use Graph for 2D graphs. –  Vitaliy Kaurov Feb 17 '12 at 2:53
Might I suggest BaseStyle -> {PointSize[0.01]}, PlotStyle -> Array[ColorData[3], n]` –  Mr.Wizard Feb 17 '12 at 11:18
@Mr.Wizard Yes, thanks, should keep it simple ;-) –  Vitaliy Kaurov Feb 17 '12 at 11:50