# Building Better Mind Maps

Posted 2 years ago
4887 Views
|
4 Replies
|
22 Total Likes
|
 "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.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}]  Attachments:
4 Replies
Sort By:
Posted 2 years ago
 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] 
Posted 2 years ago
 Thanks Vitaliy! I decided to check out what they think about Wolfram Mathematica. The result was unexpected, but reasonable.
 Two things: Change root to syn in: synlinks=DeleteDuplicatesBy[WikipediaData[root, "LinksRules","MaxLevelItems"->3,"MaxLevel"->3],Sort];  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].
 Thanks, Carl! Typo corrected. TextCell is a nice idea, - I also like that TextJustification can be used.