-
Notifications
You must be signed in to change notification settings - Fork 5
Algorithms section & degree docs #117
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
base: main
Are you sure you want to change the base?
Changes from all commits
4a4d583
f40742f
2399d35
e90a8c2
879bb5d
6c9615a
dfaf8c9
e7cfc43
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 |
---|---|---|
|
@@ -348,6 +348,9 @@ hostnames | |
bigmac | ||
calmcode | ||
io | ||
influencers | ||
analytics | ||
Pathfinding | ||
kafka | ||
readme | ||
github | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,170 @@ | ||||||||||||||||
--- | ||||||||||||||||
title: "Degree" | ||||||||||||||||
description: "Measures the number of incoming or outgoing conections for all nodes." | ||||||||||||||||
parent: "Algorithms" | ||||||||||||||||
--- | ||||||||||||||||
|
||||||||||||||||
# Degree Procedure Documentation | ||||||||||||||||
|
||||||||||||||||
## Introduction | ||||||||||||||||
|
||||||||||||||||
The **Degree Procedure** calculates the degree of nodes in a graph based on the specified parameters. | ||||||||||||||||
This allows users to analyze the connectivity of nodes in terms of incoming or outgoing edges, filtered by node labels and relationship types. | ||||||||||||||||
|
||||||||||||||||
--- | ||||||||||||||||
|
||||||||||||||||
## Use Cases | ||||||||||||||||
|
||||||||||||||||
Here are some practical scenarios where the **Degree Procedure** can be applied: | ||||||||||||||||
|
||||||||||||||||
1. **Social Network Analysis**: Identify influencers or highly connected individuals by calculating the degree of `Person` nodes in a social graph. | ||||||||||||||||
2. **Infrastructure Planning**: Determine bottlenecks in a transportation network by analyzing nodes with high incoming or outgoing connections. | ||||||||||||||||
3. **E-commerce Recommendations**: Identify popular products or categories by computing the degree of `Product` or `Category` nodes based on customer interactions. | ||||||||||||||||
4. **Fraud Detection**: Spot suspicious activities by analyzing nodes with unusually high degrees in financial transaction graphs. | ||||||||||||||||
|
||||||||||||||||
--- | ||||||||||||||||
|
||||||||||||||||
## Syntax | ||||||||||||||||
|
||||||||||||||||
The procedure has the following call signature: | ||||||||||||||||
```procedure input: | ||||||||||||||||
CALL algo.dgree({ | ||||||||||||||||
'srcLabels': [<label>, ...], | ||||||||||||||||
'dir': 'incoming' / 'outgoing' / 'both', | ||||||||||||||||
'relationshipTypes': [<type>, ...], | ||||||||||||||||
'destLabels': [<label>, ...], | ||||||||||||||||
}) | ||||||||||||||||
``` | ||||||||||||||||
Comment on lines
+30
to
+37
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. Correct the procedure name spelling. The call signature has - ```procedure input:
- CALL algo.dgree({
+ ```cypher
+ CALL algo.degree({ — also consider using a standard 🧰 Tools🪛 markdownlint-cli2 (0.17.2)32-32: Hard tabs (MD010, no-hard-tabs) 32-32: Hard tabs (MD010, no-hard-tabs) 33-33: Hard tabs (MD010, no-hard-tabs) 33-33: Hard tabs (MD010, no-hard-tabs) 33-33: Hard tabs (MD010, no-hard-tabs) 34-34: Hard tabs (MD010, no-hard-tabs) 35-35: Hard tabs (MD010, no-hard-tabs) 35-35: Hard tabs (MD010, no-hard-tabs) 🤖 Prompt for AI Agents
|
||||||||||||||||
|
||||||||||||||||
### Parameters | ||||||||||||||||
|
||||||||||||||||
| Name | Type | Description | Default | | ||||||||||||||||
|---------------------|-----------------------|--------------------------------------------|-----------| | ||||||||||||||||
| `srcLabels` | [optional] [string[]] | type of nodes for which degree is computed | All Nodes | | ||||||||||||||||
| `dir` | [optional] [string] | 'incoming', 'outgoing', or 'both' | outgoing | | ||||||||||||||||
| `relationshipTypes` | [optional] [string[]] | the type of edges to consider | All edges | | ||||||||||||||||
| `destLabels` | [optional] [string[]] | type of reachable nodes | All Nodes | | ||||||||||||||||
|
||||||||||||||||
--- | ||||||||||||||||
|
||||||||||||||||
## Output | ||||||||||||||||
|
||||||||||||||||
The procedure returns a result set where each row corresponds to a node and includes the following fields: | ||||||||||||||||
|
||||||||||||||||
| Field | Type | Description | | ||||||||||||||||
| -------- | ---- | -------------------------------- | | ||||||||||||||||
| `node` | Node | The Node object. | | ||||||||||||||||
| `degree` | Int | The computed degree of the node. | | ||||||||||||||||
|
||||||||||||||||
--- | ||||||||||||||||
|
||||||||||||||||
## Setting Up the Graph | ||||||||||||||||
|
||||||||||||||||
To run the examples below, create the following graph structure: | ||||||||||||||||
|
||||||||||||||||
### Nodes: | ||||||||||||||||
|
||||||||||||||||
| ID | Label | | ||||||||||||||||
| -- | ------ | | ||||||||||||||||
| 1 | Person | | ||||||||||||||||
| 2 | Person | | ||||||||||||||||
| 3 | City | | ||||||||||||||||
| 4 | City | | ||||||||||||||||
|
||||||||||||||||
### Relationships: | ||||||||||||||||
|
||||||||||||||||
| Source | Target | Type | | ||||||||||||||||
| ------ | ------ | ------- | | ||||||||||||||||
| 1 | 2 | FRIEND | | ||||||||||||||||
| 1 | 3 | VISITED | | ||||||||||||||||
| 2 | 3 | VISITED | | ||||||||||||||||
| 2 | 4 | VISITED | | ||||||||||||||||
|
||||||||||||||||
Create this graph using the following commands: | ||||||||||||||||
|
||||||||||||||||
```plaintext | ||||||||||||||||
CREATE (:Person {id: 1}) | ||||||||||||||||
CREATE (:Person {id: 2}) | ||||||||||||||||
CREATE (:City {id: 3}) | ||||||||||||||||
CREATE (:City {id: 4}) | ||||||||||||||||
CREATE (p1:Person {id: 1})-[:FRIEND]->(p2:Person {id: 2}) | ||||||||||||||||
CREATE (p1)-[:VISITED]->(c1:City {id: 3}) | ||||||||||||||||
CREATE (p2)-[:VISITED]->(c1) | ||||||||||||||||
CREATE (p2)-[:VISITED]->(c2:City {id: 4}) | ||||||||||||||||
``` | ||||||||||||||||
|
||||||||||||||||
 | ||||||||||||||||
--- | ||||||||||||||||
|
||||||||||||||||
## Examples and Results | ||||||||||||||||
|
||||||||||||||||
### Example 1: Compute the outgoing degree for all nodes | ||||||||||||||||
|
||||||||||||||||
```plaintext | ||||||||||||||||
CALL algo.degree() | ||||||||||||||||
``` | ||||||||||||||||
|
||||||||||||||||
#### Result: | ||||||||||||||||
|
||||||||||||||||
| Node | Degree | | ||||||||||||||||
| ---- | ------ | | ||||||||||||||||
| 1 | 2 | | ||||||||||||||||
| 2 | 3 | | ||||||||||||||||
| 3 | 0 | | ||||||||||||||||
| 4 | 0 | | ||||||||||||||||
|
||||||||||||||||
--- | ||||||||||||||||
|
||||||||||||||||
### Example 2: Compute the outgoing degree for specific node types | ||||||||||||||||
|
||||||||||||||||
```plaintext | ||||||||||||||||
CALL algo.degree({srcLabels: ['Person']}) | ||||||||||||||||
``` | ||||||||||||||||
|
||||||||||||||||
#### Result: | ||||||||||||||||
|
||||||||||||||||
| Node | Degree | | ||||||||||||||||
| ---- | ------ | | ||||||||||||||||
| 1 | 2 | | ||||||||||||||||
| 2 | 3 | | ||||||||||||||||
|
||||||||||||||||
--- | ||||||||||||||||
|
||||||||||||||||
### Example 3: Compute the total degree for a specific relationship type | ||||||||||||||||
|
||||||||||||||||
```plaintext | ||||||||||||||||
CALL algo.degree({srcLabels: ['Person'], relationshipTypes: ['FRIEND'], dir: 'total'}) | ||||||||||||||||
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.
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. what's the default if not specified ? is it 'outgoing' ? |
||||||||||||||||
``` | ||||||||||||||||
|
||||||||||||||||
#### Result: | ||||||||||||||||
Comment on lines
+134
to
+139
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. Inconsistent Syntax defines - CALL algo.degree({…, dir: 'total'})
+ CALL algo.degree({…, dir: 'both'}) 📝 Committable suggestion
Suggested change
🧰 Tools🪛 markdownlint-cli2 (0.17.2)138-138: Trailing punctuation in heading (MD026, no-trailing-punctuation) 🤖 Prompt for AI Agents
|
||||||||||||||||
|
||||||||||||||||
| Node | Degree | | ||||||||||||||||
| ---- | ------ | | ||||||||||||||||
| 1 | 1 | | ||||||||||||||||
| 2 | 1 | | ||||||||||||||||
|
||||||||||||||||
--- | ||||||||||||||||
|
||||||||||||||||
### Example 4: Compute the incoming degree for reachable nodes of a specific type | ||||||||||||||||
|
||||||||||||||||
```plaintext | ||||||||||||||||
CALL algo.degree({srcLabels: ['Person'], relationshipTypes: ['VISITED'], dir: 'incoming', destLabels: ['City']}) | ||||||||||||||||
``` | ||||||||||||||||
|
||||||||||||||||
#### Result: | ||||||||||||||||
|
||||||||||||||||
| Node | Degree | | ||||||||||||||||
| ---- | ------ | | ||||||||||||||||
| 3 | 2 | | ||||||||||||||||
| 4 | 1 | | ||||||||||||||||
|
||||||||||||||||
## Usage Notes | ||||||||||||||||
|
||||||||||||||||
- When `both` is specified, the in and out degrees of the node are summed. So if | ||||||||||||||||
(a)-[:R]->(b) and (b)-[:R]->(a) then (a) would have a degree of 2 when | ||||||||||||||||
`both` is specified. | ||||||||||||||||
- When multiple labels are specified, the nodes' degrees accross each of those | ||||||||||||||||
labels are summed together. | ||||||||||||||||
- This algorithm counts multi-edges and self-edges towards the degree. | ||||||||||||||||
- Computationally cheapest when computing the outdegree, especially on | ||||||||||||||||
undirected graphs. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
title: "Graph Algorithms" | ||
description: Graph Algorithms | ||
nav_order: 4 | ||
has_children: true | ||
--- | ||
|
||
# FalkorDB Algorithms Documentation | ||
|
||
Welcome to the FalkorDB Algorithms Documentation! This guide provides an overview of all algorithms available within FalkorDB, enabling powerful graph analytics and insights. Each algorithm is designed to help you process and analyze graph data efficiently for a variety of use cases. | ||
|
||
## Available Algorithms | ||
|
||
Below is the list of supported algorithms in FalkorDB. Click on an algorithm to view its detailed documentation, including syntax, examples, and practical use cases: | ||
|
||
### Traversal Algorithms | ||
- [BFS](algorithms/BFS) | ||
- Performs a Breadth-First Search traversal of the graph. | ||
|
||
### Centrality Algorithms | ||
- [PageRank](algorithms/page_rank) | ||
- Measures the importance of nodes based on incoming connections. | ||
|
||
### Connectivity Algorithms | ||
- [Degree](algorithms/degree) | ||
- Calculates the degree of nodes, focusing on connectivity based on edge direction and type. | ||
|
||
### Pathfinding Algorithms | ||
- [Shortest Path](algorithms/shortest_path) | ||
- Finds the shortest path between two nodes. | ||
|
||
### Community Detection Algorithms | ||
- [Label Propagation](algorithms/label_propagation) | ||
- Identifies communities based on label diffusion through the graph. | ||
Comment on lines
+16
to
+34
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. 💡 Codebase verification Documentation structure is broken and inconsistent The following documentation links are broken:
Additionally, there's an inconsistency where 🔗 Analysis chainVerify algorithm documentation links. The links appear to be relative paths. Let's ensure they point to valid documentation files. Note: 'Pathfinding' flagged by the spellchecker is a correct technical term and can be safely added to the dictionary. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify that all referenced algorithm documentation files exist
# Expected: All files should exist in the algorithms directory
for algo in "BFS" "page_rank" "degree" "shortest_path" "label_propagation"; do
if ! fd -t f "^${algo}\.(md|mdx)$" algorithms/; then
echo "Missing documentation for: $algo"
fi
done
Length of output: 638 Script: #!/bin/bash
# Check if the algorithms are documented in directories with index files
for algo in "BFS" "page_rank" "degree" "shortest_path" "label_propagation"; do
echo "Checking $algo:"
# Check if directory exists
fd -t d "^${algo}$" algorithms/
# Check for index files in that directory
fd -t f "^index\.(md|mdx)$" "algorithms/${algo}" 2>/dev/null || true
done
Length of output: 1111 🧰 Tools🪛 GitHub Actions: spellcheck[error] Spelling errors found: 'analytics' (appears twice) [error] Spelling error found: 'Pathfinding' |
||
|
||
--- | ||
|
||
## Getting Started | ||
|
||
To begin using any of the algorithms: | ||
1. Ensure FalkorDB is installed and running. | ||
2. Load your graph data into FalkorDB. | ||
3. Refer to the detailed documentation for each algorithm to configure and execute it. | ||
|
||
For example, to calculate node degrees: | ||
|
||
```plaintext | ||
CALL algo.degree({}) | ||
``` | ||
|
||
--- | ||
|
||
## Feedback and Contributions | ||
|
||
We welcome feedback and contributions! If you encounter issues or have suggestions for new algorithms, please visit our [GitHub repository](https://github.com/FalkorDB/FalkorDB). | ||
|
||
Happy graph analytics with FalkorDB! | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- | ||
title: "Client Libraries" | ||
nav_order: 4 | ||
nav_order: 5 | ||
description: > | ||
FalkorDB Clients | ||
--- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- | ||
title: Building Docker | ||
nav_order: 6 | ||
nav_order: 8 | ||
description: "Building docker container examples" | ||
--- | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- | ||
title: "Operations" | ||
nav_order: 10 | ||
nav_order: 12 | ||
description: "Configuring FalkorDB Docker" | ||
--- | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix typo in front-matter description.
There's a misspelling in the description field.
📝 Committable suggestion
🤖 Prompt for AI Agents