def create_community_candidates(graph, subset): """ Creates the community and candidate corresponding to the subset Parameters ---------- graph : a networkx graph subset : a list of nodes Returns ------- cs : a Community corresponding to the subset nodes cand : the coupled outside nodes """ cs = CD.Community() external_nodes = cs.init(graph, subset) cand = CD.Candidates(graph, external_nodes, cs) cs.init_bounds(cand) cand.rework_fringe() return cs, cand
def why_parallel_karate(): """ A plot to explain why the parallel method does not work well on small graphs Could use with some mods """ graph = CD.karate_club_graph() known = CD.karate_known_c() communities = [] candidates = [] for c in known: comm = CD.Community() ext_nodes = comm.init(graph, c) cand = CD.Candidates(graph, ext_nodes, comm) comm.init_bounds(cand) cand.rework_fringe() communities.append(comm) candidates.append(cand) for c, cand in zip(communities, candidates): CD.vis_e_p(graph, c, cand)