ViewPoint.edges_to#
- ViewPoint.edges_to(dest: Vertex) list[Edge]#
All the edges from this vertex to another vertex
- Parameters:
dest (
Vertexsubclass) – 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.
edgetoreturns 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
destare included, soa.edges_to(b)andb.edges_to(a)are different listsFor 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 emptyThe 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: