Edd's Knowledge Base

A structured specification (a system model, a schema, a configuration) can be converted into a graph so that graph tools can find problems a human reviewer would miss. This note covers the pipeline pattern, the graph construction choices that mattered, and which checks paid off. The running example is a system model exported as XMI (see Model-Based Systems Engineering).

Pipeline Pattern

flowchart LR
    X["Spec file (XML)"] --> P["Adapter parser"]
    P --> I["Intermediate graph schema"]
    I --> L["Optional LLM enrichment"]
    L --> G["Graph builder"]
    I --> G
    G --> M["GNN analysis"]
    G --> R["Rule checks"]
    M --> V["Visuals and review list"]
    R --> V
  • Adapter: a parser that knows one input format (here, namespace-aware XPath over XML) and nothing else.
  • Intermediate representation (IR): a unified, format-independent schema that sits between inputs and analysis. A minimal graph IR is Node{id, type, attrs} and Edge{src, dst, type, attrs}.
  • Why an IR: everything after the adapter is format-independent, so supporting a new input format means writing one new parser and nothing else. This is the classic adapter pattern combined with a compiler-style IR.
  • LLM enrichment (optional): normalize names, infer missing relations, or tag types. Treat its output as suggestions to verify.
  • Graph builder: NetworkX for rules, PyTorch Geometric Data for Graph Neural Networks.

Graph Construction Choices

ChoiceReason
Use a multigraph (NetworkX MultiDiGraph)Two elements can share several relation types, such as a message and a connector between the same two classes, and rule checks depend on those types
Give containment (“owned by”) its own relation and treat it as contextIt records where an element lives but is not a semantic relation between elements
Keep both edge directions when feeding a GCNGCNConv passes messages only along an edge, so a one-way edge leaves the source blind to its target
Omit a wrapper root nodeA root linked to everything joins all views through one node and hides disconnected components

Why Explicit Structure Beats a Flat Export

Example: the same model analyzed two ways.

MetricFlattened exportAdapter-built graph
Nodes6,035110
Edges539249 (113 relationships + 102 containment + 34 derived)
Isolated nodes5,5290
Connected components5,5676 (largest 37)
Average degree0.184.00
Density0.000030.0367
Relation typesn/a19

About 96% of the flattened nodes were library elements. Derived edges covered operation calls, interaction participants, parameter types, and instances. Fewer but connected nodes gave about 22 times the average degree: making structure explicit mattered more than the choice of model.

Rule-Based Consistency Checks

Rules run on the graph need no training, and every finding is explainable.

CategoryChecks
ConnectivityDisconnected parts; orphan elements
NamingDuplicate elements or inconsistent spelling under the same owner; placeholder names ending in a number; unnamed elements
CyclesCyclic dependencies through Include, Dependency, Usage, Generalization, or Extend
Use casesActor without a use case; use case without an actor; use case with no behavior of the same name
OperationsOperation never called; message sent to a class that does not declare the operation; interactions disagreeing on who calls an operation
DeploymentComponent without an artifact; artifact not deployed; dependency crossing layers; layers disagreeing
Control flowDecision node with one way out (a merge modeled as a decision); decision branch without a guard or with a vague guard; join modeled as a fork

One caution from hand review: a use case that is included by another needs no actor of its own, so the naive “use case without actor” rule gave false alarms until it was refined.

On the 110-node example the rules produced 32 findings, more than the GNN surfaced.

General Lesson

Build the graph, run simple rules first, then use ML to prioritize where a reviewer should look. Predictions are prompts for review, not corrections. The evaluation of the ML step on this graph is in Graph Neural Networks.

Sources

  • NetworkX documentation: MultiDiGraph
  • Statistics and findings come from the author’s analysis of one example model.

Verification: the pipeline description and rule list reflect the author’s own work; the NetworkX link points to the documentation page and was not re-fetched.