Graph Analytics and Pre-Defined Functions
Many real-world knowledge management tasks (supply-chain optimisation, fraud detection, recommendation, etc.) are both graph-shaped and rule-driven. Vadalog lets you run industrial-strength graph algorithms and logical reasoning in the same declarative program. Execution is automatically parallel and distributed.Using Graph Functions
A graph algorithm appears as a function literal that starts with# and lives in a rule body:
Built-in Graph Function Catalogue
| Function | Problem | Input (arity) | Output variables | Notes |
|---|---|---|---|---|
#TC(P) | Transitive Closure | P/2 edge(U,V) | (X,Y) | Directed. Includes self-loops from cycles. |
#PATHS(P[,options]) | All Paths | P/2 + optional string | (X,Y,Visited) or (X,Y) | Options: visited, self_loops, all_paths, max_depth, source, target |
#ASP(P) | All-Shortest Paths (weighted) | P/3 edge(U,V,W) | (X,Y,Z) | Parallel multi-source Dijkstra |
#SSSP(P[,options]) | Single-Source Shortest Path | P/3 + optional string | (Y,Dist) | Required: source=N |
#BFS(P) | Breadth-First Levels | P/2 | (X,Level) | Unweighted tiers |
#CC(P[,options]) | Connected Components | P/2 + optional string | (X,Comp) or (X,ID,Comp) | For undirected graphs. Options: sort_component, component_id |
#WCC(P) | Weakly Connected Components | P/2 | (X,Comp) | Directed graphs — ignores edge direction |
#TRI(P) | Triangle Enumeration | P/2 | (X,Y,Z) | Unordered triangles |
#DC(P[,options]) | Degree Centrality | P/2 | (X,Score) | Normalized by (N-1). Options: type=in/out/total |
#BC(P[,options]) | Betweenness Centrality | P/2 | (X,Score) | Normalized by (N-1)(N-2). Options: sample=K |
#PR(P[,options]) | PageRank | P/2 | (X,Score) | Options: damping, tolerance. Scores sum to 1.0 |
Examples
Transitive Closure
PATHS with Options
All-Shortest Paths
Single-Source Shortest Path
Connected Components
CC vs WCC
#CC: Expects edges to already be symmetric (undirected). You must explicitly createedge(X,Y)andedge(Y,X).#WCC: Designed for directed graphs. Automatically treats directed edges as undirected.

