path
RelationalAI path library: pattern-based matching and enumeration of paths through a knowledge graph.
PyRel natively expresses fixed-length paths over concepts and relationships. This
builtin standard library adds path, which builds a PathPattern — a reusable
specification of an alternating sequence of nodes (concepts) and edges (relationships).
Patterns support variable-length paths via PathPattern.repeat, and
PathPattern.all_paths enumerates every matching path as a
PathTraversal — a unique per-path identifier plus the nodes and relationships
visited along the way.
Examples
Enumerate every 1-to-3-hop path starting from Alice:
from relationalai.semantics import Model, String
m = Model("Social")Person = m.Concept("Person", identify_by={"name": String})Person.follows = m.Relationship(f"{Person:a} follows {Person:b}")# ... populate people and `follows` edges ...p = m.path(Person.follows.repeat(1, 3)).where(Person.name == "Alice").all_paths()m.select(p, p.length, p.nodes["index"], Person(p.nodes).name).inspect()Notes
This library is currently in preview. Preview features are publicly available but RelationalAI does not provide stability, SLA, or technical support commitments. They are intended for evaluation and testing purposes only and should not be used in production applications without consultation with the RelationalAI team.
Attributes
Attributes exposed by this module.
relationalai.semantics.std.path.api.Functions
Functions exposed by this module.
PathPattern from a sequence of nodes and edges. Re-exported from relationalai.semantics.std.path.api.Classes
Classes exposed by this module.
relationalai.semantics.std.path.api.