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.
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.
High-Performance Integration
Integrating unmanaged OGDF (C++) into the managed GAV-VR (C# / Unity) runtime with minimal execution overhead, preserving native graph drawing performance.
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.
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.
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++ directOGDF via BRIDGE → GAV-VR
B · via BRIDGEDrag to orbit · right-drag to pan · scroll to zoom · use Labels to show or hide node names · click a node to focus.
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.
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.
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.
Detailed component view: codegen, engine, and client modules
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.
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.
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.
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.
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 msApplied to Mesh.graphml (24 nodes). Planarization and orthogonal routing
produce a clear grid topology.
Case 2: PivotMDS
Native: 1.8 ms · Network: 4.2 msApplied to Mesh.graphml (24 nodes). Multidimensional scaling projects the
graph into spatial (x, y, z) coordinates.
Case 3: Hierarchical (Sugiyama)
Native: 71 ms · Network: 70–80 msApplied to n100e100.graphml (100 nodes). Layered drawing: ranking, crossing
minimization, hierarchy layout.
Case 4: Energy-Based (FMMM)
Native: 2.65 s · Network: 2.86 sApplied to n1000e1000.graphml (1,000 nodes, ≈1.21 MB). Multilevel
force-directed layout at scale.
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.
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.
$ 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
# 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
Verify the Engine build
Confirm the build artifacts exist: Engine.dll (native mode) or Engine.exe (network server).
# Native mode artifact (DLL, deployed to Unity Plugins):
$ ls build/Engine.dll
# Network mode artifact (standalone server):
$ ls build/Engine.exe
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.
# 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
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.
$ 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 '...'
base, math, table, string libraries; thread-local Lua state (TLS) isolates
concurrent executions; 2000 ms execution timeout.Resources
Links and code
Cite
BibTeX