import-json-uses-topological-sort

IN premise

`api.import_json()` reconstructs networks via a multi-pass topological sort loop — repeatedly adding nodes whose dependencies are already loaded — with a force-add fallback for cycles or missing deps.

Summary

When importing a saved belief network from JSON, the system doesn't just blindly load nodes in file order. It uses a topological sort strategy, processing nodes only after their dependencies are already in place, looping until everything is loaded. If it hits a cycle or a missing dependency that would cause a deadlock, it forces the remaining nodes in anyway so the import always completes rather than failing partway through.

Details

Sourceentries/2026/04/24/reasons_lib-api.md