-
Notifications
You must be signed in to change notification settings - Fork 17
/
GenerateIGData.nb
402 lines (375 loc) · 13.5 KB
/
GenerateIGData.nb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
Notebook[{
Cell[BoxData[
RowBox[{"Needs", "[", "\"\<IGraphM`\>\"", "]"}]], "Input",
CellLabel->"In[56]:=",ExpressionUUID->"df6af029-314a-42b3-8404-6071dee0ccd0"],
Cell[BoxData[
RowBox[{
RowBox[{"toMat", "[",
RowBox[{"vec_", ",", "n_"}], "]"}], ":=",
RowBox[{"SparseArray", "@",
RowBox[{"Partition", "[",
RowBox[{
RowBox[{"Flatten", "@",
RowBox[{"Riffle", "[",
RowBox[{
RowBox[{"Partition", "[",
RowBox[{"vec", ",", "n"}], "]"}], ",", "0", ",",
RowBox[{"{",
RowBox[{"1", ",",
RowBox[{"-", "1"}], ",", "2"}], "}"}]}], "]"}]}], ",", "n"}],
"]"}]}]}]], "Input",
CellChangeTimes->{{3.675143799751005*^9, 3.675143849046874*^9}, {
3.6751438794092607`*^9, 3.675143944286613*^9}, {3.675144162840683*^9,
3.675144164761527*^9}},
CellLabel->"In[57]:=",ExpressionUUID->"39ab1fe9-9aa2-410e-9e88-9a9b105cbaff"],
Cell[BoxData[
RowBox[{
RowBox[{"toMatU", "[",
RowBox[{"vec_", ",", "n_"}], "]"}], ":=", "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"#", "+",
RowBox[{"Transpose", "[", "#", "]"}]}], "&"}], "@",
RowBox[{"Prepend", "[", "\[IndentingNewLine]",
RowBox[{
RowBox[{"Table", "[", "\[IndentingNewLine]",
RowBox[{
RowBox[{"PadRight", "[", "\[IndentingNewLine]",
RowBox[{
RowBox[{"Part", "[",
RowBox[{"vec", ",",
RowBox[{
RowBox[{"(",
RowBox[{"1", "+",
RowBox[{"k",
RowBox[{
RowBox[{"(",
RowBox[{"k", "-", "1"}], ")"}], "/", "2"}]}]}], ")"}], ";;",
RowBox[{"(",
RowBox[{"k",
RowBox[{
RowBox[{"(",
RowBox[{"k", "+", "1"}], ")"}], "/", "2"}]}], ")"}]}]}],
"]"}], ",", "\[IndentingNewLine]", "n"}], "\[IndentingNewLine]",
"]"}], "\[IndentingNewLine]", ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{"k", ",",
RowBox[{"n", "-", "1"}]}], "}"}]}], "\[IndentingNewLine]", "]"}],
",", "\[IndentingNewLine]",
RowBox[{"ConstantArray", "[",
RowBox[{"0", ",", "n"}], "]"}]}], "\[IndentingNewLine]",
"]"}]}]}]], "Input",
CellChangeTimes->{{3.678171532445856*^9, 3.678171598859295*^9}, {
3.67817164106927*^9, 3.678171796222328*^9}},
CellLabel->"In[58]:=",ExpressionUUID->"db5e4072-54ca-470d-b6cd-bce4bf8c2a71"],
Cell[BoxData[
RowBox[{
RowBox[{"allDirectedGraphs", "[", "n_", "]"}], ":=", "\[IndentingNewLine]",
RowBox[{"Module", "[",
RowBox[{
RowBox[{"{", "graphs", "}"}], ",", "\[IndentingNewLine]",
RowBox[{
RowBox[{"graphs", "=",
RowBox[{
RowBox[{
RowBox[{"AdjacencyGraph", "[",
RowBox[{
RowBox[{"toMat", "[",
RowBox[{"#", ",", "n"}], "]"}], ",",
RowBox[{"DirectedEdges", "\[Rule]", "True"}]}], "]"}], "&"}], "/@",
RowBox[{"IntegerDigits", "[",
RowBox[{
RowBox[{
RowBox[{"Range", "[",
RowBox[{"2", "^",
RowBox[{"(",
RowBox[{"n", "*",
RowBox[{"(",
RowBox[{"n", "-", "1"}], ")"}]}], ")"}]}], "]"}], "-", "1"}],
",", "2", ",",
RowBox[{"n", "*",
RowBox[{"(",
RowBox[{"n", "-", "1"}], ")"}]}]}], "]"}]}]}], ";",
"\[IndentingNewLine]",
RowBox[{"DeleteDuplicatesBy", "[",
RowBox[{"graphs", ",", "CanonicalGraph"}], "]"}]}]}],
"\[IndentingNewLine]", "]"}]}]], "Input",
CellChangeTimes->{{3.6751445951220512`*^9, 3.675144633474648*^9},
3.675144838053624*^9},
CellLabel->"In[59]:=",ExpressionUUID->"f10201d9-c287-4b10-9e65-23b19849dcac"],
Cell[BoxData[
RowBox[{
RowBox[{"allUndirectedGraphs", "[", "n_", "]"}], ":=",
"\[IndentingNewLine]",
RowBox[{"Module", "[",
RowBox[{
RowBox[{"{", "graphs", "}"}], ",", "\[IndentingNewLine]",
RowBox[{
RowBox[{"graphs", "=",
RowBox[{
RowBox[{
RowBox[{"AdjacencyGraph", "[",
RowBox[{"toMatU", "[",
RowBox[{"#", ",", "n"}], "]"}], "]"}], "&"}], "/@",
RowBox[{"IntegerDigits", "[",
RowBox[{
RowBox[{
RowBox[{"Range", "[",
RowBox[{"2", "^",
RowBox[{"(",
RowBox[{"n", "*",
RowBox[{
RowBox[{"(",
RowBox[{"n", "-", "1"}], ")"}], "/", "2"}]}], ")"}]}], "]"}],
"-", "1"}], ",", "2", ",",
RowBox[{"n", "*",
RowBox[{
RowBox[{"(",
RowBox[{"n", "-", "1"}], ")"}], "/", "2"}]}]}], "]"}]}]}], ";",
"\[IndentingNewLine]",
RowBox[{"DeleteDuplicatesBy", "[",
RowBox[{"graphs", ",", "CanonicalGraph"}], "]"}]}]}],
"\[IndentingNewLine]", "]"}]}]], "Input",
CellLabel->"In[60]:=",ExpressionUUID->"25d89d32-d1d8-4226-bd0f-c746d3cfadc4"],
Cell[CellGroupData[{
Cell[BoxData[{
RowBox[{
RowBox[{
RowBox[{"m2", "=",
RowBox[{
RowBox[{
RowBox[{"Graph", "[",
RowBox[{"#", ",",
RowBox[{"VertexCoordinates", "\[Rule]",
RowBox[{"CirclePoints", "[", "2", "]"}]}]}], "]"}], "&"}], "/@",
RowBox[{"SortBy", "[",
RowBox[{
RowBox[{"allDirectedGraphs", "[", "2", "]"}], ",", "EdgeCount"}],
"]"}]}]}], ";"}], "//", "AbsoluteTiming"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"m3", "=",
RowBox[{
RowBox[{
RowBox[{"Graph", "[",
RowBox[{"#", ",",
RowBox[{"VertexCoordinates", "\[Rule]",
RowBox[{"CirclePoints", "[", "3", "]"}]}]}], "]"}], "&"}], "/@",
RowBox[{"SortBy", "[",
RowBox[{
RowBox[{"allDirectedGraphs", "[", "3", "]"}], ",", "IGIsoclass"}],
"]"}]}]}], ";"}], "//", "AbsoluteTiming"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"m4", "=",
RowBox[{
RowBox[{
RowBox[{"Graph", "[",
RowBox[{"#", ",",
RowBox[{"VertexCoordinates", "\[Rule]",
RowBox[{"CirclePoints", "[", "4", "]"}]}]}], "]"}], "&"}], "/@",
RowBox[{"SortBy", "[",
RowBox[{
RowBox[{"allDirectedGraphs", "[", "4", "]"}], ",", "IGIsoclass"}],
"]"}]}]}], ";"}], "//", "AbsoluteTiming"}]}], "Input",
CellLabel->"In[61]:=",ExpressionUUID->"3ad529ff-49ed-48f2-bedd-e7b91cbc3b27"],
Cell[BoxData[
RowBox[{"{",
RowBox[{"0.001866`", ",", "Null"}], "}"}]], "Output",
CellLabel->"Out[61]=",ExpressionUUID->"c7ef73fa-734e-4278-9a32-9f997a625db5"],
Cell[BoxData[
RowBox[{"{",
RowBox[{"0.020889`", ",", "Null"}], "}"}]], "Output",
CellLabel->"Out[62]=",ExpressionUUID->"09d9992a-a604-450a-b6ae-2eb41214938c"],
Cell[BoxData[
RowBox[{"{",
RowBox[{"1.064653`", ",", "Null"}], "}"}]], "Output",
CellLabel->
"Out[63]=",ExpressionUUID->"8fd9728d-5a0b-433f-a8b5-f4d7cccc91c0"]
}, Open ]],
Cell[CellGroupData[{
Cell[BoxData[{
RowBox[{
RowBox[{
RowBox[{"u2", "=",
RowBox[{
RowBox[{
RowBox[{"Graph", "[",
RowBox[{"#", ",",
RowBox[{"VertexCoordinates", "\[Rule]",
RowBox[{"CirclePoints", "[", "2", "]"}]}]}], "]"}], "&"}], "/@",
RowBox[{"SortBy", "[",
RowBox[{
RowBox[{"allUndirectedGraphs", "[", "2", "]"}], ",", "EdgeCount"}],
"]"}]}]}], ";"}], "//", "AbsoluteTiming"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"u3", "=",
RowBox[{
RowBox[{
RowBox[{"Graph", "[",
RowBox[{"#", ",",
RowBox[{"VertexCoordinates", "\[Rule]",
RowBox[{"CirclePoints", "[", "3", "]"}]}]}], "]"}], "&"}], "/@",
RowBox[{"SortBy", "[",
RowBox[{
RowBox[{"allUndirectedGraphs", "[", "3", "]"}], ",", "IGIsoclass"}],
"]"}]}]}], ";"}], "//", "AbsoluteTiming"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"u4", "=",
RowBox[{
RowBox[{
RowBox[{"Graph", "[",
RowBox[{"#", ",",
RowBox[{"VertexCoordinates", "\[Rule]",
RowBox[{"CirclePoints", "[", "4", "]"}]}]}], "]"}], "&"}], "/@",
RowBox[{"SortBy", "[",
RowBox[{
RowBox[{"allUndirectedGraphs", "[", "4", "]"}], ",", "IGIsoclass"}],
"]"}]}]}], ";"}], "//", "AbsoluteTiming"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"u5", "=",
RowBox[{
RowBox[{
RowBox[{"Graph", "[",
RowBox[{"#", ",",
RowBox[{"VertexCoordinates", "\[Rule]",
RowBox[{"CirclePoints", "[", "5", "]"}]}]}], "]"}], "&"}], "/@",
RowBox[{"SortBy", "[",
RowBox[{
RowBox[{"allUndirectedGraphs", "[", "5", "]"}], ",", "IGIsoclass"}],
"]"}]}]}], ";"}], "//", "AbsoluteTiming"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"u6", "=",
RowBox[{
RowBox[{
RowBox[{"Graph", "[",
RowBox[{"#", ",",
RowBox[{"VertexCoordinates", "\[Rule]",
RowBox[{"CirclePoints", "[", "6", "]"}]}]}], "]"}], "&"}], "/@",
RowBox[{"SortBy", "[",
RowBox[{
RowBox[{"allUndirectedGraphs", "[", "6", "]"}], ",", "IGIsoclass"}],
"]"}]}]}], ";"}], "//", "AbsoluteTiming"}]}], "Input",
CellLabel->"In[64]:=",ExpressionUUID->"708f79e3-abd0-40f3-be09-c9dc4e7a6885"],
Cell[BoxData[
RowBox[{"{",
RowBox[{"0.001161`", ",", "Null"}], "}"}]], "Output",
CellLabel->"Out[64]=",ExpressionUUID->"607f5bc7-0512-4ef7-b175-8ea7406a0264"],
Cell[BoxData[
RowBox[{"{",
RowBox[{"0.004184`", ",", "Null"}], "}"}]], "Output",
CellLabel->"Out[65]=",ExpressionUUID->"87195e52-3ae1-4093-8ee3-7d85fc45f846"],
Cell[BoxData[
RowBox[{"{",
RowBox[{"0.029806`", ",", "Null"}], "}"}]], "Output",
CellLabel->"Out[66]=",ExpressionUUID->"8fec5b66-1ee0-4cfa-ac3b-a9f8c43e9686"],
Cell[BoxData[
RowBox[{"{",
RowBox[{"0.335428`", ",", "Null"}], "}"}]], "Output",
CellLabel->"Out[67]=",ExpressionUUID->"188f25e8-5bf0-46d1-8cf3-c609ce39022d"],
Cell[BoxData[
RowBox[{"{",
RowBox[{"10.365798`", ",", "Null"}], "}"}]], "Output",
CellLabel->
"Out[68]=",ExpressionUUID->"8aaaaf67-1cb9-4027-903b-e62ee16600fe"]
}, Open ]],
Cell[BoxData[
RowBox[{
RowBox[{"MANlabels", "=",
RowBox[{"{",
RowBox[{
"\"\<003\>\"", ",", "\"\<012\>\"", ",", "\"\<021U\>\"", ",",
"\"\<102\>\"", ",", "\"\<021C\>\"", ",", "\"\<111D\>\"", ",",
"\"\<021D\>\"", ",", "\"\<030T\>\"", ",", "\"\<120D\>\"", ",",
"\"\<111U\>\"", ",", "\"\<201\>\"", ",", "\"\<030C\>\"", ",",
"\"\<120C\>\"", ",", "\"\<120U\>\"", ",", "\"\<210\>\"", ",",
"\"\<300\>\""}], "}"}]}], ";"}]], "Input",
CellLabel->"In[69]:=",ExpressionUUID->"7e2473da-3592-4f96-9124-ad6776fb7398"],
Cell[BoxData[{
RowBox[{
RowBox[{"zimport", "[", "filename_", "]"}], ":=",
RowBox[{"Uncompress", "@",
RowBox[{"Import", "[",
RowBox[{"filename", ",", "\"\<String\>\""}], "]"}]}]}], "\n",
RowBox[{
RowBox[{"zexport", "[",
RowBox[{"filename_", ",", "data_"}], "]"}], ":=",
RowBox[{"Export", "[",
RowBox[{"filename", ",",
RowBox[{"Compress", "[", "data", "]"}], ",", "\"\<String\>\""}],
"]"}]}]}], "Input",
CellLabel->"In[70]:=",ExpressionUUID->"0e50f5ac-db44-4d16-b513-449607180ee7"],
Cell[BoxData[
RowBox[{
RowBox[{"SetDirectory", "@",
RowBox[{"FileNameJoin", "[",
RowBox[{"{",
RowBox[{
RowBox[{"NotebookDirectory", "[", "]"}], ",", "\"\<IGraphM\>\""}],
"}"}], "]"}]}], ";"}]], "Input",
CellLabel->"In[72]:=",ExpressionUUID->"f5ccd16c-bf02-4ec8-bd41-067aba505f10"],
Cell[CellGroupData[{
Cell[BoxData[
RowBox[{"zexport", "[", "\[IndentingNewLine]",
RowBox[{"\"\<IGData.mz\>\"", ",", "\[IndentingNewLine]",
RowBox[{"<|", "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"{",
RowBox[{"\"\<AllDirectedGraphs\>\"", ",", "2"}], "}"}], "\[Rule]",
"m2"}], ",", "\[IndentingNewLine]",
RowBox[{
RowBox[{"{",
RowBox[{"\"\<AllDirectedGraphs\>\"", ",", "3"}], "}"}], "\[Rule]",
"m3"}], ",", "\[IndentingNewLine]",
RowBox[{
RowBox[{"{",
RowBox[{"\"\<AllDirectedGraphs\>\"", ",", "4"}], "}"}], "\[Rule]",
"m4"}], ",", "\[IndentingNewLine]",
RowBox[{
RowBox[{"{",
RowBox[{"\"\<AllUndirectedGraphs\>\"", ",", "2"}], "}"}], "\[Rule]",
"u2"}], ",", "\[IndentingNewLine]",
RowBox[{
RowBox[{"{",
RowBox[{"\"\<AllUndirectedGraphs\>\"", ",", "3"}], "}"}], "\[Rule]",
"u3"}], ",", "\[IndentingNewLine]",
RowBox[{
RowBox[{"{",
RowBox[{"\"\<AllUndirectedGraphs\>\"", ",", "4"}], "}"}], "\[Rule]",
"u4"}], ",", "\[IndentingNewLine]",
RowBox[{
RowBox[{"{",
RowBox[{"\"\<AllUndirectedGraphs\>\"", ",", "5"}], "}"}], "\[Rule]",
"u5"}], ",", "\[IndentingNewLine]",
RowBox[{
RowBox[{"{",
RowBox[{"\"\<AllUndirectedGraphs\>\"", ",", "6"}], "}"}], "\[Rule]",
"u6"}], ",", "\[IndentingNewLine]",
RowBox[{"\"\<MANTriadLabels\>\"", "\[Rule]",
RowBox[{"AssociationThread", "[",
RowBox[{"MANlabels", ",", "m3"}], "]"}]}]}], "\[IndentingNewLine]",
"|>"}]}], "\[IndentingNewLine]", "]"}]], "Input",
CellLabel->"In[73]:=",ExpressionUUID->"ab46b946-53c9-43c1-a12a-4fbcf5fd97f8"],
Cell[BoxData["\<\"IGData.mz\"\>"], "Output",
CellLabel->
"Out[73]=",ExpressionUUID->"4607c685-2377-4f88-bab4-7bba963d9d86"]
}, Open ]],
Cell[BoxData[
RowBox[{
RowBox[{"ResetDirectory", "[", "]"}], ";"}]], "Input",
CellLabel->
"In[74]:=",ExpressionUUID->"a0f61f89-1ce0-4679-9880-a2161e686f4b"]
},
WindowSize->{950, 721},
WindowMargins->{{206, Automatic}, {Automatic, 34}},
PrivateNotebookOptions->{"FileOutlineCache"->False},
TrackCellChangeTimes->False,
FrontEndVersion->"13.0 for Mac OS X x86 (64-bit) (December 2, 2021)",
StyleDefinitions->"Default.nb",
ExpressionUUID->"e866a327-4222-4c5b-9b23-5aa78821729d"
]