I would like to know if there is a computationally efficient way of creating edges only if an edge with the same extremities and the same type (= a given edge property, in the sense of graph-tool edge properties) does not exist already.
Of course I can use the following algorithm:
before creating edge (v1,v2) of type t1:
take all edges out-going from v1:
check how many of them have v2 as target,
among them: check whether one of them has type t1
if yes do not create a new edge and return this one
if not, create a new edge
As this seems to be a bit slow (I have to do many such edge creations) I was wondering if there is a more efficient « create-only-if-doesnt-exist-already » method, of maybe simply a query method including the type (a single method for checking if there exists an edge of a given type between two given vertices).
Thanks in advance