Skip to main content
Ctrl+K
edgegraph is in unstable version v0.7, and may change at any time!
this documentation was built on branch sandbox/caching!

edgegraph 0.7.0 documentation

Contents:

  • EdgeGraph
  • edgegraph usage
    • Installation
    • Concept
  • Developer documentation
    • Development Practices
    • Testing Practices
    • Documentation practices
    • Program diagrams
    • API documentation
      • edgegraph
        • edgegraph.builder
        • edgegraph.output
        • edgegraph.structure
        • edgegraph.traversal
        • edgegraph.version
      • tests
        • tests.builder
        • tests.conftest
        • tests.integration
        • tests.interact
        • tests.output
        • tests.structure
        • tests.test_version
        • tests.traversal
    • Performance and optimizing
    • To-Do’s
  • References
  • Repository
  • Show source
  • Suggest edit
  • Open issue
  • .rst

edgegraph.structure.twoendedlink.TwoEndedLink

Contents

  • TwoEndedLink
    • TwoEndedLink.__init__()
    • TwoEndedLink.add_to_universe()
    • TwoEndedLink.add_vertex()
    • TwoEndedLink.other()
    • TwoEndedLink.remove_from_universe()
    • TwoEndedLink.uid
    • TwoEndedLink.universes
    • TwoEndedLink.unlink_from()
    • TwoEndedLink.v1
    • TwoEndedLink.v2
    • TwoEndedLink.vertices

edgegraph.structure.twoendedlink.TwoEndedLink#

class edgegraph.structure.twoendedlink.TwoEndedLink(v1=None, v2=None, *, uid=None, attributes=None)#

Bases: Link

Represents an two-ended edge (v1 and v2) in the vertex-edge graph. It is neither undirected nor directed, and not intended for explicit use.

See also

You may want one of these subclasses of links, which are intended for explicit use:

  • UnDirectedEdge

  • DirectedEdge

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

Instantiate an two-ended edge.

Parameters:
  • v1 (Vertex) – One end of the edge

  • v2 (Vertex) – The other end of the edge

See also

  • edgegraph.structure.link.Link.__init__(), the superclass constructor

Methods

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

Instantiate an two-ended edge.

add_to_universe(universe)

Adds this object to a new universe.

add_vertex(new)

Adds 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 one vertex of this edge.

v2

Return the other vertex of this edge.

vertices

Return a tuple of vertices this edge connects.

add_to_universe(universe)#

Adds 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)#

Adds 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

remove_from_universe(universe)#

Remove this object from the specified universe.

Parameters:

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

Raises:

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

property uid: int#

Get the UID of this object.

property universes: frozenset[Universe]#

Get the universes this object belongs to.

Note that this gives you a frozenset; you cannot add or remove universes from this attribute.

See also

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

Return type:

frozenset[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

property v1: Vertex#

Return one vertex of this edge.

Setting this attribute automatically handles link-vertex assocation updates; no extra effort is necessary.

property v2: Vertex#

Return the other vertex of this edge.

Setting this attribute automatically handles link-vertex assocation updates; no extra effort is necessary.

property vertices#

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.

Return type:

tuple[Vertex]

previous

edgegraph.structure.twoendedlink

next

edgegraph.structure.undirectededge

Contents
  • TwoEndedLink
    • TwoEndedLink.__init__()
    • TwoEndedLink.add_to_universe()
    • TwoEndedLink.add_vertex()
    • TwoEndedLink.other()
    • TwoEndedLink.remove_from_universe()
    • TwoEndedLink.uid
    • TwoEndedLink.universes
    • TwoEndedLink.unlink_from()
    • TwoEndedLink.v1
    • TwoEndedLink.v2
    • TwoEndedLink.vertices

By Misha Turnbull

© Copyright 2024, Michael Turnbull.