Undirected graph vertex
- class PGraph.UVertex(coord=None, name=None)[source]
Bases:
VertexVertex subclass for undirected graphs
This class can be inherited to provide user objects with graph capability.

- __init__(coord=None, name=None)
- closest()
- connect(other, **kwargs)[source]
Connect two vertices with an edge
- Parameters:
dest (
Vertexsubclass) – The vertex to connect toedge (
Edgesubclass, optional) – Use this as the edge object, otherwise a newEdgeobject is created from the vertices being connected, and thecostandedgeparameters, defaults to Nonecost (float, optional) – the cost to traverse this edge, defaults to None
data (Any, optional) – reference to arbitrary data associated with the edge, defaults to None
- Raises:
TypeError – vertex types are different subclasses
- Returns:
the edge connecting the vertices
- Return type:
v1.connect(v2)connects vertexv1to vertexv2.Note
If the vertices subclass
UVertexthe edge is undirected, and if they subclassDVertexthe edge is directed.Vertices must both be of the same
Vertexsubclass
- Seealso:
- copy(cls=None)
- property degree
Degree of vertex
- Returns:
degree of the vertex
- Return type:
int
Returns the number of edges connected to the vertex.
Note
For a
DGraphonly outgoing edges are considered.- Seealso:
- distance(coord)
Distance from vertex to point
- Parameters:
coord (ndarray(n) or Vertex) – coordinates of the point
- Returns:
distance
- Return type:
float
Distance is computed according to the graph’s metric.
- Seealso:
metric()
- edges()
All outgoing edges of vertex
- Returns:
List of all edges leaving this vertex
- Return type:
list of Edge
Note
For a directed graph the edges are those leaving this vertex
- For a non-directed graph the edges are those leaving or entering
this vertex
- edgeto(dest)
Get edge connecting vertex to specific neighbour
- Parameters:
dest (
Vertexsubclass) – a neigbouring vertex- Raises:
ValueError –
destis not a neighbour- Returns:
the edge from this vertex to
dest- Return type:
Note
For a directed graph
destmust be at the arrow end of the edge
- heuristic_distance(v2)
- incidences()
Neighbours and edges of a vertex
v.incidences()is a generator that returns a list of incidences, tuples of (vertex, edge) for all neighbours of the vertexv.Note
For a directed graph the edges are those leaving this vertex
- isneighbour(vertex)
Test if vertex is a neigbour
- Parameters:
vertex (Vertex subclass) – vertex reference
- Returns:
true if a neighbour
- Return type:
bool
For a directed graph this is true only if the edge is from
selftovertex.
- neighbors()
Neighbors of a vertex
v.neighbors()is a list of neighbors of this vertex.Note
For a directed graph the neighbours are those on edges leaving this vertex
- neighbours()
Neighbours of a vertex
v.neighbours()is a list of neighbours of this vertex.Note
For a directed graph the neighbours are those on edges leaving this vertex
- property x
The x-coordinate of an embedded vertex
- Returns:
The x-coordinate
- Return type:
float
- property y
The y-coordinate of an embedded vertex
- Returns:
The y-coordinate
- Return type:
float
- property z
The z-coordinate of an embedded vertex
- Returns:
The z-coordinate
- Return type:
float