OGDF → BRIDGE → GAV-VR

Run the C++.
See the graph.

Connecting OGDF to GAV-VR via automated Lua bindings.

BRIDGE (Binding Runtime Interface for Dynamic General Execution) is a hybrid architecture that connects the Open Graph Drawing Framework (OGDF) to the GAV-VR viewer. It uses an automated binding generation pipeline (LibClang AST analysis → sol2/Lua bindings), a dual execution strategy (native P/Invoke for low latency, network mode for cloud offloading), and thread-local Lua state management for memory safety. While demonstrated with OGDF and GAV-VR, the architecture is designed to generalize to other C++ graph libraries and Unity-based visualization environments.

No headset required Dual execution: native + network Thread-local Lua state (TLS) Whitelist security policy LibClang AST codegen

Comparison

Direct OGDF vs. OGDF through BRIDGE

A headset is optional for verifying the result. The VR renderer is one consumer of the bridge, not a requirement for checking it.

Performance

High-Performance Integration

Integrating unmanaged OGDF (C++) into the managed GAV-VR (C# / Unity) runtime with minimal execution overhead, preserving native graph drawing performance.

Automation

Automated Binding Pipeline

Leveraging compiler-based AST analysis via LibClang to autonomously generate sol2/Lua bindings, eliminating manual wrapper code and technical debt. The analysis is target-agnostic — future Python or JavaScript backends would reuse it unchanged.

Architecture

Scalable Dual Execution

Providing dual execution modes (local native P/Invoke for sub-millisecond VR latency vs. remote REST server for heavy graphs) with Thread-Local Storage (TLS) memory isolation.

Live comparison

One case, two paths, side by side

Pick a predefined C++/Lua layout pair and graph to inspect the code. Connect a running Engine to execute live layouts and compare the C++ vs. Lua results side by side — as dual SVG outputs in Pane A, and as the same dual outputs in an interactive 3D view (Three.js) in Pane B.

No file loaded
Values are written into the Lua script as literals.

Both sources are sent to the Engine for execution via /api/v1/execute_sequential. The Engine enforces a whitelist sandbox — only base, math, table, string libraries are loaded.

Engine status Checking Engine connection...

Direct OGDF · 2D reference

A · C++ direct

OGDF via BRIDGE → GAV-VR

B · via BRIDGE

Run the Engine to explore its GraphML result.

Drag to orbit · right-drag to pan · scroll to zoom · use Labels to show or hide node names · click a node to focus.

What to compare

Layouts may differ between engines or runs; the claim to verify is that the same graph, algorithm, and settings produce a consistent result through both paths.

Run stages

Stages are reported by the runner while your job progresses. No timings are invented in the browser — published numbers come from the published experiments.

Engine integration contract

Endpoint

POST /api/v1/execute_sequential — the Engine's single documented route (mirroring the C++ ExecutionController). The request carries the Lua script name, the input graph, and script parameters.

Operational parameters per NetworkConfiguration.json: timeout: 30 seconds and retryCount: 3 for robustness against transient network instability.

Native mode bypasses HTTP entirely: the C# NativeBridge imports InitializeBindings, ExecuteScript, and FreeExecutionResponse via P/Invoke.

Request / response shape

Request: { "script", "input", "params" } — e.g. { "script": "hierarchical.lua", "input": "n100e100.graphml", "params": { "layerDistance": 3.0 } }.

Response: execution results with the output graph (nodes with x, y, z coordinates and edges). Large outputs are transmitted via a Base64 chunking protocol (MAX_CHUNK_DATA_SIZE = 1 MB).

On AWS, the API Gateway fronts the EC2-hosted Engine with HTTPS and IAM authorization; clients sign requests via SigV4. The Engine enforces a whitelist sandbox (only base, math, table, string libraries) and a 2000 ms execution timeout per script.

About this demo

Pane A renders only the SVG the Engine returns; until the Engine is connected it stays empty — that is the correct state, and the page ships no sample graphs. Pane B parses GraphML files directly in the browser and shows their original x/y/z coordinate layout in a 3D projection — it works without the Engine. Every output a reviewer sees was therefore produced by the published pipeline: the same Lua script executed through the BRIDGE Engine in Native (P/Invoke) or Network (REST) mode, with node coordinates and edges returned to this page unmodified. The Engine enforces a whitelist sandbox and a fresh Lua state per execution.

Video

BRIDGE in motion

A short walkthrough of the full pipeline: OGDF layouts executed through the BRIDGE Engine and rendered in GAV-VR — direct C++ execution next to the Lua path via BRIDGE.

Hosted on YouTube (unlisted) — playback quality adapts to your connection. Watch on YouTube ↗

Architecture

What BRIDGE actually is

BRIDGE is a hybrid integration architecture, not a second implementation of OGDF. It uses a three-layered approach: (1) an Automatic Binding Generation Tool that parses OGDF headers via LibClang AST analysis and generates sol2/Lua bindings from a declarative bindings_config.yaml configuration, (2) a BRIDGE Engine with dual execution modes — Native Interface (P/Invoke for low-latency local execution) and Network Interface (cloud offloading for compute-intensive tasks), and (3) a C# Client in GAV-VR managing execution strategies and UI. Thread-local Lua state (TLS) ensures memory safety and concurrency, and the generated bindings infer each class's memory ownership so Lua's garbage collector never frees objects the Engine manages; a strict whitelist policy enforces security. The design is constrained by VR's requirement of a minimum 72 frames per second: heavy graph processing must never block the main rendering thread, which is why the client runs all layout work asynchronously.

Offline Codegen LibClang AST Analysis YAML Config → sol2/Lua Bindings Automated — no manual wrappers BRIDGE Engine Native Interface P/Invoke (C# ↔ C++) Low-latency local execution Thread-local Lua state (TLS) Network Interface REST API Cloud offloading Whitelist security policy GAV-VR C# Client Execution Strategy Selection · UI Control · Graph Rendering 🔒 Whitelist policy · 🧵 Thread-local Lua state (TLS)
Figure 1 · The BRIDGE architecture: offline binding generation, dual execution engine (native P/Invoke + network REST), and GAV-VR client. Thread-local Lua state and whitelist security span both execution paths.
Detailed component view: codegen, engine, and client modules
1 · Offline codegen (pre-build)InputsConfig (.yaml & .env)OGDF headers & wrappersIO & configurationEnv ReaderYaml ReaderHeader CollectorStatic analysisClang Analyzer (LibClang)AST VisitorCode synthesisSol2 GeneratorOutputGenerated Lua bindings (.cpp)2 · BRIDGE engine (C++)Binding layerGenerated bindingsManual registersLua binderScripting coreLua state managerLua script runnerScript executorOGDF libraryExecution logicExecution engineExecution serviceNative interfaceInterop C APIInterop bridgeResponse factoryNetwork interfaceServer manager (Oat++)Execution controllerMapper (DTOs)3 · GAV-VR client (C#, Unity)Scripts & configConfigurations & scriptsInfrastructureApp servicesResource loaderUI & controlScript list controllerIntegration controllerModal controllerParameter extractorScript builderExecution strategyExecutor factoryNative executorNetwork executorNative bridge (P/Invoke)Async jobsGraph update jobMetadata (class / enum / func)usesgets statecallserror casesuccess caseusesBase64 decode / encodeselectsusesusesmode: nativemode: networkFFI callHTTP / JSON (Base64)on success

Component view of Figure 1: codegen modules, BRIDGE engine internals (binding, scripting, execution, native and network interfaces), and GAV-VR client modules. Highlighted nodes are the two execution paths.

sol2 is the C++/Lua binding library the generated module is built on — it is the mechanism, not the research claim. The claim is that selected OGDF functionality becomes callable from GAV-VR's Lua runtime with its parameters passed through unchanged, and that the resulting layouts are identical to what OGDF produces directly. BRIDGE uses thread-local Lua state (TLS) for memory safety, and enforces a whitelist security policy. Dual execution modes (Native P/Invoke + Network REST) share the same automated binding layer. The Codegen pipeline's AST analysis is agnostic to the target scripting language — other languages can be supported by implementing a language-specific generator backend — and the three-layer pattern (P/Invoke base, Lua intermediary, automated binding generation) is designed to generalize to other C++ graph libraries and Unity-based visualization environments.

Evaluation

Overhead, concurrency and isolation

Measured in an isolated containerized environment (Ubuntu 24.04, GCC 13.3.0, Lua 5.4, oat++ 1.3.1), with the test client on a separate Windows host. Overhead is the difference between the client-side round trip and the server-side script execution time. Timings are absolute values from a single consumer-grade machine; full methodology, hardware specs, and raw data: thesis, Chapter 5.

≤ 45 ms Peak bridge cost per request Measured 7.7–45 ms across all workloads, 8 to 1,000 nodes — does not scale with graph size
0.0% Error rate under load I/O-bound workload, 100 concurrent threads, 1.2 MB graphs
+2.23 MB Memory growth over 2,000 requests Plateaued — no linear leak in the C++/Lua interop layer

Round-trip overhead

Mean time per request for four representative workloads, from trivial to data-heavy.

Workload Graph · script Round trip (ms) Script (ms) Overhead (ms)
Baseline Cube (8 nodes) · orthogonal.lua 53.86 9.05 44.81
Algorithmic n100e100 (100 nodes) · hierarchical.lua 44.29 36.63 7.66
CPU stress Mesh (24 nodes) · orthogonal.lua 69.30 24.32 44.98
Data volume n1000e1000 (1,000 nodes) · energybased.lua 2448.84 2416.48 32.36

The bridge cost is bounded, not proportional: from the 8-node baseline to the 1,000-node workload, computation grows from 9 ms to 2,416 ms, while the per-request overhead stays below 45 ms in every scenario (7.7–45 ms measured). Its components — TCP handshake, HTTP header parsing, Lua state initialization, payload transfer — vary with workload type and connection behavior, not with graph size, so the decoupled architecture does not become the bottleneck as graphs scale.

Concurrency

Isolation under load

Each server thread owns an isolated Lua VM via thread-local state — no global locks. At 100 concurrent threads the I/O-bound workload (1.2 MB graphs) completed with a 0.0% error rate at ~64 req/s; CPU-bound throughput peaked at 323.85 req/s. The rare errors at 50–100 CPU-bound threads were Docker network-bridge saturation, not Engine faults — the connection-heavy scenario outpaced the container's network stack.

Memory

No linear leaks

Resident Set Size was monitored via the Docker statistics API across 500 to 2,000 sequential requests in three stress scenarios (heavy object churn, fragmentation, large buffers). Growth plateaued in all three — characteristic of Lua 5.4's incremental garbage collector, not a leak.

Sandbox

Restricted Lua environment

Five injected payloads — os.execute, io.open, dynamic table-name reconstruction, load(), and an infinite loop — were all neutralized. The whitelist loads only base, math, table, string, so dangerous namespaces are unreachable regardless of obfuscation; a 2,000 ms watchdog stops runaway scripts.

Case Studies

Algorithmic fidelity in VR

Four layout algorithms were executed natively and through BRIDGE, then rendered in GAV-VR and compared against OGDF's own 2D reference output. Each scenario was run five times in a randomized sequence, alternating Native and Network modes.

Case 1: Orthogonal Layout

Native: 29 ms · Network: 35 ms

Applied to Mesh.graphml (24 nodes). Planarization and orthogonal routing produce a clear grid topology.

Observed: Node coordinates match the OGDF reference grid exactly.

Case 2: PivotMDS

Native: 1.8 ms · Network: 4.2 ms

Applied to Mesh.graphml (24 nodes). Multidimensional scaling projects the graph into spatial (x, y, z) coordinates.

Observed: Fastest algorithm tested. GAV-VR forms a coherent 3D cylinder — direct 3D coordinate streaming from Lua works without collapsing to a planar layout.

Case 3: Hierarchical (Sugiyama)

Native: 71 ms · Network: 70–80 ms

Applied to n100e100.graphml (100 nodes). Layered drawing: ranking, crossing minimization, hierarchy layout.

Observed: The global top-down layering is preserved. Some sub-branches appear with flipped orientation in the GAV-VR parser — a frontend artifact, not a layout error.

Case 4: Energy-Based (FMMM)

Native: 2.65 s · Network: 2.86 s

Applied to n1000e1000.graphml (1,000 nodes, ≈1.21 MB). Multilevel force-directed layout at scale.

Observed: The dense central cluster with peripheral chains is preserved. At this size the dominant cost is layout computation — and VR rendering itself, not the bridge, becomes the bottleneck.

Known limitations

  • Orientation: Some hierarchical sub-branches are drawn with a different orientation than the reference. The cause is in the frontend parser, not in the layout result.
  • Scale: Graphs with about 1,000 nodes need server-side layout, and rendering that many GameObjects causes frame drops in VR. Level-of-detail clustering is future work.
  • Validity: Benchmarks ran in local Docker (no wide-area latency), on a subset of OGDF's algorithms, from a single client host, and without a monolithic C++ baseline — the metrics prove internal stability and scalability, not relative gains over alternative architectures.

For every evaluated case, the SVG and GraphML outputs of direct C++ execution and of BRIDGE Lua execution are topologically identical — the interoperability layer transmits all layout data, node coordinates, and edge routing points without error. The visual differences seen in VR come from the GAV-VR GraphML parser, not from the layout calculation.

Reproduce

Four commands from clone to render

Everything a reviewer needs is in the repository: pinned dependencies, the example graphs, and the exact commands below. No headset is required for any verification step.

Step 1

Build BRIDGE

Clone the repository, declare the OGDF classes, functions and enums to expose in bindings_config.yaml, and compile — the bootstrap script runs Codegen on that file as a pre-build step. Hand-written C++ wrappers and manual sol2 registrations are picked up automatically for the cases the generator cannot resolve on its own.

terminal
$ git clone <repository-url> && cd bridge
$ cp .env.example .env
# edit .env: LIBRARY_INCLUDE_PATH, WRAPPER_DIR, MANUAL_REGISTER_DIR, UNITY_PROJECT_PATH
# edit bindings_config.yaml: classes, free_functions, enums to expose
# Windows (PowerShell):
$ ./bootstrap.ps1 -BuildType Release -InstallDeps
# Linux:
$ sudo ./bootstrap.sh --build-type Release --install-deps
bindings_config.yaml
# OGDF entities to expose to Lua — member variables, properties
# and nested enums of a class are detected and bound automatically.
classes:
  - name: Graph
    methods:
      - numberOfNodes
  - name: SugiyamaLayout
    methods:
      - setRanking
      - setLayout
      - call
  - name: PlanarSubgraphFast
    types:
      - int  # → Lua class PlanarSubgraphFastInt
free_functions:
  - randomSimpleGraph
  - drawSVG
enums:
  - RemoveReinsertType
Step 2

Verify the Engine build

Confirm the build artifacts exist: Engine.dll (native mode) or Engine.exe (network server).

terminal
# Native mode artifact (DLL, deployed to Unity Plugins):
$ ls build/Engine.dll
# Network mode artifact (standalone server):
$ ls build/Engine.exe
Step 3

Run it through BRIDGE → GAV-VR

Native mode: the Engine.dll is loaded by GAV-VR via P/Invoke (no CLI needed). Network mode: start the Engine server, then point GAV-VR at it. A headset is optional — GAV-VR also renders in a normal desktop window.

terminal
# Native mode: Engine.dll is auto-deployed to the Unity project
# and loaded via P/Invoke by the NativeExecutor — no CLI command needed.

# Network mode: start the Engine server:
$ ./Engine.exe --host 0.0.0.0 --port 8000

# In GAV-VR: Options Panel → Execution Mode → Native/Network
# NetworkConfiguration.json: { "host": "localhost", "port": 8000, "endpoint": "/api/v1/execute_sequential" }

# Optional Docker (exposes port 8000):
$ docker run --rm -p 8000:8000 -v $PWD/data:/data bridge-engine:latest
Step 4

Or verify against the hosted runner

The Engine's Network mode exposes a REST API. Send a script-execution request with curl. On AWS, the API Gateway endpoint requires IAM/SigV4-signed requests.

terminal
$ curl -X POST <engine-host>:8000/api/v1/execute_sequential \
     -H 'Content-Type: application/json' \
     -d '{"script": "hierarchical.lua", "input": "n100e100.graphml", "params": {"layerDistance": 3.0, "nodeDistance": 3.0}}'
# AWS API Gateway (IAM SigV4 signing required):
$ curl -X POST <gateway-host>/api/v1/execute_sequential \
     -H 'Authorization: AWS4-HMAC-SHA256 ...' -d '...'
Native modeLocal P/Invoke execution for low-latency layout.
Network modeCloud offloading via REST for compute-intensive tasks.
OutputGraph nodes and edges are the primary result. Large payloads are transmitted via Base64 chunking (1 MB chunks). Failure details surfaced on error.
SafetyWhitelist sandbox loads only base, math, table, string libraries; thread-local Lua state (TLS) isolates concurrent executions; 2000 ms execution timeout.

Resources

Links and code

Cite

BibTeX

igidov2025bridge.bib