Skip to content

Commit 7b477f4

Browse files
matanbroitMatan Broitbarakbswilly22
authored
Update Docs towards New Version Deploy (#155)
* created folder and mds. TODO - put cyper-path-functions under cypher folder * put dedicated path_algorithm.md under cypher/functions.md. clean reduncdancy in match.md. fixed links * added more untracked files related to previous commit * (1) add algos (2) add memory usage * small changes to algos and memory usage * add DEDUPLICATE_STRINGS to configuration md * fix spell checker * add the updated wordlist file * add verbosity * minor typo fix * add array indices * add to wordlist * added (1) between centrality algo (2) remove dedupliacte string (3) update new memory usage (4) minor edits and fixes * add wordllist * added cdlp * spellcheck --------- Co-authored-by: Matan Broit <matanbroit@Matans-MacBook-Pro.local> Co-authored-by: Barak Bar Orion <barak.bar@gmail.com> Co-authored-by: Roi Lipman <roilipman@gmail.com> Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>
1 parent b1960ff commit 7b477f4

22 files changed

+1000
-641
lines changed

.wordlist.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ CMD
1313
CSC
1414
CSV
1515
CSVs
16+
CDLP
17+
communityId
1618
Cailliau
1719
Centos
1820
ColumnType
@@ -360,3 +362,21 @@ propname
360362
propvalue
361363
ro
362364
GenAI
365+
366+
WCC
367+
SPpath
368+
SSpath
369+
370+
undirected
371+
preprocessing
372+
subgraphs
373+
directionality
374+
iteratively
375+
analytics
376+
Pathfinding
377+
Brin
378+
Sergey
379+
lookups
380+
componentId
381+
Betweenness
382+
betweenness

algorithms/betweenness_centrality.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
title: "Betweenness Centrality"
3+
description: "Measures the importance of nodes based on the number of shortest paths that pass through them."
4+
parent: "Algorithms"
5+
---
6+
7+
# Betweenness Centrality
8+
9+
## Introduction
10+
11+
Betweenness Centrality is a graph algorithm that quantifies the importance of a node based on the number of shortest paths that pass through it. Nodes that frequently occur on shortest paths between other nodes have higher betweenness centrality scores. This makes the algorithm useful for identifying **key connectors** or **brokers** within a network.
12+
13+
## Algorithm Overview
14+
15+
The core idea of Betweenness Centrality is that a node is more important if it lies on many of the shortest paths connecting other nodes. It’s particularly useful in understanding information flow or communication efficiency in a graph.
16+
17+
For example, in a social network, a person who frequently connects otherwise unconnected groups would have high betweenness centrality.
18+
19+
## Syntax
20+
21+
The procedure has the following call signature:
22+
```cypher
23+
CALL algo.betweenness({
24+
nodeLabels: [<node_label>],
25+
relationshipTypes: [<relationship_type>]
26+
})
27+
YIELD node, score
28+
```
29+
30+
### Parameters
31+
32+
| Name | Type | Description | Default |
33+
|-----------------------|---------|-------------------------------------------------|---------|
34+
| `nodeLabels` | Array | *(Optional)* List of Strings representing node labels | [] |
35+
| `relationshipTypes` | Array | *(Optional)* List of Strings representing relationship types | [] |
36+
37+
### Yield
38+
39+
| Name | Type | Description |
40+
|---------|-------|-----------------------------------------------|
41+
| `node` | Node | The node being evaluated |
42+
| `score` | Float | The betweenness centrality score for the node |
43+
44+
## Example:
45+
46+
Lets take this Social Graph as an example:
47+
![Social Graph](../images/between.png)
48+
49+
### Create the Graph
50+
51+
```cypher
52+
CREATE
53+
(a:Person {name: 'Alice'}),
54+
(b:Person {name: 'Bob'}),
55+
(c:Person {name: 'Charlie'}),
56+
(d:Person {name: 'David'}),
57+
(e:Person {name: 'Emma'}),
58+
(a)-[:FRIEND]->(b),
59+
(b)-[:FRIEND]->(c),
60+
(b)-[:FRIEND]->(d),
61+
(c)-[:FRIEND]->(e),
62+
(d)-[:FRIEND]->(e)
63+
```
64+
65+
### Run Betweenness Centrality - Sort Persons by importance based on FRIEND relationship
66+
67+
```cypher
68+
CALL algo.betweenness({
69+
'nodeLabels': ['Person'],
70+
'relationshipTypes': ['FRIEND']
71+
})
72+
YIELD node, score
73+
RETURN node.name AS person, score
74+
ORDER BY score DESC
75+
```
76+
77+
Expected result:
78+
79+
| person | score |
80+
|-----------|--------|
81+
| `Bob` | 6 |
82+
| `Charlie` | 2 |
83+
| `David` | 2 |
84+
| `Alice` | 0 |
85+
| `Emma` | 0 |
86+
87+
## Usage Notes
88+
89+
- Scores are based on **all shortest paths** between node pairs.
90+
- Nodes that serve as bridges between clusters tend to score higher.
91+
- Can be computationally expensive on large, dense graphs.

algorithms/bfs.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
title: "BFS"
3+
description: "Breadth-First Search (BFS) explores a graph level by level, visiting all neighbors of a node before moving to the next depth."
4+
parent: "Algorithms"
5+
---
6+
7+
# BFS
8+
9+
## Overview
10+
11+
The Breadth-First Search (BFS) procedure allows you to perform a breadth-first traversal of a graph starting from a specific node.
12+
BFS explores all the nodes at the present depth before moving on to nodes at the next depth level.
13+
This is particularly useful for finding the shortest path between two nodes or exploring a graph layer by layer.
14+
15+
## Syntax
16+
17+
```
18+
CALL algo.bfs(start_node, max_depth, relationship)
19+
YIELD nodes, edges
20+
```
21+
22+
## Arguments
23+
24+
| Name | Type | Description | Default |
25+
|--------------|----------------|-----------------------------------------------------------------------------|------------|
26+
| start_node | Node | Starting node for the BFS traversal | (Required) |
27+
| max_depth | Integer | Maximum depth to traverse | (Required) |
28+
| relationship | String or null | The relationship type to traverse. If null, all relationship types are used | null |
29+
30+
## Returns
31+
32+
| Name | Type | Description |
33+
|-------|------|----------------------------------------------|
34+
| nodes | List | List of visited nodes in breadth-first order |
35+
| edges | List | List of edges traversed during the BFS |
36+
37+
## Examples
38+
39+
### Social Network Friend Recommendations
40+
41+
This example demonstrates how to use BFS to find potential friend recommendations in a social network.
42+
By exploring friends of friends, BFS uncovers second-degree connections—people you may know through mutual friends—which are often strong candidates for relevant and meaningful recommendations.
43+
44+
#### Create the Graph
45+
46+
```cypher
47+
CREATE
48+
(alice:Person {name: 'Alice', age: 28, city: 'New York'}),
49+
(bob:Person {name: 'Bob', age: 32, city: 'Boston'}),
50+
(charlie:Person {name: 'Charlie', age: 35, city: 'Chicago'}),
51+
(david:Person {name: 'David', age: 29, city: 'Denver'}),
52+
(eve:Person {name: 'Eve', age: 31, city: 'San Francisco'}),
53+
(frank:Person {name: 'Frank', age: 27, city: 'Miami'}),
54+
55+
(alice)-[:FRIEND]->(bob),
56+
(alice)-[:FRIEND]->(charlie),
57+
(bob)-[:FRIEND]->(david),
58+
(charlie)-[:FRIEND]->(eve),
59+
(david)-[:FRIEND]->(frank),
60+
(eve)-[:FRIEND]->(frank)
61+
```
62+
63+
![Graph BFS](../images/graph_bfs.png)
64+
65+
#### Find Friends of Friends (Potential Recommendations)
66+
67+
```
68+
// Find Alice's friends-of-friends (potential recommendations)
69+
MATCH (alice:Person {name: 'Alice'})
70+
CALL algo.bfs(alice, 2, 'FRIEND')
71+
YIELD nodes
72+
73+
// Process results to get only depth 2 connections (friends of friends)
74+
WHERE size(nodes) >= 3
75+
WITH alice, nodes[2] AS potential_friend
76+
WHERE NOT (alice)-[:FRIEND]->(potential_friend)
77+
RETURN potential_friend
78+
```
79+
80+
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.
81+
82+
83+
## Performance Considerations
84+
85+
- **Indexing:** Ensure properties used for finding your starting node are indexed for optimal performance
86+
- **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
87+
- **Relationship Filtering:** When applicable, specify the relationship type to limit the traversal scope
88+
- **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
89+
90+
## Error Handling
91+
92+
Common errors that may occur:
93+
94+
- **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
95+
- **Invalid Relationship Type:** If you specify a relationship type that doesn't exist in your graph, the traversal will only include the starting node
96+
- **Memory Limitations:** For large graphs with high connectivity, an out-of-memory error may occur if too many nodes are visited
97+
- **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

0 commit comments

Comments
 (0)