New in Wolfram
Mathematica
8: Graph & Network Analysis
◄
previous
|
next
►
Application Areas
Analyze Social Networks
Analyze a friendship network between members of a club.
In[1]:=
X
g = ExampleData[{"NetworkGraph", "ZacharysKarateClub"}];
In[2]:=
X
maxMember[func_, g_] := Last[GatherBy[SortBy[Transpose[{VertexList[g], func[g]}], Last], Last]][[All, 1]];
In[3]:=
X
{totalMember, totalRel, mostP, mostF} = {VertexCount[g], EdgeCount[g], maxMember[DegreeCentrality, g], maxMember[BetweennessCentrality, g]};
In[4]:=
X
titles = Style[#, FontFamily -> "Verdana"] & /@ {"Total number of members:", "Total number of relations:", "Most popular members:", "Most friendly members:"};
In[5]:=
X
Grid[Join[{{HighlightGraph[ g, {Labeled[mostP, "MP"], Labeled[mostF, "MF"]}, ImageSize -> 340], SpanFromLeft}}, {{}}, Transpose[{titles, {totalMember, totalRel, mostP[[1]], mostF[[1]]}}]], ItemSize -> {{15, 12}, 1}, Alignment -> Left]
Out[5]=