def simple_test(): """run simple test""" with open("sbm_graph.pkl", "rb") as pickle_file: graph = pickle.load(pickle_file) all_results = run(graph) plotting.plot_scan(all_results, use_plotly=False) plotting.plot_scan(all_results, use_plotly=True, live=False) with open("sbm_graph.gpickle", "rb") as pickle_file: graph = pickle.load(pickle_file) plotting.plot_communities(graph, all_results)
def simple_test(): """run simple test""" with open("sbm_graph.pkl", "rb") as pickle_file: graph = pickle.load(pickle_file) all_results = run(graph, n_time=50) all_results = identify_optimal_scales(all_results, window=2, beta=0.1) plot_optimal_scales(all_results, use_plotly=True) plt.show() with open("sbm_graph.gpickle", "rb") as pickle_file: graph = pickle.load(pickle_file) plotting.plot_communities(graph, all_results)
def cluster_signed_modularity( graph, times, kappas, kappa0=None, n_louvain=10, with_VI=True, n_louvain_VI=10, with_postprocessing=True, with_ttprime=True, n_workers=1, tqdm_disable=False, ): """Cluster using signed modularity of Gomez, Jensen, Arenas PRE 2009. Args: graph (networkx): graph to cluster times (list): markov times to consider kappas (list): list of corresponding Kappa matrices kappa0 (float): shift of kappa via the null model n_louvain (int): number of Louvain evaluations with_VI (bool): compute the variatio of information between Louvain runs n_louvain_VI (int): number of randomly chosen Louvain run to estimate VI with_postprocessing (bool): apply the final postprocessing step with_ttprime (bool): compute the ttprime matrix n_workers (int): number of workers for multiprocessing tqdm_disable (bool): disable progress bars """ return run( graph=None, constructor=constructor( nx.adjacency_matrix(graph, weight="weight"), kappa0=kappa0, kappas=kappas, time_dict={time: i for i, time in enumerate(times)}, row=np.array([e[0] for e in graph.edges]), col=np.array([e[1] for e in graph.edges]), ), times=times, n_louvain=n_louvain, with_VI=with_VI, n_louvain_VI=n_louvain_VI, with_postprocessing=with_postprocessing, with_ttprime=with_ttprime, n_workers=n_workers, tqdm_disable=tqdm_disable, )