Statistics
| Branch: | Revision:

iof-tools / networkxMiCe / networkx-master / examples / graph / plot_atlas.py @ 5cef0f13

History | View | Annotate | Download (896 Bytes)

1
#!/usr/bin/env python
2
"""
3
======
4
Atlas2
5
======
6

7
Write first 20 graphs from the graph atlas as graphviz dot files
8
Gn.dot where n=0,19.
9
"""
10
# Author: Aric Hagberg (hagberg@lanl.gov)
11
# Date: 2005-05-19 14:23:02 -0600 (Thu, 19 May 2005)
12

    
13
#    Copyright (C) 2006-2019 by
14
#    Aric Hagberg <hagberg@lanl.gov>
15
#    Dan Schult <dschult@colgate.edu>
16
#    Pieter Swart <swart@lanl.gov>
17
#    All rights reserved.
18
#    BSD license.
19

    
20
import networkx as nx
21
from networkx.generators.atlas import graph_atlas_g
22

    
23
atlas = graph_atlas_g()[0:20]
24

    
25
for G in atlas:
26
    print("graph %s has %d nodes with %d edges"
27
          % (G.name, nx.number_of_nodes(G), nx.number_of_edges(G)))
28
    A = nx.nx_agraph.to_agraph(G)
29
    A.graph_attr['label'] = G.name
30
    # set default node attributes
31
    A.node_attr['color'] = 'red'
32
    A.node_attr['style'] = 'filled'
33
    A.node_attr['shape'] = 'circle'
34
    A.write(G.name + '.dot')