[Python-ideas] Graph class

Yuval Greenfield ubershmekel at gmail.com
Tue Dec 18 15:24:01 CET 2012


On Tue, Dec 18, 2012 at 2:08 PM, Oscar Benjamin
<oscar.j.benjamin at gmail.com>wrote:

> On 18 December 2012 09:06, Terry Reedy <tjreedy at udel.edu> wrote:
> > On 12/17/2012 10:26 PM, Nick Coghlan wrote:
> >> A graph library that focused on defining a good abstraction (and
> >> adapters) that allowed graph algorithms to be written that worked with
> >> multiple existing Python graph data structures could be quite
> interesting.
> >
> >
> > I was just thinking that what is needed, at least as a first step, is a
> > graph api, like the db api, that would allow the writing of algorithms to
> > one api and adapters to various implementations. I expect to be writing
> some
> > graph algorithms (in Python) in the next year and will try to keep that
> idea
> > in mind and see if it makes any sense, versus just whipping up a
> > implementation that fits the particular problem.
>
> I'd be interested to use (and possibly to contribute to) a graph
> library of this type on PyPI. I have some suggestions about the
> appropriate level of abstraction below.
>
> The graph algorithms that are the most useful can be written in terms
> of two things:
> 1) An iterator over the nodes
> 2) A way to map each node into an iterator over its children (or partners)
>
>

Some graphs don't care for the nodes, all their information is in the
edges. That's why most graph frameworks have iter_edges and iter_nodes
functions. I'm not sure what's the clean way to represent the
optional directionality of edges though.

Some example API's from networkx:

http://networkx.lanl.gov/reference/classes.html
http://networkx.lanl.gov/reference/classes.digraph.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20121218/693d07ff/attachment.html>


More information about the Python-ideas mailing list