On Saturday, 11 January 2014 at 03:53:28 UTC, Timon Gehr wrote:

One issue with the API is that it does not deal with graphswith more than one edge between two given vertices very well. Ithink it'd need a separate edge abstraction. (Formally, a graphis just a pair of sets (V,E) with two functions from E to Vgiving you start and end vertex of an edge.)

`I was thinking of changing the adjacency list to return a range`

`of edges instead. That may solve the problem. It also solves the`

`problem of the edgeWeight API being inefficient for certain graph`

`data structures.`

A graph search can have more properties than just the sequenceof visited edges, so maybe it is not a range, but just providesa range. (And maybe also a range of events, usable instead ofcallbacks, maybe a DFS tree etc.)

`A range of events would be interesting. You could then get a`

`range of different events by filtering:`

`graph.depthFirstSearchEvents(start).filter!(e => e.type ==`

`Event.node).map!(e => e.node);`

etc.

Allocation of memory for visited flags and the like should becontrollable. Maybe the design should even allow usingpersistent data structures for storing visited flags, such thatthe search range can be used as a value type / forward range.

`Absolutely. I'm leaving things like memory allocation API until`

`later and focussing on the general usability and flexibility.`

Probably it would be worthwhile to explore a design that issimilar to Phobos ranges at some level. I.e. support kinds ofgraphs with different capabilities. (Eg. your implicitGraphcannot enumerate all vertices or edges that are present in theGraph. The least capable graph kind reasonably supported mightnot even be able to quickly report all adjacent edges to avertex. Some graphs may allow in-place mutation etc.) Thenprovide some explicit representations with high capabilitiesand helper functions to convert certain representations to(more) explicit representations. (similar to constructing eg.an array from a range.) Constructions on graphs would thenreturn implicit representations.

`Yah, I only implemented implicit graph first due to it's simple`

`representation. It's mainly useful for infinite graphs like game`

`trees and works well for some other simple graph types, but`

`certainly there will be a need for other types of graph`

`(adjacency matrices, edge lists, adjacency lists, etc.)`

`It's also a very minimal graph type, which is useful for testing`

`a generic API. I want the algorithms to require only as much as`

`necessary from the graph representation. If users have to`

`construct large graph data type with many mandatory member`

`functions then I would be unhappy.`

Thanks for all the feedback.