face2face.statistics.null_modell.remove_self_loops¶
-
face2face.statistics.null_modell.
remove_self_loops
(graph)¶ Removes self-loops that occur by using the “configuration_model”-function
Removes self-loops that occur by using the “configuration_model”-function from networkx.
- Parameters
graph (networkX Graph) – A graph with a specified degree sequence. Nodes are labeled based on the imported data set. Graph might contain self loops
- Returns
graph – A graph with a specified degree sequence. Nodes are labeled based on the imported data set. Graph contains no selfloops anymore.
- Return type
networkX Graph
Examples
The
networkx.configuration_model()
function which is being used for the configuration model can lead to self- and parallel edges. As you can see here the functionremove_self_loops()
filters self loops out of the network.>>> degree_sequence_1 = [v[1] for v in test_network.degree] >>> test_model = nx.configuration_model(degree_sequence_1) >>> print(test_model.edges) [(0, 1, 0), (1, 1, 0), (2, 6, 0), (2, 3, 0), (3, 4, 0), (4, 8, 0), (5, 5, 0), (6, 9, 0), (7, 8, 0), (7, 9, 0)] >>> remove_self_loops(test_model) >>> print(test_model.edges) [(0, 1, 0), (2, 6, 0), (2, 3, 0), (3, 4, 0), (4, 8, 0), (6, 9, 0), (7, 8, 0), (7, 9, 0)]
face2face.statistics.null_modell.configuration_model_label_z_score_mixing_matrix