コード例 #1
0
 public static void printGraph(Graph hgraph) {
   for (Node n : hgraph.getNodes()) {
     for (Node m : hgraph.getNeighbors(n)) {
       System.out.println(n.getID() + " --> " + m.getID());
     }
     System.out.println();
   }
 }
コード例 #2
0
 public int buildCommunities(Graph hgraph) {
   int[] comStructure = new int[hgraph.getNodeCount()];
   computeModularity(hgraph, structure, comStructure, resolution);
   Set<Integer> communityCount = new HashSet<>();
   int idx = 0;
   for (Node n : hgraph.getNodes()) {
     communityCount.add(comStructure[idx]);
     n.setProperty("communityID", comStructure[idx++]);
   }
   return communityCount.size();
 }