toymodel module¶
- toymodel.create_LFR_graph()[source]¶
- Create an Lancichinetti Fortunato Radicchi (LFR) benchmark graph. - The graph has 500 nodes with specific degree and community size distributions. Community labels are then assigned to the nodes. - Returns:
- A NetworkX graph with community labels assigned to nodes. 
- Return type:
- networkx.Graph 
 
- toymodel.create_SBM_graph()[source]¶
- Create a Stochastic Block Model (SBM) graph with 2 equal size communities. - The sizes of the communities are predefined as 250, 250 (as it is in “Community Detection on Networks with Ricci Flow” by by Chien-Chun Ni et al.). A probability matrix defines the edge probabilities within and across the communities. This function also assigns community labels to the nodes in the graph. - Returns:
- A NetworkX graph with community labels assigned to nodes. 
- Return type:
- networkx.Graph 
 
- toymodel.run_tests()[source]¶
- Run all tests including graph generation, Ricci curvature computation, accuracy checking, and surgery performance. - The function allows the user to choose between generating a Stochastic Block Model (SBM) graph or an LFR benchmark graph. It then computes the Ricci curvature, performs Ricci flow, checks modularity and ARI, and performs edge surgery on the graph. - Returns:
- None 
- Return type:
- None 
 
- toymodel.test_check_accuracy(G)[source]¶
- Compute Modularity and Adjusted Rand Index (ARI) for different edge weight cutoffs. - This function tests the community detection performance by checking modularity and ARI for different cutoff values applied to the graph. - Parameters:
- G (networkx.Graph) – The graph on which the accuracy is tested. 
- Returns:
- Maximum weight, cutoff range, modularity, and ARI values. 
- Return type:
- tuple 
 
- toymodel.test_perform_surgery(G)[source]¶
- Perform edge surgery on the graph by removing edges with weight greater than a given threshold. - The user is prompted to input a threshold value, and edges with weights greater than this threshold are removed from the graph. - Parameters:
- G (networkx.Graph) – The graph on which the surgery is performed. 
 
- toymodel.test_ricci_curvature(G)[source]¶
- Compute Ricci curvature of the given graph using Ollivier-Ricci method. - This function initializes the Ollivier-Ricci curvature calculation on the input graph and computes the Ricci curvature using the Optimal Transport Distance (OTD) method. - Parameters:
- G (networkx.Graph) – The graph to compute the Ricci curvature on. 
- Returns:
- The OllivierRicci instance containing computed Ricci curvature. 
- Return type:
- GraphRicciCurvature.OllivierRicci 
 
- toymodel.test_ricci_flow(orc, iterations)[source]¶
- Compute Ricci flow of the graph using Ollivier-Ricci method. - This function applies the Ricci flow algorithm to the graph and updates the graph’s curvature. - Parameters:
- orc (GraphRicciCurvature.OllivierRicci) – The OllivierRicci instance that has the initial Ricci curvature. 
- Returns:
- The updated graph after applying Ricci flow. 
- Return type:
- networkx.Graph