You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Change __repr__ for AGraph? (migrated from Trac #341) #338
In NetworkX, the repr for graphs is just the memory address:
'''
In [1]: x = nx.Graph()
In [2]: x
Out[2]: <networkx.classes.graph.Graph object at 0x904e34c>
'''
In PyGraphviz, repr gives the dot representation instead.
'''
In [3]: x = pygraphviz.AGraph()
In [4]: x
Out[4]:
strict graph {
}
'''
If any function, such as like networkx.view_pygraphviz(), returns an AGraph instance, the output in IPython is a bit ugly.
'''
In [5]: x = nx.path_graph(3)
Activity
networkx-trac commentedon Jul 20, 2012
Comment in Trac by @hagberg, 2010-04-16
The general guidance is to make repr make an
unambiguous representation that in a perfect world
could be passed to eval().
See e.g
http://stackoverflow.com/questions/1436703/difference-between-str-and-repr-in-python
So maybe it is more likely that the NetworkX class repr's are lacking.
networkx-trac commentedon Jul 20, 2012
Comment in Trac by @hagberg, 2010-07-23