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:
BaseObjectDefines 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_toanduniversesattributes. 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 alsoedgegraph.structure.base.BaseObject.universes, where the latter (universes) is inherited from.Likewise, the
add_to_universe()andremove_from_universe()are inherited fromedgegraph.structure.base.BaseObject.add_to_universe()andedgegraph.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 | None) – 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 | None) – 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
Returns the universe that these laws apply to.
Returns whether or not cycles are allowed in this universe.
Returns an immutable copy of the edge whitelist rules.
Returns whether or not mixed types of links are allowed here.
Returns whether or not multiple paths between nodes are allowed in this universe.
Returns whether ot not this is a "multiverse" -- that is, whether other Universes are allowed to be vertices in this graph.
Get the UID of this object.
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 edge_whitelist#
Returns an immutable copy of the edge whitelist rules.
- Return type:
types.MappingProxyType[type, types.MappingProxyType[type, type]] or None
- 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.
- 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