Given the matrix wam:
wam={
{∞, ∞, ∞, ∞, ∞, ∞, 0.180744, ∞, ∞, ∞, ∞, ∞, 0.196146, ∞, ∞, 0.192559},
{∞, ∞, 0.199743, 0.189167, ∞, 0.177828, 0.136293, 0.198179,
0.170862, ∞, ∞, 0.150103, 0.152068, ∞, 0.145293, 0.147801},
{∞, 0.17492, ∞, ∞, ∞, ∞, ∞, 0.196928, ∞, 0.18818, ∞, ∞, ∞, ∞, ∞, ∞},
{∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞},
{∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞},
{∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞},
{0.164114, 0.189904, ∞, ∞, ∞, 0.142879, ∞, 0.173485, ∞, 0.195519, ∞,
0.179716, 0.152131, ∞, ∞, 0.197488},
{0.193476, 0.186542, ∞, 0.196847, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞,
0.184613, ∞, 0.195341, 0.190637},
{∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞},
{0.17967, ∞, ∞, ∞, ∞, 0.165566, ∞, ∞, ∞, ∞, ∞, ∞, 0.16862, ∞, ∞, ∞},
{∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞},
{∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞},
{∞, ∞, ∞, ∞, ∞, 0.183951, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞, ∞},
{∞, ∞, ∞, ∞, ∞, 0.189936, 0.16593, 0.197014, ∞, ∞, ∞, 0.194794, ∞, ∞, ∞, ∞},
{0.189579, 0.167198, ∞, ∞, ∞, 0.18947, ∞, ∞, ∞, 0.187049, ∞, ∞, ∞, ∞, ∞, ∞},
{∞, 0.149854, ∞, ∞, ∞, 0.188494, 0.150641, 0.192737, 0.194964, ∞, ∞, ∞,
0.14314, 0.15716, 0.14968, ∞}
};
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?





Graph. Ideally, use 12.2. – Szabolcs Feb 14 '21 at 16:56EdgeWeights are not properly modified byVertexDelete. A workaround: useEdgeDelete, that is, tryedwag = EdgeDelete[wag, DirectedEdge["WHS", _] | DirectedEdge[_, "WHS"]]– kglr Feb 14 '21 at 17:05IGWeightedVertexDeletewhich can handle weighted graphs properly in v11.3 as well. But it will discard all edge properties except weights. There is alsoIGTakeSubgraph, which handles all properties correctly in versions prior to 12.0 as well, but it is very slow. – Szabolcs Feb 14 '21 at 17:21IGWeightedAdjacencyGraphandIGWeightedAdjacencyMatrixwhich are actually consistent with each other in the handling of zeros and infinities, unlike the builtinWeightedAdjacencyMatrixandWeightedAdjacencyGraph. – Szabolcs Feb 14 '21 at 17:22FindGraphCommunities– Szabolcs Feb 14 '21 at 17:25IGWeightedVertexDelete[wag, {"WHS"}, VertexLabels -> "Name"]and it works as I expect it. The resulting directed graph seems to be identical to one @kglr presented. For now, I solved the problem with by @kglr's answer and also byIGraph. Thanks to you. and @kglr. – Tugrul Temel Feb 14 '21 at 17:37wamhow did you insertInfinitysign? If I had known how to do it, I would have used the mathematical sign when posting the question. Maybe you have a special program for it. – Tugrul Temel Feb 14 '21 at 18:26