edgegraph.structure.universe.UniverseLaws#

class edgegraph.structure.universe.UniverseLaws(edge_whitelist=None, mixed_links=False, cycles=True, multipath=True, multiverse=False, applies_to=None)#

Bases: BaseObject

Defines the rules that apply to a universe.

This class is effectively a namespace that controls the rules / constraints that a universe must obey.

Pay close attention to the difference in meaning between the applies_to and universes attributes. The former (applies_to) refers to the universe that these laws apply to. This object is not necessarily a vertex / object present in that universe. The latter (universes) is the set of universes this object appears in; see also edgegraph.structure.base.BaseObject.universes, where the latter (universes) is inherited from.

Likewise, the add_to_universe() and remove_from_universe() are inherited from edgegraph.structure.base.BaseObject.add_to_universe() and edgegraph.structure.base.BaseObject.remove_from_universe().

__init__(edge_whitelist=None, mixed_links=False, cycles=True, multipath=True, multiverse=False, applies_to=None)#

Instantiate a set of universal laws.

Important

After creation / instantiation, the attributes of this object become read-only!

Parameters:
  • edge_whitelist (dict) – dictionary of types of links allowed

  • mixed_links (bool) – whether or not mixed link types are allowed

  • cycles (bool) – whether or not cycles are allowed

  • multipath (bool) – whether or not multiple paths between nodes are allowed (not necessarily cycles)

  • multiverse (bool) – whether or not universes may be connected inside this universe

  • applies_to (Universe) – the universe these laws apply to

Methods

__init__([edge_whitelist, mixed_links, ...])

Instantiate a set of universal laws.

add_to_universe(universe)

Adds this object to a new universe.

remove_from_universe(universe)

Remove this object from the specified universe.

Attributes

applies_to

Returns the universe that these laws apply to.

cycles

Returns whether or not cycles are allowed in this universe.

edge_whitelist

Returns an immutable copy of the edge whitelist rules.

mixed_links

Returns whether or not mixed types of links are allowed here.

multipath

Returns whether or not multiple paths between nodes are allowed in this universe.

multiverse

Returns whether ot not this is a "multiverse" -- that is, whether other Universes are allowed to be vertices in this graph.

uid

Get the UID of this object.

universes

Get the universes this object belongs to.

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

property applies_to: Universe#

Returns the universe that these laws apply to.

property cycles: bool#

Returns whether or not cycles are allowed in this universe.

property edge_whitelist#

Returns an immutable copy of the edge whitelist rules.

Return type:

types.MappingProxyType[type, types.MappingProxyType[type, type]] or None

Returns whether or not mixed types of links are allowed here.

property multipath: bool#

Returns whether or not multiple paths between nodes are allowed in this universe.

property multiverse: bool#

Returns whether ot not this is a “multiverse” – that is, whether other Universes are allowed to be vertices in this graph.

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]