This adds API for adding edges, while also adding given vertices if they are not yet present in the graph. In petgraph, there is GraphMap type for this use case. With a new storage which would use the same implementation as petgraph's GraphMap for storing vertices and edges and override find_vertex method, the performance characteristics for add_edge_connecting should be mostly the same as GraphMap::add_edge.
The definition of find_vertex on the Vertices trait requires only Eq trait. However, the implementation of GraphMap requires Ord + Hash. I believe that this is fine, because it is technically possible to put the constraints on the impl itself, i.e., impl<V, ...> Vertices for Map where V: Ord + Hash.
This adds API for adding edges, while also adding given vertices if they are not yet present in the graph. In petgraph, there is GraphMap type for this use case. With a new storage which would use the same implementation as petgraph's
GraphMap
for storing vertices and edges and overridefind_vertex
method, the performance characteristics foradd_edge_connecting
should be mostly the same asGraphMap::add_edge
.The definition of
find_vertex
on theVertices
trait requires onlyEq
trait. However, the implementation ofGraphMap
requiresOrd + Hash
. I believe that this is fine, because it is technically possible to put the constraints on theimpl
itself, i.e.,impl<V, ...> Vertices for Map where V: Ord + Hash
.