SpaceRelationGraph

Source:

Local role: Validated relation graph over spaces.

Big-picture role: Topology query and validation layer used by World and by Sensor through Perception.

Inheritance:

  • dataclass

Parameters and fields:

Methods:

  • mutation: add_relation, remove_relation
  • queries: relations_from, relations_to, children_of, parents_of, neighbors_of, intersects_with
  • serialization: to_dict, from_dict

Example:

from ometeotl_core.model.space_relations import SpaceRelationGraph, SpaceRelation

graph = SpaceRelationGraph()
graph.add_relation(SpaceRelation(
    source_space_id="zone-1", target_space_id="zone-2", relation_type="adjacent"
))
graph.add_relation(SpaceRelation(
    source_space_id="zone-2", target_space_id="zone-3", relation_type="adjacent"
))

neighbors = graph.neighbors_of("zone-1")      # ["zone-2"]
children = graph.children_of("zone-1")        # directed children
data = graph.to_dict()

See also:

Ometeotl

A Python library to build complex multi-agent simulations, wargames, and AI-driven strategies