Function Repository Resource:

GeoCommunityGraphPlot

Source Notebook

Create a graph on a map with communities highlighted with different colors

Contributed by: Peter Cullen Burbery and Eric Parfitt

ResourceFunction["GeoCommunityGraphPlot"][g]

generates a geographic plot showing the community structure of the graph g.

Details and Options

ResourceFunction["GeoCommunityGraphPlot"] takes the same options as GeoGraphPlot.

Examples

Basic Examples (2) 

Create a community graph plot of some European cities:

In[1]:=
ResourceFunction["GeoCommunityGraphPlot"][
 Graph@{Entity["City", {"Rome", "Lazio", "Italy"}] \[UndirectedEdge] Entity["City", {"Milan", "Lombardy", "Italy"}], Entity["City", {"Milan", "Lombardy", "Italy"}] \[UndirectedEdge] Entity["City", {"Paris", "IleDeFrance", "France"}], Entity["City", {"Milan", "Lombardy", "Italy"}] \[UndirectedEdge] Entity["City", {"Frankfurt", "Hesse", "Germany"}], Entity["City", {"Paris", "IleDeFrance", "France"}] \[UndirectedEdge] Entity["City", {"Frankfurt", "Hesse", "Germany"}], Entity["City", {"Paris", "IleDeFrance", "France"}] \[UndirectedEdge] Entity["City", {"Madrid", "Madrid", "Spain"}], Entity["City", {"Paris", "IleDeFrance", "France"}] \[UndirectedEdge] Entity["City", {"London", "GreaterLondon", "UnitedKingdom"}], Entity["City", {"Madrid", "Madrid", "Spain"}] \[UndirectedEdge] Entity["City", {"Seville", "Seville", "Spain"}], Entity["City", {"Madrid", "Madrid", "Spain"}] \[UndirectedEdge] Entity["City", {"Barcelona", "Barcelona", "Spain"}]}]
Out[1]=

Nest the operation of finding bordering countries for a country to create a graph of bordering countries in Europe, Africa, and Asia:

In[2]:=
\[ScriptCapitalE] = UndirectedGraph[
   NestGraph[CountryData[#, "BorderingCountries"] &, Entity["Country", "France"], 12]];

Plot the graph on a map:

In[3]:=
ResourceFunction["GeoCommunityGraphPlot"][\[ScriptCapitalE], Sequence[
 ImageSize -> Full, GeoBackground -> "VectorBusiness"]]
Out[3]=

Neat Examples (1) 

Visualize a graph of the 49 administrative divisions of the continental states including the District of Columbia:

In[4]:=
\[ScriptCapitalE] = UndirectedGraph[
   NestGraph[AdministrativeDivisionData[#, "BorderingStates"] &, Entity["AdministrativeDivision", {"WestVirginia", "UnitedStates"}], 20]];
In[5]:=
ResourceFunction["GeoCommunityGraphPlot"][\[ScriptCapitalE], Sequence[
 ImageSize -> Full, GeoBackground -> "VectorBusiness"]]
Out[5]=

Publisher

Peter Burbery

Version History

  • 1.0.0 – 23 August 2022

Related Resources

Author Notes

The function code was created by Eric Parfitt.

License Information