ViewPoint.adjacent#
- ViewPoint.adjacent() list[Vertex]#
Vertices adjacent to this vertex
- Returns:
the vertices at the far end of this vertex’s edges
- Return type:
list of Vertex subclass
v.adjacent()is a list of the vertices that this vertex is joined to by an edge. “Adjacent” is the graph-theory term, and it is the relation thatGraph.adjacencytabulates: rowiof the adjacency matrix is non-zero exactly at the columns of the vertices returned byg[i].adjacent().Note
For a directed graph these are the vertices at the head of the edges leaving this vertex, the successors.
There is one entry per edge, so a vertex joined by
kparallel edges appearsktimes. In an undirected graph a self-loop lists the vertex itself twice, once for each end.neighboursandneighborsare aliases, the same method under the British and American spellings, and are not deprecated.
>>> from pgraph import UGraph >>> g = UGraph() >>> 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, v2) Edge{[v1] -- [v2], cost=1.414} >>> g.add_edge(v1, v3) Edge{[v1] -- [v3], cost=2.828} >>> print(v1.adjacent()) [Vertex[v2, coord=(1, 1)], Vertex[v3, coord=(2, 2)]]
- Seealso:
isadjacentsuccessorspredecessorsincidencesout_edgesedgesGraph.adjacency