tests.fixtures.weighted_graphs.WeightedDirectedEdge#

class tests.fixtures.weighted_graphs.WeightedDirectedEdge(v1=None, v2=None, weight=None, *, uid=None, attributes=None)#

Bases: DirectedEdge

A subclass of DirectedEdge which supports a custom weight attribute.

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

Create a weighted directed edge. All parameters the same as DirectedEdge, except the addition of a numerical weight.

Methods

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

Create a weighted 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

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

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.