Exemplo n.º 1
0
 def getCommStruct(self):
     cs = self.ktree.getCommStruct()
     newcs = communities.NodeCover()
     for c in cs:
         newc = []
         for node in c:
             newc.append(self.nodeIndex.getReverse(node))
         newcs._addCommunity(newc)
         #newcs.comm.append(newc)
     return newcs
Exemplo n.º 2
0
    def getCommStruct(self, separateElements=True):
        communityMap = {}
        if self.mappingOn:
            nodes = self.ktree
        else:
            nodes = range(0, len(self.ktree))

        for node in nodes:
            communityKey = self.getParent(node)
            if separateElements or communityKey != node:
                if communityKey not in communityMap:
                    communityMap[communityKey] = [node]
                else:
                    communityMap[communityKey].append(node)

        return communities.NodeCover(communityMap)