Skip to main content
2 of 3
edited tags
Szabolcs
  • 236.5k
  • 31
  • 641
  • 1.3k

how to successively plot Community Graphs by iteratively using VertexDelete[]

Given the matrix wam:

wam={
{\[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], 
 0.180744, \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], 0.196146, \[Infinity], \[Infinity], 
0.192559}, {\[Infinity], \[Infinity], 0.199743, 
0.189167, \[Infinity], 0.177828, 0.136293, 0.198179, 
0.170862, \[Infinity], \[Infinity], 0.150103, 0.152068, \[Infinity],
0.145293, 0.147801}, {\[Infinity], 
0.17492, \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], 0.196928, \[Infinity], 
0.18818, \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity]}, {\[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity]}, {\[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity], \[Infinity]}, {\[Infinity], \
\[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity]}, \
{0.164114, 0.189904, \[Infinity], \[Infinity], \[Infinity], 
0.142879, \[Infinity], 0.173485, \[Infinity], 0.195519, \[Infinity],
0.179716, 0.152131, \[Infinity], \[Infinity], 0.197488}, {0.193476,
0.186542, \[Infinity], 
0.196847, \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity], \[Infinity], 
0.184613, \[Infinity], 0.195341, 
0.190637}, {\[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity]}, {0.17967, \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], 
0.165566, \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], 
0.16862, \[Infinity], \[Infinity], \[Infinity]}, {\[Infinity], \
\[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity]}, {\
\[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity]}, {\[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], 
 0.183951, \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity]}, {\[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], 0.189936, 0.16593, 
0.197014, \[Infinity], \[Infinity], \[Infinity], 
0.194794, \[Infinity], \[Infinity], \[Infinity], \[Infinity]}, \
{0.189579, 0.167198, \[Infinity], \[Infinity], \[Infinity], 
 0.18947, \[Infinity], \[Infinity], \[Infinity], 
0.187049, \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity]}, {\[Infinity], 
0.149854, \[Infinity], \[Infinity], \[Infinity], 0.188494, 0.150641,
0.192737, 0.194964, \[Infinity], \[Infinity], \[Infinity], 0.14314,
0.15716, 0.14968, \[Infinity]}
}

I generate the directed graph and its community structure:

 vnames = {"AGF", "OIL", "MA1", "MA2", "EGW", "CST", "WHS", "TRS", 
      "HOT", "INF", "FIN", "EST", "ADM", "EDU", "HLT", "ENT"};
 wag = WeightedAdjacencyGraph[vnames, wam, VertexLabels -> "Name", 
     ImageSize -> 250]
 CommunityGraphPlot[wag, FindGraphCommunities[wag]]

Then I delete a vertex from the graph wag and find the communities in the resulting graph:

vdwag = VertexDelete[wag, {"WHS"}]
FindGraphCommunities[vdwag]
 (* {{"OIL", "MA1", "MA2", "TRS", "HOT", "EST", "EDU", "HLT", 
     "ENT"}, {"AGF", "CST", "INF", "ADM"}, {"EGW"}, {"FIN"}} *)

Then I wanted to draw the communities using:

 CommunityGraphPlot[vdwag, FindGraphCommunities[vdwag]]

However, this does not work, although vdwag is a graph. WHY?

Tugrul Temel
  • 6.4k
  • 3
  • 14
  • 33