def __init__(self, changeEdges=10, numGraphs=100, numClusterVertices=50, numClusters=3, p=0.3): 
        self.changeEdges = changeEdges 
        self.numGraphs = numGraphs
        self.graphInd = 0
        self.numClusters = numClusters 
        self.realClustering = numpy.zeros(numClusterVertices*numClusters)
        generator = ErdosRenyiGenerator(p)
        
        clusterList = []
        for i in range(numClusters):  
            cluster = SparseGraph(GeneralVertexList(numClusterVertices))
            cluster = generator.generate2(cluster)
            clusterList.append(cluster)
            
            self.realClustering[numClusterVertices*i:(i+1)*numClusterVertices] = i

        self.graph = clusterList[0]
        for i in range(1, len(clusterList)): 
            self.graph = self.graph.concat(clusterList[i])
Example #2
0
def print_Eros(vertex, p):
    graph = SparseGraph(VertexList(vertex, 0))
    #graph = AbstractMatrixGraph()
    generator = ErdosRenyiGenerator(p)
    graphER = generator.generate2(graph)
    result = graphER.adjacencyList()
    print graphER

    newdic = {}
    cnt = 0
    for i in result[0]:
        #print "I value = ", i
        newdic[cnt] = set(i)
        cnt+=1
 
    newgra = dergee(newdic) 
    #print "NEWGRA = ", newgra
    #plt.subplot(212)
    #plt.loglog(newgra[0], newgra[1], 'ro', markersize=3, basex=2)
    return newdic