3
Draw a graph with matplotlib, color by degree.
4
You must have matplotlib for this to work.
6
__author__ = """Aric Hagberg (hagberg@lanl.gov)"""
7
# Copyright (C) 2004-2006 by
8
# Aric Hagberg <hagberg@lanl.gov>
9
# Dan Schult <dschult@colgate.edu>
10
# Pieter Swart <swart@lanl.gov>
11
# Distributed under the terms of the GNU Lesser General Public License
12
# http://www.gnu.org/copyleft/lesser.html
17
print "pylab not found: see https://networkx.lanl.gov/Drawing.html for info"
20
from networkx import *
22
G=grid_2d_graph(4,4) #4x4 grid
24
draw(G,pos,node_color=array([G.degree(v) for v in G]),node_size=800)
25
savefig("grid.png") # save as png