I quite like when the __repr__ actually says something about the object, so here's a draft of Graph.__repr__. Happy to iterate over if you have ideas what and how should be shown. The info I picked now is very cheap to compute.
In [1]: import numpy as np
...: from libpysal import graph
...: import geopandas as gpd
...: from geodatasets import get_path
In [2]: coords = np.random.random((100_000, 2))
In [5]: delaunay = graph.Graph.build_triangulation(coords)
In [6]: %time r = delaunay.__repr__()
CPU times: user 27 ms, sys: 10.9 ms, total: 37.9 ms
Wall time: 36.9 ms
In [7]: delaunay
Out[7]:
<Graph of 100000 nodes and 599936 nonzero edges indexed by
[0, 1, 2, 3, 4, ...]>
In [8]: nybb = gpd.read_file(get_path('nybb')).set_index('BoroName')
In [9]: contig = graph.Graph.build_contiguity(nybb)
...: contig
Out[9]:
<Graph of 5 nodes and 10 nonzero edges indexed by
['Staten Island', 'Queens', 'Brooklyn', 'Manhattan', 'Bronx']>
I quite like when the
__repr__
actually says something about the object, so here's a draft ofGraph.__repr__
. Happy to iterate over if you have ideas what and how should be shown. The info I picked now is very cheap to compute.udpated to match the latest formatting