Tutorial: Graph Algorithms
Graph algorithms reveal structure the world model already contains — influence, communities, bottlenecks. In ArcFlow, they run directly against the live graph: no projection lifecycle, no separate catalog, no setup.
No projection lifecycle#
Traditional graph algorithm systems require: create catalog → project graph → run algorithm → drop projection.
In ArcFlow: just run it.
// That's it. No projection. No catalog.
const pr = db.query("CALL algo.pageRank()")PageRank#
Find the most important nodes in your graph:
import { openInMemory } from 'arcflow'
const db = openInMemory()
// Build a small web graph
db.batchMutate([
"CREATE (a:Page {name: 'Home'})",
"CREATE (b:Page {name: 'About'})",
"CREATE (c:Page {name: 'Blog'})",
"CREATE (d:Page {name: 'Contact'})",
"CREATE (a:Page {name: 'Home'})-[:LINKS]->(b:Page {name: 'About'})",
"CREATE (a:Page {name: 'Home'})-[:LINKS]->(c:Page {name: 'Blog'})",
"CREATE (b:Page {name: 'About'})-[:LINKS]->(a:Page {name: 'Home'})",
"CREATE (c:Page {name: 'Blog'})-[:LINKS]->(a:Page {name: 'Home'})",
"CREATE (c:Page {name: 'Blog'})-[:LINKS]->(d:Page {name: 'Contact'})",
])
const pr = db.query("CALL algo.pageRank()")
for (const row of pr.rows) {
console.log(`${row.get('name')}: ${row.get('rank')}`)
}
// Home has the highest rank (most incoming links)Community Detection#
Find clusters of densely connected nodes:
// Louvain — fast, hierarchical communities
const communities = db.query("CALL algo.louvain()")
for (const row of communities.rows) {
console.log(`${row.get('name')} → community ${row.get('community')}`)
}
// Leiden — more accurate for large graphs
const leiden = db.query("CALL algo.leiden()")Centrality Measures#
Betweenness centrality#
Which nodes are bridges between communities?
const betweenness = db.query("CALL algo.betweenness()")
for (const row of betweenness.rows) {
console.log(`${row.get('name')}: ${row.get('score')}`)
}Closeness centrality#
Which nodes can reach all others most quickly?
const closeness = db.query("CALL algo.closeness()")Degree centrality#
Which nodes have the most connections?
const degree = db.query("CALL algo.degreeCentrality()")Path Finding#
All-pairs shortest paths#
const paths = db.query("CALL algo.allPairsShortestPath()")Confidence-weighted paths#
Find the most reliable path (highest minimum confidence):
const path = db.query("CALL algo.confidencePath()")Graph Properties#
// How many triangles exist?
const tri = db.query("CALL algo.triangleCount()")
// Local clustering coefficient
const cc = db.query("CALL algo.clusteringCoefficient()")
// Graph density (0 to 1)
const density = db.query("CALL algo.density()")
// Graph diameter (longest shortest path)
const diameter = db.query("CALL algo.diameter()")Node Similarity#
Find nodes with similar connection patterns:
const similar = db.query("CALL algo.nodeSimilarity()")
for (const row of similar.rows) {
console.log(`${row.get('node1')} ↔ ${row.get('node2')}: ${row.get('score')}`)
}Available algorithms#
See the full list in the Compatibility Matrix.
See Also#
- Graph Algorithms — full procedure reference with signatures and output schemas
- Algorithms Reference — GQL syntax for all 27 procedures
- GPU Acceleration — ArcFlow Adaptive Dispatch: automatic hardware routing for large graphs
- Use Case: Knowledge Management — algorithms over a knowledge world model
Try it
Open ↗⌘↵ to run
Loading engine…