Mastering Graph Traversal in ArangoDB: Building High-Performance Path Finding APIs with .NET 10

January 30, 2026
Graph databases excel at modeling relationships between entities, making them ideal for applications like social networks, recommendation engines, knowledge graphs, and fraud detection. In this article, we’ll explore ArangoDB—a multi-model database that combines document storage with graph capabilities—and build a .NET 10 Web API for efficient graph traversal.
Why Graph Databases Matter
Traditional relational databases struggle with relationship-heavy queries. Finding connections between entities often requires multiple JOINs, leading to poor performance as data grows. Graph databases model relationships as first-class citizens, making traversal operations extremely efficient.
ArangoDB offers a unique advantage: it’s a multi-model database supporting documents, graphs, and key-value storage in one system. You can store complex JSON documents and traverse relationships between them without managing separate database systems.
What We’re Building
We’ll create a Knowledge Graph API that demonstrates essential graph patterns:
- Path Finding – Discover routes between two concepts
- Network Expansion – Explore all connections from a starting point
- Full-text Search – Find nodes by name across collections
The complete source code is available on GitHub: arangodb-dotnet-graph-api
Core Graph Concepts
Before diving into code, let’s understand the key concepts:
- Vertices (Nodes) – Entities in your graph (stored as documents)
- Edges – Relationships connecting vertices (stored in edge collections)
- Paths – Sequences of vertices connected by edges
- Traversal – The operation of following edges to discover connected nodes
BFS vs DFS
ArangoDB supports two traversal strategies:
- BFS (Breadth-First Search) – Explores all nodes at depth N before depth N+1. Finds shortest paths first. Use when path length matters.
- DFS (Depth-First Search) – Explores as deep as possible before backtracking. Uses less memory. Use when you need any path quickly.
Architecture Overview
The solution follows clean architecture principles with three layers:
- GraphApi (Presentation) – ASP.NET Core Web API exposing RESTful endpoints
- GraphApi.Data (Infrastructure) – ArangoDB connectivity using ArangoDBNetStandard
- GraphApi.Models (Domain) – Document models and DTOs shared across layers
Key design decisions:
- IOptions pattern for configuration management
- Dependency injection for testability and loose coupling
- Typed documents with NJsonSchema validation
ArangoDB Configuration
First, configure the connection settings using the Options pattern:
Data Modeling
Our knowledge graph has four vertex collections:
- Concepts – Ideas, technologies, or entities (e.g., “.NET”, “Kubernetes”)
- Topics – Categories that group concepts (e.g., “Cloud Computing”)
- Resources – Learning materials (articles, videos, tutorials)
- Authors – Content creators
Connected by a single edge collection Relationships with typed connections:
BFS Path Finding with PRUNE
The first pattern finds all paths between two nodes. The key optimization is PRUNE, which stops exploring a branch once the target is found:
Understanding the AQL Query
FOR v, e, p IN 1..@maxDepth ANY @startVertex
@@edgeCollection
PRUNE v._id == @targetVertex
OPTIONS { bfs: true, uniqueVertices: 'path' }
FILTER v._id == @targetVertex
LIMIT 50
RETURN { vertices: p.vertices, edges: p.edges }
FOR v, e, p– v=current vertex, e=current edge, p=path objectIN 1..@maxDepth– Traverse 1 to maxDepth edgesANY– Follow edges in both directionsPRUNE– Stop this branch when condition is true (huge optimization!)bfs: true– Use breadth-first searchuniqueVertices: 'path'– Allow revisiting nodes on different paths
Network Expansion
The second pattern discovers all nodes reachable from a starting point, tracking the shortest path to each:
uniqueVertices Options
The uniqueVertices option dramatically affects traversal behavior:
| Option | Behavior | Best For |
|---|---|---|
'global' | Each vertex visited once total | Network visualization, shortest paths |
'path' | Each vertex once per path | Finding all routes between nodes |
'none' | No restrictions (allows cycles!) | Rarely used in production |
API Design
The API exposes clean endpoints for graph operations:
Running the Project
1. Start ArangoDB
docker-compose up -d
2. Create the Database
Open http://localhost:8529, login with root/rootpassword, and create a database named knowledge_graph.
3. Run the API
cd src/GraphApi
dotnet run
The Swagger UI is available at the root URL for testing endpoints.
Performance Tips
- Always use LIMIT – Graph traversals can explode on connected data
- Index edge collections – Create composite index on (_from, _to)
- Use PRUNE – Stop exploring when you’ve found what you need
- Choose uniqueVertices wisely – ‘global’ is fastest but misses some paths
- Consider depth limits – Each additional hop multiplies results exponentially
Conclusion
ArangoDB’s graph capabilities combined with .NET’s strong typing create a powerful platform for relationship-heavy applications. The patterns shown here—BFS path finding with PRUNE, network expansion with path tracking, and schema validation—form the foundation for more complex graph operations like bidirectional search, weighted shortest paths, and community detection.
The complete source code is on GitHub: arangodb-dotnet-graph-api
In future articles, we’ll explore ArangoSearch for full-text search, graph analytics patterns, and visualizing graph data with React Flow.
