Note
Click here to download the full example code
Atlas2ΒΆ
Write first 20 graphs from the graph atlas as graphviz dot files Gn.dot where n=0,19.
Out:
graph G0 has 0 nodes with 0 edges
graph G1 has 1 nodes with 0 edges
graph G2 has 2 nodes with 0 edges
graph G3 has 2 nodes with 1 edges
graph G4 has 3 nodes with 0 edges
graph G5 has 3 nodes with 1 edges
graph G6 has 3 nodes with 2 edges
graph G7 has 3 nodes with 3 edges
graph G8 has 4 nodes with 0 edges
graph G9 has 4 nodes with 1 edges
graph G10 has 4 nodes with 2 edges
graph G11 has 4 nodes with 2 edges
graph G12 has 4 nodes with 3 edges
graph G13 has 4 nodes with 3 edges
graph G14 has 4 nodes with 3 edges
graph G15 has 4 nodes with 4 edges
graph G16 has 4 nodes with 4 edges
graph G17 has 4 nodes with 5 edges
graph G18 has 4 nodes with 6 edges
graph G19 has 5 nodes with 0 edges
# Author: Aric Hagberg (hagberg@lanl.gov)
# Date: 2005-05-19 14:23:02 -0600 (Thu, 19 May 2005)
# Copyright (C) 2006-2019 by
# Aric Hagberg <hagberg@lanl.gov>
# Dan Schult <dschult@colgate.edu>
# Pieter Swart <swart@lanl.gov>
# All rights reserved.
# BSD license.
import networkx as nx
from networkx.generators.atlas import graph_atlas_g
atlas = graph_atlas_g()[0:20]
for G in atlas:
print("graph %s has %d nodes with %d edges"
% (G.name, nx.number_of_nodes(G), nx.number_of_edges(G)))
A = nx.nx_agraph.to_agraph(G)
A.graph_attr['label'] = G.name
# set default node attributes
A.node_attr['color'] = 'red'
A.node_attr['style'] = 'filled'
A.node_attr['shape'] = 'circle'
A.write(G.name + '.dot')
Total running time of the script: ( 0 minutes 0.121 seconds)