sdboyer / gogl

A graph library in Go
MIT License
77 stars 13 forks source link

Add enumeration methods+interfaces for out-edge/in-edge traversal, similar to adjacency #11

Closed sdboyer closed 10 years ago

sdboyer commented 10 years ago

right now, EachAdjacent() is lying in the implementations - 'adjacency' means the same thing regardless of whether the connecting edge is directed or not. so we need more enumerators that allow traversal purely of out-edges, purely of in-edges, or both (and which send the edge instead of the vertex, as EachAdjacent() does).

the final set of methods should be:

sdboyer commented 10 years ago

Changing that plan - instead it's this:

// An IncidentEdgeEnumerator iteratively enumerates a given vertex's incident edges.
type IncidentEdgeEnumerator interface {
    EachEdgeIncidentTo(v Vertex, incidentEdgeLambda EdgeLambda)
}

// An IncidentArcEnumerator iteratively enumerates a given vertex's incident arcs (directed edges).
// One enumerator provides inbound edges, the other outbound edges.
type IncidentArcEnumerator interface {
    EachArcFrom(v Vertex, outEdgeLambda EdgeLambda)
    EachArcTo(v Vertex, inEdgeLambda EdgeLambda)
}
sdboyer commented 10 years ago

ugh, that was mind-numbing. #17 really needs to happen next.