Skip to content
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

Algorithms section & degree docs #117

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -347,3 +347,4 @@ hostnames
bigmac
calmcode
io
influencers
149 changes: 149 additions & 0 deletions algorithms/degree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# 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

```plaintext
CALL algo.degree(config)
```

### Parameters

The `config` parameter is a Map object containing the following optional keys:

| Key | Type | Default | Description |
| ------------- | ------ | ---------- | ---------------------------------------------------------------------- |
| `source` | String | `null` | Specifies the label of nodes for which the degree is computed. |
| `dir` | String | `outgoing` | Direction of edges to consider: `incoming` or `outgoing`. |
| `relation` | String | `null` | Specifies the type of edges to consider. |
| `destination` | String | `null` | Specifies the label of nodes reachable via the edges being considered. |

---

## 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({source: 'Person'})
```

#### Result:

| Node | Degree |
| ---- | ------ |
| 1 | 2 |
| 2 | 3 |

---

### Example 3: Compute the outgoing degree for a specific relationship type

```plaintext
CALL algo.degree({source: 'Person', relation: 'FRIEND', dir: 'outgoing'})
```

#### Result:

| Node | Degree |
| ---- | ------ |
| 1 | 1 |

---

### Example 4: Compute the incoming degree for reachable nodes of a specific type

```plaintext
CALL algo.degree({source: 'Person', relation: 'VISITED', dir: 'incoming', destination: 'City'})
```

#### Result:

| Node | Degree |
| ---- | ------ |
| 3 | 2 |
| 4 | 1 |


59 changes: 59 additions & 0 deletions algorithms/index.md
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
Copy link
Contributor

Choose a reason for hiding this comment

The 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:

  • algorithms/BFS - directory doesn't exist
  • algorithms/page_rank - directory doesn't exist
  • algorithms/shortest_path - directory doesn't exist
  • algorithms/label_propagation - directory doesn't exist

Additionally, there's an inconsistency where degree is documented in a flat file (algorithms/degree.md) while others use a directory-based approach in the navigation.

🔗 Analysis chain

Verify 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 executed

The 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!


File renamed without changes.
2 changes: 1 addition & 1 deletion bolt_support.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "BOLT protocol support"
nav_order: 10
nav_order: 11
description: "Connecting to FalkorDB using BOLT protocol."
---

Expand Down
2 changes: 1 addition & 1 deletion clients.md
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
---
Expand Down
2 changes: 1 addition & 1 deletion cypher/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Cypher Language"
nav_order: 7
nav_order: 9
description: >
Cypher Language documentation
has_children: true
Expand Down
2 changes: 1 addition & 1 deletion datatypes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Data types"
description: "FalkorDB supports a number of distinct data types, some of which can be persisted as property values and some of which are ephemeral."
nav_order: 5
nav_order: 6
---

# Graph types
Expand Down
2 changes: 1 addition & 1 deletion docker-examples/README.md
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"
---

Expand Down
2 changes: 1 addition & 1 deletion integration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Integration"
description: "Learn how to integrate FalkorDB into your applications with REST APIs"
has_children: true
nav_order: 5
nav_order: 7
---

# Integration
Expand Down
2 changes: 1 addition & 1 deletion llm_support.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "LLM frameworks support"
nav_order: 8
nav_order: 10
description: "FalkorDB supports a number of LLM frameworks."
---

Expand Down
2 changes: 1 addition & 1 deletion operations/index.md
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"
---

Expand Down
2 changes: 1 addition & 1 deletion redisgraph-to-falkordb.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "RedisGraph to FalkorDB"
nav_order: 11
nav_order: 13
description: "Migrate from RedisGraph to FalkorDB."
---

Expand Down
Loading