Skip to content

Instantly share code, notes, and snippets.

@mzsima
Created May 24, 2020 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mzsima/8ff0467f0b0f3d2e8a31b3d63fce4ee8 to your computer and use it in GitHub Desktop.
Save mzsima/8ff0467f0b0f3d2e8a31b3d63fce4ee8 to your computer and use it in GitHub Desktop.
[networkX]グリッドeven/odd

image

snapshot

code jupyter notebook

import matplotlib.pyplot as plt
import networkx as nx

G = nx.grid_2d_graph(5, 5) 
pos = nx.spring_layout(G, k=0.3)
node_colors = ['#1f78b4' if v[0] % 2 == 0  else '#33a02c' for v in G.nodes] 
nx.draw(G, pos, node_color=node_colors)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment