Example #1
0
def drawCommunityGraph(G, zeta, **kwargs):
    """ Draws the community graph for a given graph and partition. Passes any additional arguments to networkx.draw(...).
	    By default, node sizes are scaled between 30 and 500 by community size.
	"""
    cg = ParallelPartitionCoarsening(G, zeta)
    cg.run()  # convert communities to nodes
    graph = cg.getCoarseGraph()
    comGraph = nxadapter.nk2nx(graph)
    if not "node_size" in kwargs:
        sizes = list(zeta.subsetSizeMap().values())
        max_size = max(sizes)
        sizes = [elem / max_size for elem in sizes]
        kwargs["node_size"] = [30 + 470 * s for s in sizes]
    networkx.draw(comGraph, **kwargs)
Example #2
0
def communityGraph(G, zeta):
	""" Create a community graph, i.e. a graph in which one node represents a community and an edge represents the edges between communities, from a given graph and a community detection solution"""
	cg = ParallelPartitionCoarsening(G, zeta)
	cg.run()
	return cg.getCoarseGraph()
Example #3
0
def communityGraph(G, zeta):
	""" Create a community graph, i.e. a graph in which one node represents a community and an edge represents the edges between communities, from a given graph and a community detection solution"""
	cg = ParallelPartitionCoarsening(G, zeta)
	cg.run()
	return cg.getCoarseGraph()