Skip to main content

Module para

Module para 

Source
Expand description

para_graph and para_graph_fixed: shape-aware structural fold over a graph view.

Ported from Pattern.Graph.Transform.paraGraph and paraGraphFixed in the Haskell reference implementation.

§Processing order: topo_shape_sort

Elements are sorted in two passes before the fold begins:

Pass 1 — Inter-bucket ordering (fixed shape class priority):

GNode < GRelationship < GWalk < GAnnotation < GOther

This ensures cross-class containment dependencies are satisfied: nodes (atomic) before relationships (contain nodes), relationships before walks, walks before annotations (can reference any shape below them), and annotations before other (GOther is unconstrained).

Pass 2 — Within-bucket ordering (Kahn’s algorithm): Applied to the GAnnotation and GOther buckets only. Direct sub-elements (Pattern::elements) that belong to the same bucket are treated as dependencies — they must appear before the element that contains them.

GNode, GRelationship, and GWalk require no within-bucket sort: by the definition of classify_by_shape, their sub-elements always belong to a lower-priority bucket.

Cycle handling: If a dependency cycle is detected within a bucket (e.g., annotation A references annotation B which references A), the cycle members are appended after all non-cycle elements in their encountered order. No error is raised. Cycle members receive sub_results = &[] for the other cycle members (soft-miss). Callers should treat sub_results as best-effort.

Functions§

para_graph
Single-pass shape-aware structural fold over a GraphView.
para_graph_fixed
Fixed-point shape-aware fold for iterative convergence.