@@ -0,0 +1,1649 @@
+%0Aclass MajorClust(object):%0A    def __init__(self, graph):%0A        self.graph = graph%0A%0A    def get_majorclust(self):%0A        reclusters = set()%0A        terminate = False%0A        while not terminate:%0A            terminate = True%0A            for node in self.graph.nodes_iter(data=True):%0A                initial_cluster = node%5B1%5D%5B'cluster'%5D%0A                current_cluster = self._sub_majorclust(node, g)%0A                recluster = (node%5B0%5D, initial_cluster, current_cluster)%0A%0A                # if has not checked, recluster again%0A                if initial_cluster != current_cluster and recluster not in reclusters:%0A                    reclusters.add(recluster)%0A                    node%5B1%5D%5B'cluster'%5D = current_cluster%0A                    terminate = False%0A%0A    def _sub_majorclust(self, node):%0A        # reclustering%0A        visited_neighbor, visited_neigbor_num, neighbor_weights = %7B%7D, %7B%7D, %7B%7D%0A%0A        # observe neighboring edges and nodes%0A        for current_node, neighbor_node, weight in self.graph.edges_iter(%5Bnode%5B0%5D%5D, data='weight'):%0A            neighbor_weights%5Bneighbor_node%5D = weight%0A            visited_neighbor%5Bself.graph.node%5Bneighbor_node%5D%5B'cluster'%5D%5D = %5C%0A                visited_neighbor.get(self.graph.node%5Bneighbor_node%5D%5B'cluster'%5D, 0.0) + weight%5B'weight'%5D%0A%0A        # get the weight%0A        for k, v in visited_neighbor.iteritems():%0A            visited_neigbor_num.setdefault(v, %5B%5D).append(k)%0A%0A        # attach a node to the cluster of majority of neighbor nodes%0A        current_cluster = visited_neigbor_num%5Bmax(visited_neigbor_num)%5D%5B0%5D if visited_neigbor_num else %5C%0A            node%5B1%5D%5B'cluster'%5D%0A%0A        return current_cluster%0A

Add code of MajorClust algorithm