Message Boards Message Boards

GROUPS:

Label an ExampleData within CommunityGraphPlot?

Posted 2 years ago
2551 Views
|
1 Reply
|
5 Total Likes
|

This will probably sound silly, but I would like to label a graph. Specifically I am running the command line:

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

I would first like to locate the file (it was downloaded automatically through mathematica does not appear to be in the ExampleData folder). I am familiar with this data set and am relatively sure it includes labels. I simply do not know how to populate them in the rendering.

Any help is appreciated. Thank you.

Attachments:

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.

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