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

Refactorings Code and Adding Node Filter

parent cd935194
No related branches found
No related tags found
1 merge request!1Adding new methods and the consensual backbone
...@@ -45,7 +45,6 @@ def fraction_filter(backbone, value, narrate=True, secondary_property='weight', ...@@ -45,7 +45,6 @@ def fraction_filter(backbone, value, narrate=True, secondary_property='weight',
filter_by = [backbone.property_name] filter_by = [backbone.property_name]
ascending = [backbone.ascending] ascending = [backbone.ascending]
value = math.ceil(value * len(data))
if backbone.filter_on == 'Edges': if backbone.filter_on == 'Edges':
filter_by.append(secondary_property) filter_by.append(secondary_property)
...@@ -58,9 +57,11 @@ def fraction_filter(backbone, value, narrate=True, secondary_property='weight', ...@@ -58,9 +57,11 @@ def fraction_filter(backbone, value, narrate=True, secondary_property='weight',
backbone.narrate() backbone.narrate()
if backbone.filter_on == 'Edges': if backbone.filter_on == 'Edges':
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:
b = backbone.graph.copy() b = backbone.graph.copy()
value = math.ceil(value * len(backbone.graph))
b.remove_nodes_from(list(data[:value].index)) b.remove_nodes_from(list(data[:value].index))
return b return b
......
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