grid_execution(graph: <Mock id='140361405498608'>, method: Callable[[<Mock id='140361405509600'>, dict], object], parameters: list) → tuple

Instantiate the specified community discovery method performing a grid search on the parameter set.

  • method – community discovery method (from
  • graph – networkx/igraph object
  • parameters – list of Parameter and BoolParameter objects

at each call the generator yields a tuple composed by the current configuration and the obtained communities

>>> import networkx as nx
>>> from cdlib import algorithms, ensemble
>>> g = nx.karate_club_graph()
>>> resolution = ensemble.Parameter(name="resolution", start=0.1, end=1, step=0.1)
>>> for communities in ensemble.grid_execution(graph=g, method=algorithms.louvain, parameters=[resolution]):
>>>     print(communities)