Exemple #1
0
 def getClassSets(self, nodes):
     """
     Returns a NodeFamily of the node classes 
     """
     cmap = {1: [], 2: [], 3: []}
     for node in nodes:
         cmap[self.getClass(node)].append(node)
     return communities.NodeFamily(cmap)
Exemple #2
0
def detectCommunities(net,alpha,useStrength=True):
    todo=set(list(net))
    cmap={}
    while len(todo)>0:
        node=todo.pop()
        print "Nodes left: "+str(len(todo))+" now processing node: "+ str(node)
        com=detectCommunityForNode(net,alpha,node,useStrength)
        todo=todo-set(com)
        cmap[node]=com
    return communities.NodeFamily(cmap)
Exemple #3
0
    def getLocationSets(self, nodes):
        """
        Returns a NodeFamily of the node classes 
        """

        cmap = {}
        for ln in range(1, len(self.name) + 1):
            cmap[ln] = []
        for node in nodes:
            cmap[self.getLocation(node)].append(node)
        return communities.NodeFamily(cmap)