moon_graphdesk

    Property graph import, indexing, query and impact analysis

    graphdesk
    cli
    moonbit
    Download zip
    Author
    Version
    0.2.0
    License
    Apache-2.0
    Last updated
    18 days ago
    Downloads
    34

    No dependencies

    #Moon GraphDesk

    Property graph queries, implemented in MoonBit with a JSON CLI and reusable library API.

    • Repository: https://github.com/yyqdbngt/moon-graphdesk
    • Package: yyqdbngt/moon_graphdesk@0.2.0
    • License: Apache-2.0
    • Release scope: 0.1.0 initial implementation. The broader competition proposal in docs/proposal.md is a reference design, not a claim that every planned capability is implemented.

    #Implemented

    Node/edge/property import with identity and endpoint checks; outgoing and incoming indexes; typed/property selection; depth-limited forward and reverse traversal; nonnegative weighted shortest paths; iterative strongly connected components; cycles/isolated-node summaries; snapshots.

    #Build and run

    Use MoonBit and Node.js 24. The core library supports JS, wasm, wasm-gc and native; the filesystem/HTTP/process CLI is JS only.

    moon update moon build --target js moon run cmd/main --target js -- examples/scenario-1.json node _build/js/debug/build/cmd/main/main.js examples/scenario-1.json

    Pass - to read a UTF-8 JSON request from stdin. A single request must be at most 16 MiB. Successful requests print one JSON result; invalid requests exit nonzero. The host runner is a separate process and does not edit the input request file.

    #Library use

    moon add yyqdbngt/moon_graphdesk@0.2.0

    In the consumer's moon.pkg:

    import {
    "yyqdbngt/moon_graphdesk" @engine,
    "moonbitlang/core/json",
    }

    fn example(request : Json) -> Json raise {
    @engine.execute(request)
    }

    execute(Json) -> Json raise is the standard JSON boundary. from_json, Value::to_json, and run(Value) -> Value raise provide a typed semantic value interface. Object ordering is not significant; numeric values use finite Double. Public domain functions are listed in pkg.generated.mbti.

    #Tests

    moon test --target js moon test --target wasm moon test --target wasm-gc moon test --target native # requires a C compiler moon build --target js node scripts/check.mjs python -B scripts/reference.py

    There are 10 checked fixture cases in tests/cases.json, executed both in MoonBit white-box tests and through the actual Node CLI. Independent reference checks use Python's standard library or separately written algorithms. Fixtures are synthetic and are not presented as production adoption evidence. See input and output examples and current boundaries.

    #Current boundaries

    An in-memory property graph. Shortest paths use O(V²) Dijkstra and reject negative weights. Components are sorted for reproducible output. Impact analysis follows incoming edges up to the requested depth (default 1). No graph query language or disk database. Numeric weights use finite Double. Snapshots are JSON graph data validated again on import.

    See source and dependency attribution. This release does not establish competition eligibility or organizer acceptance.

    #2026-10-18 follow-up

    新增 topology,按 prerequisite→dependent 的边方向计算拓扑层次与可执行前缀,报告环组件及被环阻塞的下游节点。平行边按实际入度计数,孤立节点进入首层;遇到环不伪造完整拓扑序。修复遍历深度的小数截断及过大参数。

    拓扑以输入图边方向为准,不自动猜测业务依赖方向。环和阻塞报告不负责修改关系;最短路径仍使用非负权 Dijkstra 的内存实现。

    Repository release: 0.2.0; installable MoonCakes module: yyqdbngt/moon_graphdesk@0.2.0. Earlier repository 1.0.0 labels are retained as history; the module uses the registry-compatible zero-major sequence.

    Current source contains 12 MoonBit test declarations and 10 CLI fixtures (generated fixture tests are included in the declaration count). Run python -B scripts/followup_reference.py for independent follow-up oracles and examples/followup-20261018.json for the new scenario.

    InputError

    pub(all) suberror InputError {
    InputError(String)
    } derive(Eq, Show)

    Graph

    pub struct Graph {
    nodes : Map[String, Value]
    edges : Array[Value]
    outgoing : Map[String, Array[Int]]
    incoming : Map[String, Array[Int]]
    }

    Graph::shortest_path

    fn Graph::shortest_path(self : Graph, start : String, target : String, edge_type? : String) -> Value raise

    Graph::snapshot

    fn Graph::snapshot(self : Graph) -> Value

    Graph::strong_components

    fn Graph::strong_components(self : Graph) -> Array[Array[String]] raise

    Graph::topology

    fn Graph::topology(self : Graph) -> Value raise

    Graph::traverse

    fn Graph::traverse(self : Graph, start : String, depth : Int, reverse? : Bool, edge_type? : String) -> Value raise

    Value

    pub(all) enum Value {
    Null
    Bool(Bool)
    Number(Double)
    String(String)
    Array(Array[Value])
    Object(Map[String, Value])
    } derive(Eq,
    Debug
    )

    Value::stringify

    fn Value::stringify(self : Value) -> String

    Value::to_json

    fn Value::to_json(self : Value) -> Json

    execute

    fn execute(request : Json) -> Json raise

    from_json

    fn from_json(value : Json) -> Value

    load_graph

    fn load_graph(source : Value) -> Graph raise

    run

    fn run(request : Value) -> Value raise