@@ -44,17 +44,17 @@ def gen_gexf_and_pass_partition_data(
4444 cooccur_matrix = matrix .get ('cooccur_matrix' )
4545
4646 # Get Graph
47- G = nx .from_pandas_adjacency (cooccur_matrix )
47+ graph = nx .from_pandas_adjacency (cooccur_matrix )
4848
4949 # Get Sub Data
5050 sub_data = get_sub_data (
51- graph = G ,
51+ graph = graph ,
5252 node_num = node_num ,
5353 edge_remove_threshold = edge_remove_threshold ,
5454 remove_isolated_node = remove_isolated_node ,
5555 matrix = matrix
5656 )
57- sub_G = sub_data .get ('sub_graph' )
57+ sub_graph = sub_data .get ('sub_graph' )
5858 tf_sum_dict_sorted = sub_data .get ('tf_sum_dict_sorted' )
5959
6060 # ------ Set Attributes for gexf file ------ #
@@ -69,24 +69,24 @@ def gen_gexf_and_pass_partition_data(
6969 scaled_weight_dict = dict (scaled_weight_list )
7070
7171 for node in scaled_weight_dict :
72- sub_G .nodes [node ]['viz' ] = {'size' : scaled_weight_dict [node ]}
72+ sub_graph .nodes [node ]['viz' ] = {'size' : scaled_weight_dict [node ]}
7373
7474 # Add edge weight
75- edge_weight_max = max ([sub_G [u ][v ]['weight' ] for u , v in sub_G .edges ])
76- for u , v in sub_G .edges :
77- sub_G [u ][v ]['viz' ] = {'thickness' : sub_G [u ][v ]['weight' ] * 35 / edge_weight_max }
75+ edge_weight_max = max ([sub_graph [u ][v ]['weight' ] for u , v in sub_graph .edges ])
76+ for u , v in sub_graph .edges :
77+ sub_graph [u ][v ]['viz' ] = {'thickness' : sub_graph [u ][v ]['weight' ] * 35 / edge_weight_max }
7878
7979 # ------ Set Layout ------ #
8080 # Fruchterman Reingold
8181 if layout == "fr" :
82- pos = nx .spring_layout (sub_G , k = fr_k , iterations = iterations )
82+ pos = nx .spring_layout (sub_graph , k = fr_k , iterations = iterations )
8383 for node in pos :
84- sub_G .nodes [node ]['viz' ]['position' ] = {'x' : pos [node ][0 ], 'y' : pos [node ][1 ]}
84+ sub_graph .nodes [node ]['viz' ]['position' ] = {'x' : pos [node ][0 ], 'y' : pos [node ][1 ]}
8585
8686 # ForceAtlas2
8787 elif layout == "fa2" :
8888 forceatlas2 = ForceAtlas2 ()
89- pos = forceatlas2 .forceatlas2_networkx_layout (sub_G , iterations = iterations )
89+ pos = forceatlas2 .forceatlas2_networkx_layout (sub_graph , iterations = iterations )
9090
9191 for node in pos :
9292 raw_x , raw_y = pos [node ]
@@ -95,14 +95,14 @@ def gen_gexf_and_pass_partition_data(
9595 if raw_x < 0 : adj_x *= - 1
9696 if raw_y < 0 : adj_y *= - 1
9797 # ----------------- #
98- sub_G .nodes [node ]['viz' ]['position' ] = {'x' : adj_x , 'y' : adj_y }
98+ sub_graph .nodes [node ]['viz' ]['position' ] = {'x' : adj_x , 'y' : adj_y }
9999 # -------------------------- #
100100
101101 # Generate gexf file
102- write_gexf (graph = sub_G )
102+ write_gexf (graph = sub_graph )
103103
104104 # ------ Pass partition data to template ------ #
105- partition = community .best_partition (sub_G )
105+ partition = community .best_partition (sub_graph )
106106 partition_len = max (partition .values ()) + 1
107107 node_freq_per_klass = {n : list () for n in range (partition_len )}
108108 for node , klass in partition .items ():
0 commit comments