@@ -91,7 +91,7 @@ def build_noisy_circular_graph(
9191 g = nx .Graph ()
9292 g .add_nodes_from (list (range (N )))
9393 for i in range (N ):
94- noise = float ( np .random .normal (mu , sigma , 1 ))
94+ noise = np .random .normal (mu , sigma , 1 )[ 0 ]
9595 if with_noise :
9696 g .add_node (i , attr_name = math .sin ((2 * i * math .pi / N )) + noise )
9797 else :
@@ -107,7 +107,7 @@ def build_noisy_circular_graph(
107107 if i == N - 1 :
108108 g .add_edge (i , 1 )
109109 g .add_edge (N , 0 )
110- noise = float ( np .random .normal (mu , sigma , 1 ))
110+ noise = np .random .normal (mu , sigma , 1 )[ 0 ]
111111 if with_noise :
112112 g .add_node (N , attr_name = math .sin ((2 * N * math .pi / N )) + noise )
113113 else :
@@ -157,7 +157,7 @@ def graph_colors(nx_graph, vmin=0, vmax=7):
157157 plt .subplot (3 , 3 , i + 1 )
158158 g = X0 [i ]
159159 pos = nx .kamada_kawai_layout (g )
160- nx .draw (
160+ nx .draw_networkx (
161161 g ,
162162 pos = pos ,
163163 node_color = graph_colors (g , vmin = - 1 , vmax = 1 ),
@@ -173,7 +173,7 @@ def graph_colors(nx_graph, vmin=0, vmax=7):
173173
174174# %% We compute the barycenter using FGW. Structure matrices are computed using the shortest_path distance in the graph
175175# Features distances are the euclidean distances
176- Cs = [shortest_path (nx .adjacency_matrix (x ).todense ()) for x in X0 ]
176+ Cs = [shortest_path (nx .adjacency_matrix (x ).toarray ()) for x in X0 ]
177177ps = [np .ones (len (x .nodes ())) / len (x .nodes ()) for x in X0 ]
178178Ys = [
179179 np .array ([v for (k , v ) in nx .get_node_attributes (x , "attr_name" ).items ()]).reshape (
@@ -199,7 +199,7 @@ def graph_colors(nx_graph, vmin=0, vmax=7):
199199
200200# %%
201201pos = nx .kamada_kawai_layout (bary )
202- nx .draw (
202+ nx .draw_networkx (
203203 bary , pos = pos , node_color = graph_colors (bary , vmin = - 1 , vmax = 1 ), with_labels = False
204204)
205205plt .suptitle ("Barycenter" , fontsize = 20 )
0 commit comments