Landmark.edges_to#

Landmark.edges_to(dest: Vertex) → list[Edge]#

All the edges from this vertex to another vertex

Parameters:

dest (Vertex subclass) – the vertex at the far end

Returns:

every edge from this vertex to dest, in the order they were connected, which is empty if there are none

Return type:

list of Edge

This is how to see parallel edges. edgeto returns the one edge that a path would use, the cheapest, whereas this returns them all.

Note

  • For a directed graph only the edges leaving this vertex for dest are included, so a.edges_to(b) and b.edges_to(a) are different lists

  • For an undirected graph the edges are found from either end, whichever vertex they were connected from

  • A self-loop is listed once, although its vertex holds it twice (see edges)

  • Unlike edgeto, there being no edge is not an error, the list is empty

  • The list is a new one, so changing it does not change the graph

>>> from pgraph import UGraph
>>> g = UGraph()
>>> v1 = g.add_vertex(coord=[0,0], name='v1')
>>> v2 = g.add_vertex(coord=[1,1], name='v2')
>>> g.add_edge(v1, v2, cost=3)
Edge{[v1] -- [v2], cost=3}
>>> g.add_edge(v1, v2, cost=1)
Edge{[v1] -- [v2], cost=1}
>>> print(v1.edges_to(v2))
[Edge{[v1] -- [v2], cost=3}, Edge{[v1] -- [v2], cost=1}]
>>> print(v1.edgeto(v2))
Edge{[v1] -- [v2], cost=1}
Seealso:

edgeto edges out_edges incidences adjacent