edgegraph.traversal.helpers.find_links#
- edgegraph.traversal.helpers.find_links(v1, v2, direction_sensitive=True, unknown_handling=2, filterfunc=None)#
Find the link(s) that connect v1 to v2.
This function returns links that connect v1 and v2. If multiple links/edges connect the given vertices, they are all returned in a list. It respects edge directionality if/when necessary, and can handle arbitrary edge types given they are subclasses of either
DirectedEdgeor :py:class:~edgegraph.structure.undirectededge.UnDirectedEdge`.For example, with the given graph:
the function would operate as:
>>> find_links(v1, v2) {e1} >>> find_links(v1, v4) {e6} >>> find_links(v1, v4, direction_sensitive=False) {e6, e5}
If supplied, the
filterfuncargument should be a callable object (function or otherwise) that will return eitherTrueorFalse. This function is used to determine if a given edge should be included in the returned set. It must have the following signature:- edgegraph.traversal.helpers.filterfunc(e)
Determines if a given edge (
e) should be included in the returned set of edges betweenv1andv2.- Parameters:
e – The edge under consideration.
- Returns:
Whether or not
eshould be returned as part of the set of edges connectingv1andv2.
- Parameters:
v1 (Vertex) – First vertex to find links from. In a directed edge, this is consiered the “from” vertex.
v2 (Vertex) – Second vertex to find links from. In a directed edge, this is consiered the “to” vertex.
direction_sensitive (bool) – Whether or not to respect edge directionality. If True (default), edges direcetd from v2 to v1 are ignored. If False, such edges are collected and returned.
unknown_handling (int) –
How to deal with classes that are subclasses of neither
DirectedEdgenorUnDirectedEdge.LNK_UNKNOWN_ERROR(default): Raise aNotImplementedErrorwhen such an edge is encountered.LNK_UNKNOWN_NEIGHBOR: Skip unknown edges.LNK_UNKNOWN_NONNEIGHBOR: Collect and return unknown edges.
filterfunc (Callable | None) – Callable object that returns whether or not a given link should be included in the output.