ViewPoint.predecessors#

ViewPoint.predecessors() → list[Vertex]#

Vertices that have an edge to this vertex

Returns:

the vertices at the tail of the incoming edges

Return type:

list of Vertex subclass

There is one entry per edge, so a vertex joined by k parallel edges appears k times. For an undirected graph this is adjacent.

>>> from pgraph import DGraph
>>> g = DGraph()
>>> v1 = g.add_vertex(coord=[0,0], name='v1')
>>> v2 = g.add_vertex(coord=[1,1], name='v2')
>>> v3 = g.add_vertex(coord=[2,2], name='v3')
>>> g.add_edge(v1, v3)
Edge{[v1] -> [v3], cost=2.828}
>>> g.add_edge(v2, v3)
Edge{[v2] -> [v3], cost=1.414}
>>> print(v3.predecessors())
[Vertex[v1, coord=(0, 0)], Vertex[v2, coord=(1, 1)]]
Seealso:

successors adjacent in_edges in_degree