Skip to content

Commit 20aac56

Browse files
authored
Update principal_feature_analysis.py
1 parent 3c5f507 commit 20aac56

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

src/parallel_principal_feature_analysis/principal_feature_analysis.py

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -89,36 +89,35 @@ def principal_feature_analysis(cluster_size,data,number_output_functions,freq_da
8989

9090

9191
idx = 0
92-
set_nodes_to_delete = []
93-
92+
9493
set_nodes_to_delete = pool.map(nx.minimum_node_cut, list_graphs_to_divide)
9594
assert len(set_nodes_to_delete) == len(list_graphs_to_divide)
9695

97-
9896
global_list_graphs_to_divide = list_graphs_to_divide.copy()
99-
window = len(list_graphs_to_divide)
100-
while list_graphs_to_divide!=[]:
97+
window = len(set_nodes_to_delete)
98+
99+
if list_graphs_to_divide!=[]:
101100
any_cluster_dissected=1
102101

103-
for current_graph in list_graphs_to_divide:
104-
print(str(len(set_nodes_to_delete[idx])) + " nodes removed!")
105-
list_graphs_to_divide.remove(current_graph)
106-
for node in list(set_nodes_to_delete[idx]):
107-
current_graph.remove_node(node) # remove the nodes that were found with the minimum cut algorithm
108-
list_new_sub_graphs = [current_graph.subgraph(c).copy() for c in nx.connected_components(current_graph)]
109-
# Sort the new subgraphs into a list of complete subgraphs and subgraphs that can be further divided
110-
for sub_graph_of_current_graph in list_new_sub_graphs:
111-
if list(nx.complement(sub_graph_of_current_graph).edges)!=[]:
112-
list_graphs_to_divide.append(sub_graph_of_current_graph)
113-
global_list_graphs_to_divide.append(sub_graph_of_current_graph)
114-
else:
115-
list_complete_sub_graphs.append(sub_graph_of_current_graph)
116-
list_nodes_complete_sub_graphs.append(list(sub_graph_of_current_graph.nodes))
117-
idx += 1
118-
119-
if idx >= window:
120-
window = len(set_nodes_to_delete)
121-
set_nodes_to_delete += pool.map(nx.minimum_node_cut, global_list_graphs_to_divide[idx:])
102+
for current_graph in list_graphs_to_divide:
103+
print(str(len(set_nodes_to_delete[idx])) + " nodes removed!")
104+
105+
for node in list(set_nodes_to_delete[idx]):
106+
current_graph.remove_node(node) # remove the nodes that were found with the minimum cut algorithm
107+
list_new_sub_graphs = [current_graph.subgraph(c).copy() for c in nx.connected_components(current_graph)]
108+
# Sort the new subgraphs into a list of complete subgraphs and subgraphs that can be further divided
109+
for sub_graph_of_current_graph in list_new_sub_graphs:
110+
if list(nx.complement(sub_graph_of_current_graph).edges)!=[]:
111+
list_graphs_to_divide.append(sub_graph_of_current_graph)
112+
global_list_graphs_to_divide.append(sub_graph_of_current_graph)
113+
else:
114+
list_complete_sub_graphs.append(sub_graph_of_current_graph)
115+
list_nodes_complete_sub_graphs.append(list(sub_graph_of_current_graph.nodes))
116+
idx += 1
117+
118+
if idx >= window:
119+
set_nodes_to_delete += pool.map(nx.minimum_node_cut, global_list_graphs_to_divide[idx:])
120+
window = len(set_nodes_to_delete)
122121

123122

124123

0 commit comments

Comments
 (0)