-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathgraphing.py
More file actions
42 lines (32 loc) · 837 Bytes
/
Copy pathgraphing.py
File metadata and controls
42 lines (32 loc) · 837 Bytes
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
import networkx as nx
import numpy as np
import matplotlib.pyplot as plt
def MakeRingLattice(n, d):
offsets = range(1, (d//2) + 1)
return nx.circulant_graph(n, offsets)
def Single():
G = nx.Graph()
G.add_node(0)
return G
def DrawGraph(G):
options = {
"font_size": 12,
"node_size": 500,
"node_color": "white",
"edgecolors": "black",
"linewidths": 4,
"width": 2,
"with_labels": True,
}
nx.draw_circular(G, **options)
def PlotShow():
# special magic for avoiding a blocking call
plt.show(block=False)
# Pause to allow the input call to run:
plt.pause(0.001)
input("hit [enter] to end.")
plt.close('all')
def SaveGraph(G, prefix='', n=0):
DrawGraph(G)
plt.savefig(f'img/{prefix}_layer_{n}.png')
plt.close()