pnevyk / gryf

Graph data structure library aspiring to be convenient, versatile, correct and performant.
MIT License
69 stars 1 forks source link

Reconsider multi edges iteration #48

Closed pnevyk closed 1 year ago

pnevyk commented 1 year ago

There are cases (1) when it would be useful to be able to iterate over all multi-edges between two vertices without requiring an additional trait bound on the input graph not to disqualify graphs that do not support that.

We might move multi_edge_index method from MultiEdges to Edges so that it can be used on all types implementing Edges. The trait MultiEdges would become a marker trait, if there is a need for constraining a graph on that. For graphs without multi-edge support, the MultiEdgeIndicesIter type would simply be Option<EdgeIndex> and the implementation would call edge_index.

We might even stop distinguishing between edge_index and multi_edge_index and have just edge_index that returns an iterator. With the current API, surprises may happen if a developer/user does not realize that edge_index does not tell the whole truth in multi-edge graphs. Therefore this change would reduce a chance for surprising behavior, which is one of our goals.

pnevyk commented 1 year ago

Changed in 2d3fab8b12bc5e07d6025141d22ac964c07a884c