edgegraph.structure.directededge.DirectedEdge#
- class edgegraph.structure.directededge.DirectedEdge(v1=None, v2=None, *, uid=None, attributes=None)#
Bases:
TwoEndedLinkRepresents 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:
See also
edgegraph.structure.undirectededge.UnDirectedEdge.__init__(), the superclass constructor
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
Get the UID of this object.
Get the universes this object belongs to.
Return the origin vertex of this edge.
Return the destination vertex of this edge.
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,
Noneis returned.
- 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 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
- unlink_from(kill)#
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.