[Python-ideas] Graph class

Mark Adam dreamingforward at gmail.com
Sun Dec 9 02:29:56 CET 2012


On Fri, Dec 7, 2012 at 4:22 PM, Thomas Kluyver <thomas at kluyver.me.uk> wrote:
> On 7 December 2012 21:45, Mark Adam <dreamingforward at gmail.com> wrote:
>>
>> I have a decent semi-recursive Graph class that I think could be a
>> good addition to the Collections module.  It probably needs some
>> refactoring, but I'm posting here to see if there's any interest.
>
> For reference, there was a previous idea to make some kind of standard
Graph
> API:
> http://wiki.python.org/moin/PythonGraphApi

All very interesting.  I'm going to suggest a sort of "meta-discussion"
about why -- despite the power of graphs as a data structure -- such a
feature has not stabilized into a workable solution for inclusion in a
high-level language like Python.

I identity the following points of "wavery":

1) the naming of methods (add_edge, vs add(1,2)):  *aesthetic grounds,*
2) what methods to include (degree + neighbors or the standard dict's
__len__ + __getitem__):  *API grounds*
3) how much flexibility to be offered (directed, multi-graphs, edge weights
with arbitrary labeling, etc.):  *functionality grounds*
3) what underlying data structure to use (sparse adjacency dicts, matrices,
etc):  *representation conflicts*.

And upon further thought, it looks like only a killer application could
ever settle the issue(s) to make it part of the standard library.

mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20121208/abdf95d8/attachment.html>


More information about the Python-ideas mailing list