neofoam.framework.graph.sorter

Topological sort abstractions and implementations.

class neofoam.framework.graph.sorter.NetworkxTopologicalSorter(key: Callable[[str], Any] | None = None)[source]

Bases: object

Topological sorter implementation based on networkx.

sort(graph: DiGraph, key: Callable[[str], Any] | None = None) list[str][source]

Return nodes in topological order.

Per-call key overrides the instance-level key; otherwise the instance key is used; otherwise sort lexicographically by node name.

class neofoam.framework.graph.sorter.TopologicalSorter(*args, **kwargs)[source]

Bases: Protocol

Interface boundary for DAG sorting backends.

sort(graph: DiGraph, key: Callable[[str], Any] | None = None) list[str][source]

Return nodes in valid topological order, with optional tie-break key.