[Python-ideas] Graph class
Terry Reedy
tjreedy at udel.edu
Tue Dec 18 10:06:39 CET 2012
On 12/17/2012 10:26 PM, Nick Coghlan wrote:
> On Mon, Dec 17, 2012 at 9:28 AM, Hannu Krosing
> <hannu at krosing.net
> <mailto:hannu at krosing.net>> wrote:
>
> On 12/16/2012 04:41 PM, Guido van Rossum wrote:
>> I think of graphs and trees as patterns, not data structures.
>
> How do you draw line between what is data structure and what is
> pattern ?
>
>
> A rough rule of thumb is that if it's harder to remember the
> configuration options in the API than it is to just write a
> purpose-specific function, it's probably better as a pattern that can be
> tweaked for a given use case than it is as an actual data structure.
>
> More generally, ABCs and magic methods are used to express patterns
> (like iteration), which may be implemented by various data structures.
>
> 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.
--
Terry Jan Reedy
More information about the Python-ideas
mailing list