UltipaDocs
Try Playground
  • Overview
  • Centrality Algorithms
  • Community Detection
  • Path Finding
  • Similarity Algorithms
  1. Docs
  2. /
  3. Graph Algorithms
  4. /
  5. Overview

Graph Algorithms

Overview

GQLDB provides built-in graph algorithms for analyzing graph structure and discovering patterns. These algorithms are called using the CALL algo.* syntax and can be combined with GQL queries.

Algorithm Categories:

CategoryPurposeExamples
CentralityFind important nodesPageRank, Betweenness, Closeness, Degree
Community DetectionDiscover clustersLouvain, Label Propagation, Connected Components
Path FindingFind routesDijkstra, BFS, DFS, A*
SimilarityFind similar nodesNode Similarity, Jaccard, Cosine

Basic Usage

Algorithms are called using the CALL statement with YIELD to capture results:

GQL
CALL algo.pageRank('Person', 'FOLLOWS')
YIELD nodeId, score
MATCH (p:Person) WHERE id(p) = nodeId
RETURN p.name, score
ORDER BY score DESC
LIMIT 10

Common Parameters

Most algorithms accept these parameters:

ParameterDescription
nodeLabelLabel of nodes to include
edgeTypeType of edges to traverse
directionEdge direction: 'OUTGOING', 'INCOMING', or 'BOTH'
writePropertyProperty name to store results on nodes

Persisting Results

Many algorithms can write results back to nodes:

GQL
// Compute and store PageRank scores
CALL algo.pageRank('Person', 'FOLLOWS', {writeProperty: 'pageRankScore'})
YIELD nodesProcessed

// Later query by stored score
MATCH (p:Person)
WHERE p.pageRankScore > 0.5
RETURN p.name, p.pageRankScore
ORDER BY p.pageRankScore DESC

Streaming vs Batch

Algorithms ending in .stream return results row by row without persisting:

GQL
// Stream results
CALL algo.pageRank.stream('Person', 'FOLLOWS')
YIELD nodeId, score
RETURN nodeId, score

See the following pages for detailed information:

  • Centrality Algorithms
  • Community Detection
  • Path Finding
  • Similarity Algorithms