<jupyter_start><jupyter_text>AttributesExample illustrating how attributes of nodes, edges, and graphs are handledduring conversion to/from `~pygraphviz.AGraph`.<jupyter_code>import networkx as nx

G = nx.Graph()
G.add_edge(1, 2, color="red")
G.add_edge(2, 3, color="red")
G.add_node(3)
G.add_node(4)

A = nx.nx_agraph.to_agraph(G)  # convert to a graphviz graph
A.draw("attributes.png", prog="neato")  # Draw with pygraphviz

# convert back to networkx Graph with attributes on edges and
# default attributes as dictionary data
X = nx.nx_agraph.from_agraph(A)
print("edges")
print(list(X.edges(data=True)))
print("default graph attributes")
print(X.graph)
print("node node attributes")
print(X.nodes.data(True))
!pip install pygraphviz<jupyter_output>Collecting pygraphviz
  Downloading pygraphviz-1.7.zip (118 kB)
[K     |████████████████████████████████| 118 kB 6.9 MB/s eta 0:00:01
[?25hBuilding wheels for collected packages: pygraphviz
  Building wheel for pygraphviz (setup.py) ... [?25lerror
[31m  ERROR: Command errored out with exit status 1:
   command: /opt/conda/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-q8o0orwd/pygraphviz_cdf7f5756e0d4ce5a515de78abc8bb03/setup.py'"'"'; __file__='"'"'/tmp/pip-install-q8o0orwd/pygraphviz_cdf7f5756e0d4ce5a515de78abc8bb03/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-ir7u8v3d
       cwd: /tmp/pip-install-q8o0orwd/pygraphviz_cdf7f5756e0d4ce5a515de78abc8bb03/
  Complete output (53 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x[...]
{'fraction_non_alphanumeric': 0.17359134889015368, 'fraction_numerical': 0.05122367672168469, 'mean_word_length': 5.894117647058824, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '458719', 'license': 'MIT', 'n_tokens_mistral': 758, 'n_tokens_neox': 693, 'n_words': 136, 'path': 'plot_attributes.ipynb', 'repo_name': 'DavidChoi76/networkx_examples', 'size': '1757'}