Group Abstract Group Abstract

Message Boards Message Boards

Label an ExampleData within CommunityGraphPlot?

Posted 9 years ago
Attachments:
POSTED BY: Abhik

There is no point in looking for a data file as not only is it not supposed be accessed directly by users, it can only be read by Mathematica anyway. Use ExampleData directly. Please look up its usage in the documentation.

See what data is available:

ExampleData[{"NetworkGraph", "AmericanCollegeFootball"}, "Properties"] 

Now you can tell how to look for vertex properties:

ExampleData[{"NetworkGraph", 
  "AmericanCollegeFootball"}, "VertexProperty"]

(* {"Conferences"} *)

or edge properties:

ExampleData[{"NetworkGraph", 
  "AmericanCollegeFootball"}, "EdgeProperty"]

(* {EdgeWeight} *)

Now that you know that there is a vertex property call "Conference", you can get it for each node:

PropertyValue[{g, #}, "Conference"] & /@ VertexList[g]

Update

You could specify the communities manually to be the same as the confereces like this:

asc = GroupBy[VertexList[g], PropertyValue[{g, #}, "Conference"] &];

CommunityGraphPlot[g,
 Values[asc],
 CommunityLabels -> Keys[asc]
 ]

enter image description here

Unfortunately, this plot has multiple problems, including overlapping communities and sub-optimal label placement, and I do not know how to fix either of those.

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