edgegraph.structure.directededge.DirectedEdge#

class edgegraph.structure.directededge.DirectedEdge(v1=None, v2=None, *, uid=None, attributes=None)#

Bases: TwoEndedLink

Represents a directed edge (v1 –> v2) in the vertex-edge graph.

This object is intended to join two vertices in a directed fashion; i.e., one vertex directs to the other.

See also

  • To create DirectedEdges, see link_directed() rather than creating these classes directly.

__init__(v1=None, v2=None, *, uid=None, attributes=None)#

Instantiate a directed edge.

Parameters:
  • v1 (Vertex | None) – The first vertex in the edge (the link will be FROM this one)

  • v2 (Vertex | None) – The second vertex in the edge (thie link will be TO this one)

Methods

__init__([v1, v2, uid, attributes])

Instantiate a directed edge.

add_to_universe(universe)

Add this object to a new universe.

add_vertex(new)

Add a vertex to this link.

other(end)

Identify and return the other end of this edge.

remove_from_universe(universe)

Remove this object from the specified universe.

unlink_from(kill)

Remove the link association from the given vertex.

Attributes

uid

Get the UID of this object.

universes

Get the universes this object belongs to.

v1

Return the origin vertex of this edge.

v2

Return the destination vertex of this edge.

vertices

Return a tuple of vertices this edge connects.

add_to_universe(universe)#

Add this object to a new universe.

If it is already there, no action is taken.

Parameters:

universe (Universe) – the new universe to add this object to

add_vertex(new)#

Add a vertex to this link.

Parameters:

new (Vertex) – the vertex to add to the link

Concurrency:

Thread-safe

other(end)#

Identify and return the other end of this edge.

This is mainly a convience method – it accepts one vertex as an argument, figures out whether it’s v1 or v2 of this edge, and returns v2 or v1 respectively.

Should the given vertex not be a part of this edge, None is returned.

Parameters:

end (Vertex) – one end of this edge

Returns:

the other end of this edge, or None

Return type:

Vertex | None

remove_from_universe(universe)#

Remove this object from the specified universe.

Parameters:

universe (Universe) – the universe that this object will be removed from

Raises:

ValueError – if this object is not present in the given universe

property uid: int#

Get the UID of this object.

property universes: list[Universe]#

Get the universes this object belongs to.

Note that the copy returned is just that, a copy. Modifications to this list that you may make will have no effect on the object.

See also

add_to_universe(), remove_from_universe() to add or remove this object from a given universe

Remove the link association from the given vertex.

This is effectively “unlinking” the specified vertex from this link. If this link is not associated with the given vertex, no action is taken.

Parameters:

kill (Vertex) – the vertex to unlink

Concurrency:

Thread-safe

property v1: Vertex#

Return the origin vertex of this edge.

This edge comes FROM this object: v1 –> v2.

property v2: Vertex#

Return the destination vertex of this edge.

This edge goes TO this object: v1 –> v2.

property vertices: tuple[Vertex, ...]#

Return a tuple of vertices this edge connects.

A tuple object is given because the addition or removal of vertex objects using this attribute is not intended; it is meant to be immutable.

Concurrency:

Thread-safe