-
Notifications
You must be signed in to change notification settings - Fork 5
Update Docs towards New Version Deploy #155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
9c6e0bb
1dcdd22
2a65ded
3d6de6c
1ab1ca9
08dca15
c2f7a07
ce0ab50
49b6044
b6d0b05
f02471d
9f68b8b
ae7003e
fce15bd
388795e
e3752a8
8a6b005
dea9e92
c846eed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
--- | ||
title: "BFS" | ||
description: "BFS" | ||
--- | ||
|
||
# BFS | ||
|
||
## Overview | ||
|
||
The Breadth-First Search (BFS) procedure allows you to perform a breadth-first traversal of a graph starting from a specific node. | ||
BFS explores all the nodes at the present depth before moving on to nodes at the next depth level. | ||
This is particularly useful for finding the shortest path between two nodes or exploring a graph layer by layer. | ||
|
||
## Syntax | ||
|
||
``` | ||
CALL algo.bfs(start_node, max_depth, relationship) | ||
YIELD nodes, edges | ||
``` | ||
|
||
## Arguments | ||
|
||
| Name | Type | Description | Default | | ||
|--------------|----------------|-----------------------------------------------------------------------------|------------| | ||
| start_node | Node | Starting node for the BFS traversal | (Required) | | ||
| max_depth | Integer | Maximum depth to traverse | (Required) | | ||
| relationship | String or null | The relationship type to traverse. If null, all relationship types are used | null | | ||
|
||
## Returns | ||
|
||
| Name | Type | Description | | ||
|-------|------|----------------------------------------------| | ||
| nodes | List | List of visited nodes in breadth-first order | | ||
| edges | List | List of edges traversed during the BFS | | ||
|
||
## Examples | ||
|
||
### Basic BFS Traversal | ||
|
||
This example demonstrates a basic BFS traversal starting from a person node. | ||
|
||
|
||
### Social Network Friend Recommendations | ||
|
||
This example demonstrates how to use BFS to find potential friend recommendations in a social network. | ||
matanbroit marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#### Setup the Graph | ||
|
||
```cypher | ||
CREATE | ||
(alice:Person {name: 'Alice', age: 28, city: 'New York'}), | ||
(bob:Person {name: 'Bob', age: 32, city: 'Boston'}), | ||
(charlie:Person {name: 'Charlie', age: 35, city: 'Chicago'}), | ||
(david:Person {name: 'David', age: 29, city: 'Denver'}), | ||
(eve:Person {name: 'Eve', age: 31, city: 'San Francisco'}), | ||
(frank:Person {name: 'Frank', age: 27, city: 'Miami'}), | ||
|
||
(alice)-[:FRIEND]->(bob), | ||
(alice)-[:FRIEND]->(charlie), | ||
(bob)-[:FRIEND]->(david), | ||
(charlie)-[:FRIEND]->(eve), | ||
(david)-[:FRIEND]->(frank), | ||
(eve)-[:FRIEND]->(frank) | ||
``` | ||
|
||
 | ||
|
||
#### Find Friends of Friends (Potential Recommendations) | ||
|
||
``` | ||
// Find Alice's friends-of-friends (potential recommendations) | ||
MATCH (alice:Person {name: 'Alice'}) | ||
CALL algo.bfs(alice, 2, 'FRIEND') | ||
YIELD nodes | ||
|
||
// Process results to get only depth 2 connections (friends of friends) | ||
WHERE size(nodes) >= 3 | ||
WITH alice, nodes[2] AS potential_friend | ||
WHERE NOT (alice)-[:FRIEND]->(potential_friend) | ||
RETURN potential_friend | ||
``` | ||
|
||
In this social network example, the BFS algorithm helps find potential friend recommendations by identifying people who are connected to Alice's existing friends but not directly connected to Alice yet. | ||
|
||
|
||
## Performance Considerations | ||
|
||
- **Indexing:** Ensure properties used for finding your starting node are indexed for optimal performance | ||
- **Maximum Depth:** Choose an appropriate max_depth value based on your graph's connectivity; large depths in highly connected graphs can result in exponential growth of traversed nodes | ||
- **Relationship Filtering:** When applicable, specify the relationship type to limit the traversal scope | ||
- **Memory Management:** Be aware that the procedure stores visited nodes in memory to avoid cycles, which may require significant resources in large, densely connected graphs | ||
|
||
## Error Handling | ||
|
||
Common errors that may occur: | ||
|
||
- **Null Starting Node:** If the start_node parameter is null, the procedure will raise an error; ensure your MATCH clause successfully finds the starting node | ||
- **Invalid Relationship Type:** If you specify a relationship type that doesn't exist in your graph, the traversal will only include the starting node | ||
- **Memory Limitations:** For large graphs with high connectivity, an out-of-memory error may occur if too many nodes are visited | ||
- **Result Size:** If the BFS traversal returns too many nodes, query execution may be slow or time out; in such cases, try reducing the max_depth or filtering by relationship types |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,37 @@ | ||||||||||||||||||||||
# FalkorDB Algorithms Overview | ||||||||||||||||||||||
|
||||||||||||||||||||||
FalkorDB offers a suite of graph algorithms optimized for high-performance graph analytics. | ||||||||||||||||||||||
These algorithms are accessible via the `CALL algo.<name>()` interface and are built for speed and scalability using matrix-based computation. | ||||||||||||||||||||||
|
||||||||||||||||||||||
This overview summarizes the available algorithms and links to their individual documentation. | ||||||||||||||||||||||
|
||||||||||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||
## Table of Contents | ||||||||||||||||||||||
|
||||||||||||||||||||||
- [Pathfinding Algorithms](#pathfinding-algorithms) | ||||||||||||||||||||||
- [Centrality Measures](#centrality-measures) | ||||||||||||||||||||||
- [Community Detection](#community-detection) | ||||||||||||||||||||||
|
||||||||||||||||||||||
--- | ||||||||||||||||||||||
|
||||||||||||||||||||||
## Pathfinding Algorithms | ||||||||||||||||||||||
|
||||||||||||||||||||||
- **[BFS](./bfs.md)** | ||||||||||||||||||||||
Performs a breadth-first search starting from a source node and optionally stopping at target nodes or maximum depth. | ||||||||||||||||||||||
|
||||||||||||||||||||||
- **[SPpath](./sppath.md)** | ||||||||||||||||||||||
Computes the shortest paths between a source and one or more destination nodes. | ||||||||||||||||||||||
|
||||||||||||||||||||||
- **[SSpath](./sspath.md)** | ||||||||||||||||||||||
Enumerates all paths from a single source node to other nodes, based on constraints like edge filters and depth. | ||||||||||||||||||||||
|
||||||||||||||||||||||
Comment on lines
+28
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Align algorithm link text with procedure names - - **[SPpath](./sppath.md)**
+ - **[SPpaths](./sppath.md)**
- - **[SSpath](./sspath.md)**
+ - **[SSpaths](./sspath.md)** 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||
For path expressions like `shortestPath()` used directly in Cypher queries, refer to the [Cypher Path Functions section](../cypher/functions.md#path-functions). | ||||||||||||||||||||||
## Centrality Measures | ||||||||||||||||||||||
|
||||||||||||||||||||||
- **[PageRank](./pagerank.md)** | ||||||||||||||||||||||
Computes the PageRank score of each node in the graph, representing its influence based on the structure of incoming links. | ||||||||||||||||||||||
|
||||||||||||||||||||||
## Community Detection | ||||||||||||||||||||||
|
||||||||||||||||||||||
- **[WCC (Weakly Connected Components)](./wcc.md)** | ||||||||||||||||||||||
Finds weakly connected components in a graph, where each node is reachable from others ignoring edge directions. | ||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
--- | ||
title: "PageRank" | ||
description: "PageRank" | ||
--- | ||
|
||
# PageRank | ||
|
||
## Introduction | ||
|
||
PageRank is an algorithm that measures the importance of each node within the graph based on the number of incoming relationships and the importance of the corresponding source nodes. | ||
The algorithm was originally developed by Google's founders Larry Page and Sergey Brin during their time at Stanford University. | ||
|
||
## Algorithm Overview | ||
|
||
PageRank works by counting the number and quality of relationships to a node to determine a rough estimate of how important that node is. | ||
The underlying assumption is that more important nodes are likely to receive more connections from other nodes. | ||
|
||
The algorithm assigns each node a score, where higher scores indicate greater importance. | ||
The score for a node is derived recursively from the scores of the nodes that link to it, with a damping factor typically applied to prevent rank sinks. | ||
|
||
matanbroit marked this conversation as resolved.
Show resolved
Hide resolved
|
||
## Syntax | ||
|
||
The PageRank procedure has the following call signature: | ||
|
||
```cypher | ||
CALL pagerank.stream( | ||
[label], | ||
[relationship] | ||
) | ||
YIELD node, score | ||
``` | ||
|
||
### Parameters | ||
|
||
| Name | Type | Default | Description | | ||
|----------------|--------|---------|------------------------------------------------------------------------------| | ||
| `label` | String | null | The label of nodes to run the algorithm on. If null, all nodes are used. | | ||
| `relationship` | String | null | The relationship type to traverse. If null, all relationship types are used. | | ||
|
||
### Yield | ||
|
||
| Name | Type | Description | | ||
|---------|-------|--------------------------------------| | ||
| `node` | Node | The node processed by the algorithm. | | ||
| `score` | Float | The PageRank score for the node. | | ||
|
||
## Examples | ||
|
||
### Unweighted PageRank | ||
|
||
First, let's create a sample graph representing a citation network between scientific papers: | ||
|
||
```cypher | ||
CREATE | ||
(paper1:Paper {title: 'Graph Algorithms in Database Systems'}), | ||
(paper2:Paper {title: 'PageRank Applications'}), | ||
(paper3:Paper {title: 'Data Mining Techniques'}), | ||
(paper4:Paper {title: 'Network Analysis Methods'}), | ||
(paper5:Paper {title: 'Social Network Graph Theory'}), | ||
|
||
(paper2)-[:CITES]->(paper1), | ||
(paper3)-[:CITES]->(paper1), | ||
(paper3)-[:CITES]->(paper2), | ||
(paper4)-[:CITES]->(paper1), | ||
(paper4)-[:CITES]->(paper3), | ||
(paper5)-[:CITES]->(paper2), | ||
(paper5)-[:CITES]->(paper4) | ||
``` | ||
|
||
 | ||
|
||
Now we can run the PageRank algorithm on this citation network: | ||
|
||
```cypher | ||
CALL pagerank.stream('Paper', 'CITES') | ||
YIELD node, score | ||
RETURN node.title AS paper, score | ||
ORDER BY score DESC | ||
``` | ||
|
||
Expected results: | ||
|
||
| paper | score | | ||
|--------------------------------------|-------| | ||
| Graph Algorithms in Database Systems | 0.43 | | ||
| Data Mining Techniques | 0.21 | | ||
| PageRank Applications | 0.19 | | ||
| Network Analysis Methods | 0.14 | | ||
| Social Network Graph Theory | 0.03 | | ||
|
||
|
||
## Usage Notes | ||
|
||
**Interpreting scores**: | ||
- PageRank scores are relative, not absolute measures | ||
- The sum of all scores in a graph equals 1.0 | ||
- Scores typically follow a power-law distribution |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
--- | ||
title: "algo.SPpaths" | ||
description: "Find shortest paths between two nodes with advanced cost and length constraints." | ||
--- | ||
|
||
# `algo.SPpaths` - Shortest Path (Single Pair) | ||
|
||
The `algo.SPpaths` procedure finds the shortest paths between a **source** and a **target** node, optionally constrained by cost, path length, and the number of paths to return. | ||
|
||
It is designed for efficient and scalable computation of paths in large graphs, using properties like distance, time, or price as weights. | ||
matanbroit marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Syntax | ||
|
||
```cypher | ||
CALL algo.SPpaths({ | ||
sourceNode: <node>, | ||
targetNode: <node>, | ||
relTypes: [<relationship_type>], | ||
weightProp: <property>, | ||
costProp: <property>, // optional | ||
maxCost: <int>, // optional | ||
maxLen: <int>, // optional | ||
relDirection: "outgoing", // or "incoming", "both" | ||
pathCount: <int> // 0 = all, 1 = single (default), n > 1 = up to n | ||
}) | ||
YIELD path, pathWeight, pathCost | ||
``` | ||
|
||
## Parameters | ||
|
||
| Name | Type | Description | | ||
|-----------------|----------|-------------| | ||
| `sourceNode` | Node | Starting node | | ||
| `targetNode` | Node | Destination node | | ||
| `relTypes` | Array | List of relationship types to follow | | ||
| `weightProp` | String | Property to minimize along the path (e.g., `dist`, `time`) | | ||
| `costProp` | String | Property to constrain the total value (optional) | | ||
| `maxCost` | Integer | Upper bound on total cost (optional) | | ||
| `maxLen` | Integer | Max number of relationships in the path (optional) | | ||
| `relDirection` | String | Traversal direction (`outgoing`, `incoming`, `both`) | | ||
| `pathCount` | Integer | Number of paths to return (0 = all shortest, 1 = default, n = max number of results) | | ||
|
||
## Returns | ||
|
||
| Name | Type | Description | | ||
|--------------|---------|-------------| | ||
| `path` | Path | Discovered path from source to target | | ||
| `pathWeight` | Integer | Sum of the weightProp across the path | | ||
| `pathCost` | Integer | Sum of the costProp across the path (if used) | | ||
|
||
|
||
## Examples: | ||
Lets take this Road Network Graph as an example: | ||
|
||
 | ||
|
||
### Example: Shortest Path by Distance from City A to City G: | ||
|
||
```cypher | ||
MATCH (a:City{name:'A'}), (g:City{name:'G'}) | ||
CALL algo.SPpaths({ | ||
sourceNode: a, | ||
targetNode: g, | ||
relTypes: ['Road'], | ||
weightProp: 'dist' | ||
}) | ||
YIELD path, pathWeight | ||
RETURN pathWeight, [n in nodes(path) | n.name] AS pathNodes | ||
``` | ||
|
||
#### Expected Result: | ||
| pathWeight | pathNodes | | ||
|------------|---------------| | ||
| `12` | [A, D, E G] | | ||
|
||
|
||
### Example: Bounded Cost Path from City A to City G: | ||
|
||
```cypher | ||
MATCH (a:City{name:'A'}), (g:City{name:'G'}) | ||
CALL algo.SPpaths({ | ||
sourceNode: a, | ||
targetNode: g, | ||
relTypes: ['Road'], | ||
weightProp: 'dist', | ||
costProp: 'time', | ||
maxCost: 12, | ||
pathCount: 2 | ||
}) | ||
YIELD path, pathWeight, pathCost | ||
RETURN pathWeight, pathCost, [n in nodes(path) | n.name] AS pathNodes | ||
``` | ||
|
||
#### Expected Result: | ||
| pathWeight | pathCost | pathNodes | | ||
|------------|----------| --------------- | | ||
| `16` | `10` | [A, D, F G] | | ||
| `14` | `12` | [A, D, C F, G] | | ||
|
||
--- |
Uh oh!
There was an error while loading. Please reload this page.