cdlib.ensemble.pool¶
- cdlib.ensemble.pool(graph: Graph, methods: Callable[[Graph, dict], object], configurations: list) tuple¶
在输入图上执行社区发现内部池。
- Parameters:
methods – 列出社区发现方法(来自nclib.community)
graph – networkx/igraph 对象
配置 – 由Parameter和BoolParameter对象组成的列表的列表(每个方法一个)
- Returns:
每次调用时,生成器都会生成一个由以下内容组成的元组:实际方法、其当前配置和获得的社区
- Raises:
ValueError – 如果方法的数量与指定的配置数量不同
- Example:
>>> 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)