Created
April 2, 2020 22:45
-
-
Save OisinMoran/cbc1736789d7559a401818f4961b507c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import permutations | |
import networkx as nx | |
import matplotlib.pyplot as plt | |
def flips(x): | |
for idx, (a, b) in enumerate(zip(x[:-1], x[1:])): | |
yield x[:idx] + (b,) + (a,) + x[idx+2:] | |
G = nx.Graph() | |
for perm in permutations(range(4)): | |
for flipped in flips(perm): | |
G.add_edge(perm, flipped) | |
nx.draw(G, with_labels=True) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment