Message Boards Message Boards

Building Better Mind Maps

"Mind Maps" in the title is perhaps a bit narrow. I am looking for such Graph options that would make large text-heavy vertex labels look as comprehensive as possible. This should include some control over such things as automated text wrapping or edge arrow placements or text alignment. You can see on the figure below the design I have in mind.

enter image description here

Defining proper VertexShapeFunction is the key. This is a start with a few options that can be tuned or expanded (in Style for instance):

vshape[w_][x_, s_, _] := 
    Inset[Framed[Pane[Style[s,TextAlignment->Left],w],
    Background->LightYellow,RoundingRadius->5],x] 

Pane does the automated text wrapping over a given width that I make a variable via currying. Let's get some data for a long-text labels, which are here some Wikipedia articles' titles and hyperlinks:

ocd="Obsessive\[Dash]compulsive personality disorder";

ocdlinks=DeleteDuplicatesBy[WikipediaData[ocd,"LinksRules",
"MaxLevelItems"->3,"MaxLevel"->3],Sort];

The code below will produce the top image of this post. Note I set the arrow head position manually at 0.65 length of the edge.

Graph[ocdlinks, 
    VertexShapeFunction -> vshape[70],
    EdgeShapeFunction->
       GraphElementData[{"ShortCarvedArcArrow",
       "ArrowSize"->.03,"ArrowPositions"->.65}], 
    VertexStyle -> Black, 
    AspectRatio->1,
    PerformanceGoal -> "Quality",
    GraphLayout ->{"LayeredDigraphEmbedding",
          "Orientation"->Left,
          "RootVertex"->ocd}]

The function for VertexShapeFunction defined above will do a couple of more tricks. Let's get some other similar complex-text data:

syn="Acro\[Dash]dermato\[Dash]ungual\[Dash]lacrimal\[Dash]tooth syndrome";
synlinks=DeleteDuplicatesBy[WikipediaData[syn,
"LinksRules","MaxLevelItems"->3,"MaxLevel"->3],Sort];

I will try another layout and will remove manual arrow head placement. As you can see in this case arrow head always remains positioned at the boundary of the vertex label. Also text is reflowing nicely with help of the Pane.

Manipulate[
Graph[synlinks, 
    VertexShapeFunction -> vshape[w], 
    VertexStyle -> Black, 
    AspectRatio->1,
    ImageSize->700{1,1},
    PerformanceGoal -> "Quality",
    GraphLayout ->{"RadialEmbedding","RootVertex"->syn}]
,{{w,70},30,120}]

enter image description here

Attachments:
POSTED BY: Vitaliy Kaurov
4 Replies

Thanks Vitaliy! I decided to check out what they think about Wolfram Mathematica. The result was unexpected, but reasonable.

fig1

Two things:

  1. Change root to syn in:

    synlinks=DeleteDuplicatesBy[WikipediaData[root, "LinksRules","MaxLevelItems"->3,"MaxLevel"->3],Sort];
    
  2. Using Style[s, TextAlignment->Left] uses the default linebreaking associated with expressions. For text, you get better linebreaking if you use TexCell[s]. Even better might be TextCell[s, Hyphenation->True].

POSTED BY: Carl Woll

Yes looks a bit random :-) But don't forget "MaxLevelItems"->3 means at every page you select just 3 hyperlinks, while in reality there are many more. And to represent a Wikipedia article by its links you probably need just links of that page not the next level ones. The following paints a better picture:

syn="Wolfram Mathematica";
synlinks=WikipediaData[syn,"LinksRules","MaxLevelItems"->1000,"MaxLevel"->1];

WordCloud[DeleteStopwords[ToLowerCase[StringRiffle[synlinks]]],
ScalingFunctions->(#^.01&),WordOrientation->{{-Pi/4,Pi/4}},AspectRatio->1/2]

enter image description here

POSTED BY: Vitaliy Kaurov

Thanks, Carl! Typo corrected. TextCell is a nice idea, - I also like that TextJustification can be used.

POSTED BY: Vitaliy Kaurov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract