Degree Model¶
-
class
pygna.degree_model.
DegreeModel
(network_prob: float = 0.5, vip_prob: float = 1, n_nodes: int = 10, vip_percentage: float = 0.1)[source]¶ This class is used to calculate a degree model
-
create_graph
() → None[source]¶ Create a graph from the nodes
Example
>>> dm = DegreeModel() >>> dm.create_graph()
-
set_nodes
(nodes_names: list) → None[source]¶ Set the name of the nodes and calculate the lenght of the list
Parameters: nodes_names – the list with the nodes name Example
>>> nodes = list("A", "B", "C") >>> dm = DegreeModel() >>> dm.set_nodes(nodes)
-
-
pygna.degree_model.
generate_graph_vip
(n_nodes: int, n_vip: int, network_prob: float = 0.5, vip_prob: float = 1, node_names: list = None) → networkx.classes.graph.Graph[source]¶ This function creates a graph with n_nodes number of vertices and a matrix block_model that describes the intra e inter-block connectivity. The nodes_in_block is parameter, list, to control the number of nodes in each cluster
Parameters: - n_nodes – number of nodes in the network
- n_vip – number of VIP to create
- network_prob – probability of connection in the network
- vip_prob – probability of connection of the vip
- node_names – list of nodes for the network
Example
>>> n_nodes = 100 >>> n_vip = 10 >>> network_prob = 0.5 >>> vip_prob = 1 >>> nodes = ["A", "B", "C"] >>> graph = generate_graph_vip(n_nodes, n_vip, network_prob=network_prob, vip_prob=vip_prob, node_names=nodes)
-
pygna.degree_model.
plot_vip_graph
(graph: networkx.classes.graph.Graph, output_folder: str = None) → None[source]¶ Plot the VIP graph in the specific folder
Parameters: - graph – the graph to plot
- output_folder – the folder path where to save the file
Example
>>> g = nx.complete_graph(100) >>> plot_vip_graph(g, "./")
-
pygna.degree_model.
plot_adjacency
(graph: networkx.classes.graph.Graph, output_folder: str, prefix: str) → None[source]¶ Plot the adjacency matrix on file
Parameters: - graph – the graph to plot
- output_folder – the folder where to save the file
- prefix – the prefix to give to the file
Example
>>> g = nx.complete_graph(100) >>> plot_adjacency(g, "./","adj_matrix_")