pool(graph, methods, configurations)¶
Execute on a pool of community discovery internal on the input graph.
- methods – list community discovery methods (from nclib.community)
- graph – networkx/igraph object
- configurations – list of lists (one for each method) of Parameter and BoolParameter objects
at each call the generator yields a tuple composed by: the actual method, its current configuration and the obtained communities
ValueError – if the number of methods is different from the number of configurations specified
>>> import networkx as nx >>> from cdlib import algorithms, ensemble >>> g = nx.karate_club_graph() >>> # Louvain >>> resolution = ensemble.Parameter(name="resolution", start=0.1, end=1, step=0.1) >>> randomize = ensemble.BoolParameter(name="randomize") >>> louvain_conf = [resolution, randomize] >>> >>> # Angel >>> threshold = ensemble.Parameter(name="threshold", start=0.1, end=1, step=0.1) >>> angel_conf = [threshold] >>> >>> methods = [algorithms.louvain, algorithms.angel] >>> >>> for communities in ensemble.pool(g, methods, [louvain_conf, angel_conf]): >>> print(communities)