|
14 | 14 |
|
15 | 15 | from pegasus_graph import P16, P6 |
16 | 16 | import minorminer.layout as mml, dwave_networkx as dnx, networkx as nx |
17 | | -import matplotlib |
18 | | -matplotlib.use("agg") |
19 | | -from matplotlib import pyplot as plt, colors as mpl_color |
| 17 | + |
| 18 | +try: |
| 19 | + import matplotlib.pyplot as plt |
| 20 | + import matplotlib.colors as mpl_color |
| 21 | +except ImportError: |
| 22 | + matplotlib.use("agg") |
| 23 | + import matplotlib.pyplot as plt |
| 24 | + import matplotlib.colors as mpl_color |
20 | 25 |
|
21 | 26 | # Draw a small P6 graph |
22 | 27 | n = 200 |
23 | 28 | C = nx.random_regular_graph(3, n) |
24 | 29 |
|
25 | | -emb, (layout_C, layout_P) = mml.find_embedding(C, P6, random_seed = 1, |
26 | | - return_layouts = True, |
27 | | - threads = 3) |
| 30 | +emb, (layout_C, layout_P) = mml.find_embedding(C, P6, random_seed=1, |
| 31 | + return_layouts=True, |
| 32 | + threads=3) |
28 | 33 |
|
29 | 34 | plt.figure(figsize=(20, 20)) |
30 | 35 |
|
|
44 | 49 | n = 850 |
45 | 50 | C = nx.random_regular_graph(3, n) |
46 | 51 |
|
47 | | - emb, (layout_C, layout_P) = mml.find_embedding(C, P16, random_seed = 2, |
48 | | - return_layouts = True, layout = (None, None), |
49 | | - threads = 3, verbose = 2, interactive = True, tries = 30, max_no_improvement = 10000, timeout = 10000000) |
| 52 | + emb, (layout_C, layout_P) = mml.find_embedding(C, P16, random_seed=2, |
| 53 | + return_layouts=True, |
| 54 | + layout=(None, None), |
| 55 | + threads=3, |
| 56 | + verbose=2, |
| 57 | + interactive=True, |
| 58 | + tries=30, |
| 59 | + max_no_improvement=10000, |
| 60 | + timeout=10000000) |
50 | 61 |
|
51 | 62 | plt.figure(figsize=(20, 20)) |
52 | 63 |
|
|
0 commit comments