1
$\begingroup$

I am playing with weighted Graph and CommunityGraphPlot, and I am considering the following example.

listWeights = {2, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
tab = {UndirectedEdge[3, 1], UndirectedEdge[3, 31], UndirectedEdge[3, 32], UndirectedEdge[3, 33], Table[UndirectedEdge[1, i + 1], {i, 1, 29}]} // Flatten
g = Graph[tab[[All]], EdgeWeight -> Normalize@listWeights]

which reproduce the following Graph

enter image description here

When I use the CommunityGraphPlot to find the communities

CommunityGraphPlot[g, ImageSize -> Full, VertexLabels -> "Name"]

I get

enter image description here

Question: why is the node 2 plotted so far? You can see from the code that it has an unormalized weight of 2, so I was expecting it closest to the node 1.

$\endgroup$
  • $\begingroup$ Please show a minimal example. Do the weights matter in any way? $\endgroup$ – Szabolcs Feb 14 at 9:21
  • $\begingroup$ @Szabolcs thanks for the comment. With minimal examples I don't see this behaviour, otherwise I would have posted the most minimal one :) The weights should matter, no? For example, if I set some 0 weight, then I get a different communities plot, where the nodes that have 0 weight with the node 1 generate a separate community. $\endgroup$ – apt45 Feb 14 at 9:23
  • $\begingroup$ "The weights should matter, no?" Have you actually tried it, or are you just assuming this? I just tried omitting them and it nothing changed. $\endgroup$ – Szabolcs Feb 14 at 9:24
  • $\begingroup$ @Szabolcs try to set listWeights = {0, 1, 1, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; $\endgroup$ – apt45 Feb 14 at 9:27
  • 1
    $\begingroup$ Just be cautious, test instead of just assuming, and if in doubt, ask Wolfram Support ... I have mixed experiences with asking them about this specific topic, and I am very frustrated by the lack of proper documentation on it. If you have questions about IGraph/M, you can ask me (perhaps use the IGraph/M chatroom) $\endgroup$ – Szabolcs Feb 14 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.