Skip to main content

Module engine

Module engine 

Source

Functions§

bfs
BFS traversal result — node IDs in visit order.
has_cycle
Cycle detection: returns true if the graph contains a cycle.
impact_analysis
Impact analysis: reverse BFS from a node — “what depends on this?” Traverses incoming edges to find all nodes that transitively depend on node_id.
pattern_match
Pattern match: find chains matching a sequence of node types connected by edges. E.g., ["signal", "rule", "plan", "action"] finds all MAPE-K loops. Returns list of chains, each chain being a list of node_ids. Find chains of nodes matching a type sequence (e.g., ["signal", "rule", "plan"]).
shortest_path
Shortest path between two nodes (unweighted BFS). Returns the path as a list of node IDs (including start and end), or None if no path exists.
subgraph
Extract subgraph: all nodes and edges within N hops of a start node. Returns (node_ids, edge_ids).
topological_sort
Topological sort of nodes connected by directed edges. For DAGs only — returns None if a cycle is detected.