Skip to content

Appendix D: Algorithm Reference

This appendix provides a comprehensive reference for all graph algorithms available through the Graph OLAP SDK. Algorithms are organized by category and include both native (Ryugraph and FalkorDB) and NetworkX implementations.

Note: Algorithm Availability by Backend

  • Native Algorithms: Available on both Ryugraph (conn.algo.*) and FalkorDB (CALL algo.*()) with different syntax
  • NetworkX Algorithms: Ryugraph ONLY - 100+ algorithms via conn.networkx.*

The SDK provides algorithm interfaces that vary by backend:

  • Ryugraph Native Algorithms (conn.algo): High-performance algorithms running directly in the Ryugraph database engine
  • FalkorDB Native Algorithms (CALL algo.*()): Native Cypher procedures for graph analytics
  • NetworkX Algorithms (conn.networkx): Access to 500+ NetworkX algorithms via a bridge interface (Ryugraph only)

Both interfaces support:

  • Dynamic algorithm discovery via .algorithms() and .algorithm_info()
  • Automatic result writeback to node properties
  • Execution status tracking and timeout handling
CategoryDescriptionExamples
centralityNode importance measuresPageRank, Betweenness, Closeness
communityCluster/group detectionLouvain, WCC, SCC, Label Propagation
pathfindingPath analysisShortest Path
clusteringStructural analysisK-Core, Triangle Count
similarityNode similarity measuresJaccard, Cosine
traversalGraph traversalBFS, DFS
link_predictionPredict new edgesCommon Neighbors, Adamic-Adar

Native algorithms run directly in the Ryugraph database engine for optimal performance.

Category: Centrality

Description: Computes PageRank centrality scores measuring node importance based on incoming links.

ParameterTypeRequiredDefaultDescription
node_labelstringYes-Target node label
property_namestringYes-Property to store results
edge_typestringYes-Relationship type to traverse
dampingfloatNo0.85Damping factor (0 to 1)
max_iterationsintNo100Maximum iterations
tolerancefloatNo1e-6Convergence tolerance
timeoutintNo300Timeout in seconds

Result Property: Float between 0 and 1

Example:

# Using convenience method
result = conn.algo.pagerank(
node_label="Customer",
property_name="pr_score",
edge_type="KNOWS",
damping=0.85,
max_iterations=100
)
# Using generic method
result = conn.algo.run(
"pagerank",
node_label="Customer",
property_name="pr_score",
edge_type="KNOWS",
params={
"damping_factor": 0.85,
"max_iterations": 100,
"tolerance": 1e-6
}
)
print(f"Nodes updated: {result.nodes_updated}")
print(f"Duration: {result.duration_ms}ms")
# Query results
top_nodes = conn.query("""
MATCH (c:Customer)
WHERE c.pr_score IS NOT NULL
RETURN c.name, c.pr_score
ORDER BY c.pr_score DESC
LIMIT 10
""")

Category: Community

Description: Finds connected components treating all edges as undirected. Each node is assigned a component ID.

ParameterTypeRequiredDefaultDescription
node_labelstringYes-Target node label
property_namestringYes-Property to store component ID
edge_typestringYes-Relationship type to traverse
timeoutintNo300Timeout in seconds

Result Property: Integer (component ID)

Example:

result = conn.algo.connected_components(
node_label="Customer",
property_name="component_id",
edge_type="KNOWS"
)
print(f"Found {result.extra.get('components', 'N/A')} components")
# Find largest components
components = conn.query("""
MATCH (c:Customer)
WHERE c.component_id IS NOT NULL
RETURN c.component_id, count(*) as size
ORDER BY size DESC
LIMIT 10
""")

Category: Community

Description: Finds strongly connected components where every pair of vertices is mutually reachable (respecting edge direction).

ParameterTypeRequiredDefaultDescription
node_labelstringYes-Target node label
property_namestringYes-Property to store component ID
edge_typestringYes-Relationship type to traverse
max_iterationsintNo100Maximum iterations
timeoutintNo300Timeout in seconds

Result Property: Integer (component ID)

Example:

result = conn.algo.scc(
node_label="Customer",
property_name="scc_id",
edge_type="REFERRED"
)
print(f"Found {result.extra.get('components', 'N/A')} strongly connected components")

Category: Community

Description: Finds strongly connected components using Kosaraju’s DFS-based algorithm. Recommended for very sparse graphs or graphs with high diameter.

ParameterTypeRequiredDefaultDescription
node_labelstringYes-Target node label
property_namestringYes-Property to store component ID
edge_typestringYes-Relationship type to traverse
timeoutintNo300Timeout in seconds

Result Property: Integer (component ID)

Example:

result = conn.algo.scc_kosaraju(
node_label="Customer",
property_name="scc_ko_id",
edge_type="REFERRED"
)

Category: Community

Description: Detects communities by maximizing modularity score using hierarchical clustering. Treats edges as undirected.

ParameterTypeRequiredDefaultDescription
node_labelstringYes-Target node label
property_namestringYes-Property to store community ID
edge_typestringYes-Relationship type to traverse
resolutionfloatNo1.0Resolution parameter (higher = more communities)
timeoutintNo300Timeout in seconds

Result Property: Integer (community ID)

Example:

result = conn.algo.louvain(
node_label="Customer",
property_name="community",
edge_type="KNOWS",
resolution=1.0
)
print(f"Found {result.extra.get('communities', 'N/A')} communities")
# Analyze community distribution
communities = conn.query("""
MATCH (c:Customer)
WHERE c.community IS NOT NULL
RETURN c.community, count(*) as size
ORDER BY size DESC
""")

Category: Clustering

Description: Computes the k-core number for each node - the largest value k such that the node belongs to a k-core subgraph (where every node has degree at least k).

ParameterTypeRequiredDefaultDescription
node_labelstringYes-Target node label
property_namestringYes-Property to store k-core degree
edge_typestringYes-Relationship type to traverse
timeoutintNo300Timeout in seconds

Result Property: Integer (k-core degree)

Example:

result = conn.algo.kcore(
node_label="Customer",
property_name="kcore_degree",
edge_type="KNOWS"
)
print(f"Max k-core: {result.extra.get('max_k', 'N/A')}")
# Find highly connected core
core_nodes = conn.query("""
MATCH (c:Customer)
WHERE c.kcore_degree >= 5
RETURN c.name, c.kcore_degree
ORDER BY c.kcore_degree DESC
""")

Category: Community

Description: Detects communities by iteratively propagating labels from neighbors. Each node adopts the most common label among its neighbors.

ParameterTypeRequiredDefaultDescription
node_labelstringYes-Target node label
property_namestringYes-Property to store community label
edge_typestringYes-Relationship type to traverse
max_iterationsintNo100Maximum iterations
timeoutintNo300Timeout in seconds

Result Property: Integer (community label)

Example:

result = conn.algo.label_propagation(
node_label="Customer",
property_name="lp_community",
edge_type="KNOWS",
max_iterations=100
)

Category: Clustering

Description: Counts the number of triangles each node participates in. A triangle is a set of three mutually connected nodes.

ParameterTypeRequiredDefaultDescription
node_labelstringYes-Target node label
property_namestringYes-Property to store triangle count
edge_typestringYes-Relationship type to traverse
timeoutintNo300Timeout in seconds

Result Property: Integer (triangle count)

Example:

result = conn.algo.triangle_count(
node_label="Customer",
property_name="triangles",
edge_type="KNOWS"
)
# Find nodes in tightly connected neighborhoods
clustered = conn.query("""
MATCH (c:Customer)
WHERE c.triangles > 10
RETURN c.name, c.triangles
ORDER BY c.triangles DESC
""")

Category: Pathfinding

Description: Finds the shortest path between two specific nodes.

ParameterTypeRequiredDefaultDescription
source_idanyYes-Source node ID
target_idanyYes-Target node ID
relationship_typeslistNoNoneFilter by relationship types
max_depthintNoNoneMaximum path length
timeoutintNo60Timeout in seconds

Result: Path information in execution result

Example:

result = conn.algo.shortest_path(
source_id="node_123",
target_id="node_456",
relationship_types=["KNOWS", "WORKS_WITH"],
max_depth=6
)
if result.result:
path = result.result.get("path", [])
print(f"Path length: {len(path)}")
print(f"Path: {' -> '.join(str(n) for n in path)}")

NetworkX algorithms are available through the conn.networkx interface. The SDK provides convenience methods for common algorithms and a generic run() method for any of 500+ NetworkX algorithms.

Category: Centrality

Description: Measures node importance by counting connections (normalized by maximum possible degree).

ParameterTypeRequiredDefaultDescription
node_labelstringYes-Target node label
property_namestringYes-Property to store result
timeoutintNo300Timeout in seconds

Result Property: Float between 0 and 1

Example:

result = conn.networkx.degree_centrality(
node_label="Customer",
property_name="degree_cent"
)

Category: Centrality

Description: Measures how often a node lies on shortest paths between other nodes. High betweenness nodes are important bridges.

ParameterTypeRequiredDefaultDescription
node_labelstringYes-Target node label
property_namestringYes-Property to store result
kintNoNoneNumber of sample nodes for approximation
timeoutintNo300Timeout in seconds

Result Property: Float (normalized betweenness)

Example:

# Exact computation
result = conn.networkx.betweenness_centrality(
node_label="Customer",
property_name="betweenness"
)
# Approximate (faster for large graphs)
result = conn.networkx.betweenness_centrality(
node_label="Customer",
property_name="betweenness_approx",
k=100 # Sample 100 nodes
)

Category: Centrality

Description: Measures how close a node is to all other nodes (inverse of average shortest path length).

ParameterTypeRequiredDefaultDescription
node_labelstringYes-Target node label
property_namestringYes-Property to store result
timeoutintNo300Timeout in seconds

Result Property: Float between 0 and 1

Example:

result = conn.networkx.closeness_centrality(
node_label="Customer",
property_name="closeness"
)

Category: Centrality

Description: Measures node influence based on the influence of neighbors. High scores indicate connections to other influential nodes.

ParameterTypeRequiredDefaultDescription
node_labelstringYes-Target node label
property_namestringYes-Property to store result
max_iterintNo100Maximum iterations
timeoutintNo300Timeout in seconds

Result Property: Float (eigenvector centrality score)

Example:

result = conn.networkx.eigenvector_centrality(
node_label="Customer",
property_name="eigenvector",
max_iter=200
)

Category: Clustering

Description: Measures the degree to which nodes cluster together (ratio of actual triangles to possible triangles).

ParameterTypeRequiredDefaultDescription
node_labelstringYes-Target node label
property_namestringYes-Property to store result
timeoutintNo300Timeout in seconds

Result Property: Float between 0 and 1

Example:

result = conn.networkx.clustering_coefficient(
node_label="Customer",
property_name="clustering"
)

Use the run() method to execute any NetworkX algorithm:

# List available algorithms
algos = conn.networkx.algorithms(category="centrality")
for algo in algos:
print(f"{algo['name']}: {algo['description']}")
# Get algorithm info
info = conn.networkx.algorithm_info("katz_centrality")
print(f"Parameters: {info['parameters']}")
# Run algorithm
result = conn.networkx.run(
"katz_centrality",
node_label="Customer",
property_name="katz",
params={"alpha": 0.1, "beta": 1.0}
)
# List all native algorithms
native_algos = conn.algo.algorithms()
print(f"Available native algorithms: {len(native_algos)}")
for algo in native_algos:
print(f" {algo['name']}: {algo['description']}")
# List by category
centrality_algos = conn.algo.algorithms(category="centrality")
community_algos = conn.algo.algorithms(category="community")
# List NetworkX algorithms
nx_algos = conn.networkx.algorithms()
print(f"Available NetworkX algorithms: {len(nx_algos)}")
# Filter NetworkX by category
nx_centrality = conn.networkx.algorithms(category="centrality")
# Native algorithm info
info = conn.algo.algorithm_info("pagerank")
print(f"Name: {info['name']}")
print(f"Category: {info['category']}")
print(f"Description: {info['description']}")
print("Parameters:")
for param in info['parameters']:
print(f" {param['name']}: {param['type']} (default: {param.get('default')})")
# NetworkX algorithm info
nx_info = conn.networkx.algorithm_info("betweenness_centrality")
# Run algorithm and wait for completion
result = conn.algo.pagerank("Customer", "pr_score", edge_type="KNOWS")
# Check execution status
print(f"Status: {result.status}")
print(f"Nodes updated: {result.nodes_updated}")
print(f"Duration: {result.duration_ms}ms")
# Start algorithm without waiting
result = conn.algo.pagerank(
"Customer",
"pr_score",
edge_type="KNOWS",
wait=False
)
print(f"Started execution: {result.execution_id}")
# Check status manually later
# (implementation depends on wrapper API)
from graph_olap.exceptions import (
AlgorithmNotFoundError,
AlgorithmFailedError,
AlgorithmTimeoutError,
ResourceLockedError
)
try:
result = conn.algo.pagerank(
"Customer",
"pr_score",
edge_type="KNOWS",
timeout=300
)
except AlgorithmNotFoundError:
print("Algorithm not available in this wrapper")
except AlgorithmTimeoutError:
print("Algorithm timed out - try smaller dataset or longer timeout")
except ResourceLockedError as e:
print(f"Instance locked by: {e.holder_name} running {e.algorithm}")
except AlgorithmFailedError as e:
print(f"Algorithm failed: {e}")
AspectRyugraph NativeFalkorDB NativeNetworkX
AvailabilityRyugraph onlyFalkorDB onlyRyugraph only
Invocationconn.algo.*CALL algo.*()conn.networkx.*
Algorithms84100+
PerformanceFast (in-database)Fast (in-database)Slower (graph extraction)
MemoryEfficientEfficientHigher (graph copy)
Large graphsPreferredPreferredMay timeout
Use CaseRecommended Algorithm
Node importancePageRank (native)
Influence measurementBetweenness Centrality (NetworkX)
Find clustersLouvain (native)
Find connected groupsWCC (native)
Directed component analysisSCC (native)
Dense core detectionK-Core (native)
Path analysisShortest Path (native)
Local connectivityClustering Coefficient (NetworkX)
AlgorithmNameCategoryParametersResult Type
PageRankpagerankcentralitydamping_factor, max_iterations, toleranceFloat (0-1)
WCCwcccommunitymax_iterationsInteger (component ID)
SCCscccommunitymax_iterationsInteger (component ID)
SCC Kosarajuscc_kosarajucommunity(none)Integer (component ID)
Louvainlouvaincommunitymax_phases, max_iterationsInteger (community ID)
K-Corekcoreclustering(none)Integer (k-degree)
Label Propagationlabel_propagationcommunitymax_iterationsInteger (label)
Triangle Counttriangle_countclustering(none)Integer (count)
Shortest Pathshortest_pathpathfindingsource_id, target_id, relationship_types, max_depthPath data

FalkorDB provides 4 native graph algorithms accessible via Cypher procedures. These algorithms write results directly to node properties.

Category: Centrality

Description: Computes PageRank centrality scores measuring node importance based on incoming links.

ParameterTypeRequiredDefaultDescription
damping_factorfloatNo0.85Damping factor (probability of following a link)
max_iterationsintNo20Maximum iterations before stopping
tolerancefloatNo0.0001Convergence tolerance threshold

Writes to: Node property pagerank

Example:

// Run PageRank with default parameters
CALL algo.pagerank()
// Run PageRank with custom parameters
CALL algo.pagerank(0.85, 100, 0.00001)
// Query results
MATCH (n)
WHERE n.pagerank IS NOT NULL
RETURN n.name, n.pagerank
ORDER BY n.pagerank DESC
LIMIT 10

Category: Centrality

Description: Measures how often a node lies on shortest paths between other nodes. High betweenness nodes are important bridges in the network.

ParameterTypeRequiredDefaultDescription
sample_sizeintNoNoneNumber of sample nodes for approximation (omit for exact)

Writes to: Node property betweenness

Example:

// Exact betweenness computation
CALL algo.betweenness()
// Approximate betweenness (faster for large graphs)
CALL algo.betweenness(100)
// Query results
MATCH (n)
WHERE n.betweenness IS NOT NULL
RETURN n.name, n.betweenness
ORDER BY n.betweenness DESC
LIMIT 10

Category: Community

Description: Finds connected components treating all edges as undirected. Each node is assigned a component ID identifying which connected subgraph it belongs to.

ParameterTypeRequiredDefaultDescription
(none)---No parameters required

Writes to: Node property component_id

Example:

// Run WCC
CALL algo.wcc()
// Find component sizes
MATCH (n)
WHERE n.component_id IS NOT NULL
RETURN n.component_id, count(*) as size
ORDER BY size DESC
LIMIT 10
// Find isolated components (size = 1)
MATCH (n)
WHERE n.component_id IS NOT NULL
WITH n.component_id as comp, count(*) as size
WHERE size = 1
RETURN comp, size

Community Detection via Label Propagation (FalkorDB)

Section titled “Community Detection via Label Propagation (FalkorDB)”

Category: Community

Description: Detects communities by iteratively propagating labels. Each node adopts the most common label among its neighbors until convergence.

ParameterTypeRequiredDefaultDescription
max_iterationsintNo10Maximum iterations before stopping

Writes to: Node property community

Example:

// Run CDLP with default iterations
CALL algo.cdlp()
// Run with more iterations for better convergence
CALL algo.cdlp(50)
// Analyze community distribution
MATCH (n)
WHERE n.community IS NOT NULL
RETURN n.community, count(*) as size
ORDER BY size DESC
// Find nodes in the same community
MATCH (n)
WHERE n.community = 42
RETURN n.name, n.community

AlgorithmProcedureCategoryParametersResult Property
PageRankalgo.pagerank()centralitydamping_factor, max_iterations, tolerancepagerank
Betweennessalgo.betweenness()centralitysample_size (optional)betweenness
WCCalgo.wcc()community(none)component_id
CDLPalgo.cdlp()communitymax_iterationscommunity