The following code generates two distinct community structures: one uses a simple adjacency matrix (with 1 and 0), another uses a weighted adjacency graph (with positive real numbers). I like to know which Algorithms Mathematica implements in each case, and where they are documented (references to articles). This answer gives a relevant explanation for my question but it does not give any reference explaining the method. There must be a reference to algorithms implemented!

ClearAll[mat, g, wmat, wag];


(* communities from an unweighted adjacency graph *)
mat = RandomInteger[{0, 1}, {25, 25}];
g = AdjacencyGraph[mat /. (0. -> Infinity), VertexLabels -> "Name"];

(* communities from a weighted adjacency graph *)
wmat = (mat*RandomReal[{1, 5}, {25, 25}]) /. (0. -> Infinity);
wag = WeightedAdjacencyGraph[wmat, DirectedEdges -> True, 
   VertexLabels -> "Name"];

Row[{CommunityGraphPlot[g, ImageSize -> 350], 
  CommunityGraphPlot[wag, ImageSize -> 350]}]

In the following link S. Horvat was also raising the same question like mine:


  • 1
    $\begingroup$ Why don't you use IGraph/M? All the community detection algorithms have references, and the code is open. $\endgroup$
    – Szabolcs
    Nov 13, 2023 at 18:28


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.