INNER CODE UNIT · Python

topological_order

IvanMurzak/Unity-MCP · .github/scripts/chain_feed.py:624

def topological_order(node_ids):
    """Producers before consumers over RECIPES; ties break on node id (plan reproducibility)."""
    scope = set(node_ids)
    producers = {}
    for nid in scope:
        producers[nid] = {
            edge["node"] for edge in RECIPES[nid]["consumes"] if edge["node"] in scope
        }
    order = []
    remaining = dict(producers)
    while remaining:
        ready = sorted(nid for nid, deps in remaining.items() if not deps)
        if not ready:
            raise Refusal(
                "the consumption graph has a cycle; nodes still blocked: "
                + ", ".join(sorted(remaining))
            )
        for nid in ready:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…