Ejemplo n.º 1
0
def detectCommunities(G, algo=None, inspect=True):
	""" Perform high-performance community detection on the graph.
		:param    G    the graph
		:param     algorithm    community detection algorithm instance
		:return communities (as type Partition)
		"""
	if algo is None:
		algo = PLM(G, refine=False)
	t = stopwatch.Timer()
	algo.run()
	zeta = algo.getPartition()
	t.stop()
	print("{0} detected communities in {1} [s]".format(algo.toString(), t.elapsed))
	if inspect:
		print ("solution properties:")
		inspectCommunities(zeta, G)
	return zeta
Ejemplo n.º 2
0
def mesoscopicResponseFunction(G, samples=100):
	"""
	"""
	raise NotImplementedError("work in progress")
	m = G.numberOfEdges()
	gammaRangeLow = [math.e**x for x in range(-10, 0)]
	gammaRangeHigh = [math.e**x for x in range(0, math.ceil(math.log(2*m)))]
	gammaRange = gammaRangeLow + gammaRangeHigh
	print(gammaRange)
	nCom = []

	for gamma in gammaRange:
		communityDetector = PLM(G, gamma=gamma)
		communityDetector.run()
		communities = communityDetector.getPartition()
		nCom.append(communities.numberOfSubsets())

	return (gammaRange, nCom)
Ejemplo n.º 3
0
def mesoscopicResponseFunction(G, samples=100):
	"""
	"""
	raise NotImplementedError("work in progress")
	m = G.numberOfEdges()
	gammaRangeLow = [math.e**x for x in range(-10, 0)]
	gammaRangeHigh = [math.e**x for x in range(0, math.ceil(math.log(2*m)))]
	gammaRange = gammaRangeLow + gammaRangeHigh
	print(gammaRange)
	nCom = []

	for gamma in gammaRange:
		communityDetector = PLM(G, gamma=gamma)
		communityDetector.run()
		communities = communityDetector.getPartition()
		nCom.append(communities.numberOfSubsets())

	return (gammaRange, nCom)
Ejemplo n.º 4
0
def detectCommunities(G, algo=None, inspect=True):
	""" Perform high-performance community detection on the graph.
		:param    G    the graph
		:param     algorithm    community detection algorithm instance
		:return communities (as type Partition)
		"""
	if algo is None:
		algo = PLM(G, refine=False)
	t = stopwatch.Timer()
	algo.run()
	zeta = algo.getPartition()
	t.stop()
	print("{0} detected communities in {1} [s]".format(algo.toString(), t.elapsed))
	if inspect:
		print ("solution properties:")
		inspectCommunities(zeta, G)
	return zeta
Ejemplo n.º 5
0
graphID = 0
for graphName in Gset:
    print("graphName ist ", graphName)
    graphFile = graphDir + graphName + '.graph'
    print("graphFile ist ", graphFile)
    start = time.time()
    G = readGraph(graphFile, Format.METIS)
    finish = time.time()
    print("Einlesen von ", graphFile, " dauerte ", finish - start, " Sekunden")
    anzPLM3 = 0
    anzPLM4 = 0
    for seed in range(1, nrSeeds + 1):
        #print("seed ist ", seed)
        start = time.time()
        algo3 = PLM(G, refine=False)
        partition3 = detectCommunities(G, algo3, True)
        partition3.compact()
        finish = time.time()
        print("Ausrechnen von partition3 dauerte ", finish - start,
              " Sekunden")
        start = time.time()
        #algo4 = PLM(G, refine=True, 100)
        algo4 = PLM(G, refine=True)
        partition4 = detectCommunities(G, algo4, True)
        partition4.compact()
        finish = time.time()
        print("Ausrechnen von partition4 dauerte ", finish - start,
              " Sekunden")
        anzPLM3 = anzPLM3 + partition3.upperBound()
        anzPLM4 = anzPLM4 + partition4.upperBound()