Skip to content

Commit e5c4711

Browse files
fix solvers
1 parent 513911d commit e5c4711

File tree

5 files changed

+428
-17
lines changed

5 files changed

+428
-17
lines changed

examples/gromov/plot_barycenter_fgw.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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]
177177
ps = [np.ones(len(x.nodes())) / len(x.nodes()) for x in X0]
178178
Ys = [
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
# %%
201201
pos = 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
)
205205
plt.suptitle("Barycenter", fontsize=20)

0 commit comments

Comments
 (0)