Skip to content
Snippets Groups Projects
Commit ecd1c411 authored by Yassin's avatar Yassin
Browse files

Refactorings Code and Adding Node Filter

parent 7821ad1e
No related branches found
No related tags found
1 merge request!1Adding new methods and the consensual backbone
...@@ -60,8 +60,12 @@ def fraction_filter(backbone, value, narrate=True, secondary_property='weight', ...@@ -60,8 +60,12 @@ def fraction_filter(backbone, value, narrate=True, secondary_property='weight',
value = math.ceil(value * len(data)) value = math.ceil(value * len(data))
return nx.from_pandas_edgelist(data[:value], edge_attr=edge_properties(data)) return nx.from_pandas_edgelist(data[:value], edge_attr=edge_properties(data))
else: else:
print('hereeeeeeee')
b = backbone.graph.copy() b = backbone.graph.copy()
value = math.ceil(value * len(backbone.graph)) value = math.ceil(value * len(backbone.graph))
print(value)
b.remove_nodes_from(list(data[:value].index)) b.remove_nodes_from(list(data[:value].index))
return b return b
......
...@@ -67,7 +67,7 @@ def modularity_backbone(data): ...@@ -67,7 +67,7 @@ def modularity_backbone(data):
vitalities = (modularity_value - q1s).tolist() vitalities = (modularity_value - q1s).tolist()
nx.set_node_attributes(g, dict(zip(list(g.nodes()), np.absolute(vitalities))), name='score') nx.set_node_attributes(g, dict(zip(list(g.nodes()), np.absolute(vitalities))), name='vitality')
return Backbone(g, method_name="Modularity Filter", property_name='score', ascending=False, return Backbone(g, method_name="Modularity Filter", property_name='vitality', ascending=False,
compatible_filters=[threshold_filter, fraction_filter], filter_on='Nodes') compatible_filters=[threshold_filter, fraction_filter], filter_on='Nodes')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment