45
45
import ot
46
46
import networkx
47
47
from networkx .generators .community import stochastic_block_model as sbm
48
- # %%
49
- # =============================================================================
48
+
49
+ #############################################################################
50
+ #
50
51
# Generate a dataset composed of graphs following Stochastic Block models of 1, 2 and 3 clusters.
51
- # =============================================================================
52
+ # ---------------------------------------------
52
53
53
54
np .random .seed (42 )
54
55
@@ -109,10 +110,10 @@ def plot_graph(x, C, binary=True, color='C0', s=None):
109
110
pl .tight_layout ()
110
111
pl .show ()
111
112
112
- # %%
113
- # =============================================================================
113
+ #############################################################################
114
+ #
114
115
# Estimate the gromov-wasserstein dictionary from the dataset
115
- # =============================================================================
116
+ # ---------------------------------------------
116
117
117
118
118
119
np .random .seed (0 )
@@ -140,10 +141,10 @@ def plot_graph(x, C, binary=True, color='C0', s=None):
140
141
pl .tight_layout ()
141
142
pl .show ()
142
143
143
- # %%
144
- # =============================================================================
144
+ #############################################################################
145
+ #
145
146
# Visualization of the estimated dictionary atoms
146
- # =============================================================================
147
+ # ---------------------------------------------
147
148
148
149
149
150
# Continuous connections between nodes of the atoms are colored in shades of grey (1: dark / 2: white)
@@ -164,10 +165,11 @@ def plot_graph(x, C, binary=True, color='C0', s=None):
164
165
pl .axis ("off" )
165
166
pl .tight_layout ()
166
167
pl .show ()
167
- #%%
168
- # =============================================================================
168
+
169
+ #############################################################################
170
+ #
169
171
# Visualization of the embedding space
170
- # =============================================================================
172
+ # ---------------------------------------------
171
173
172
174
unmixings = []
173
175
reconstruction_errors = []
@@ -211,11 +213,11 @@ def plot_graph(x, C, binary=True, color='C0', s=None):
211
213
pl .legend (fontsize = 11 )
212
214
pl .tight_layout ()
213
215
pl .show ()
214
- # %%
215
- # =============================================================================
216
- # Endow the dataset with node features
217
- # =============================================================================
218
216
217
+ #############################################################################
218
+ #
219
+ # Endow the dataset with node features
220
+ # ---------------------------------------------
219
221
# We follow this feature assignment on all nodes of a graph depending on its label/number of clusters
220
222
# 1 cluster --> 0 as nodes feature
221
223
# 2 clusters --> 1 as nodes feature
@@ -251,10 +253,11 @@ def plot_graph(x, C, binary=True, color='C0', s=None):
251
253
pl .axis ("off" )
252
254
pl .tight_layout ()
253
255
pl .show ()
254
- # %%
255
- # =============================================================================
256
+
257
+ #############################################################################
258
+ #
256
259
# Estimate a Fused Gromov-Wasserstein dictionary from the dataset of attributed graphs
257
- # =============================================================================
260
+ # ---------------------------------------------
258
261
np .random .seed (0 )
259
262
ps = [ot .unif (C .shape [0 ]) for C in dataset ]
260
263
D = 3 # 6 atoms instead of 3
@@ -280,10 +283,10 @@ def plot_graph(x, C, binary=True, color='C0', s=None):
280
283
pl .tight_layout ()
281
284
pl .show ()
282
285
283
- # %%
284
- # =============================================================================
286
+ #############################################################################
287
+ #
285
288
# Visualization of the estimated dictionary atoms
286
- # =============================================================================
289
+ # ---------------------------------------------
287
290
288
291
pl .figure (7 , (12 , 8 ))
289
292
pl .clf ()
@@ -307,10 +310,10 @@ def plot_graph(x, C, binary=True, color='C0', s=None):
307
310
pl .tight_layout ()
308
311
pl .show ()
309
312
310
- # %%
311
- # =============================================================================
313
+ #############################################################################
314
+ #
312
315
# Visualization of the embedding space
313
- # =============================================================================
316
+ # ---------------------------------------------
314
317
315
318
unmixings = []
316
319
reconstruction_errors = []
0 commit comments