File: plot_mini_atlas.py

package info (click to toggle)
networkx 3.4.2-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 11,700 kB
  • sloc: python: 105,310; xml: 544; makefile: 131; javascript: 120; sh: 34
file content (26 lines) | stat: -rw-r--r-- 597 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""
Atlas
=====

An example showing how to write first 20 graphs from the graph atlas as
graphviz dot files Gn.dot where n=0,19.

TODO: does nx_agraph.draw support multiple graphs in one png?
"""

import networkx as nx

atlas = nx.graph_atlas_g()[0:20]

for G in atlas:
    print(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")

# Draw the 20th graph from the atlas to png
A.draw("A20.png", prog="neato")