BTCE | 5th Sem
No-SQL SubjectUnit 4

No-SQL Unit 4: Complete Concepts Guide

Unit 4: Graph Databases, Cypher, Graph Algorithms & Neo4j -> Generated and Prepared By Thiruselvan (ThiruXD)

1. Introduction to Graph Databases

1.1 What is a Graph Database?

A graph database is a type of NoSQL database that stores and represents data as a graph, using nodes, relationships, and properties. It is designed to efficiently manage and query highly connected data, where the relationships between entities are as important as the entities themselves.

1.2 Core Components of a Graph

ComponentDescriptionExamples
NodesRepresent an entity or object; can have a label and propertiesPerson, Product, Company, City, Movie
RelationshipsRepresent a connection between two nodes; usually directed and has a type; can have propertiesFRIEND_OF, WORKS_AT, LIKES, PURCHASED, LIVES_IN
PropertiesKey-value pairs storing additional information about nodes or relationships(name: "Alice", age: 25), (since: 2020)

1.3 Example: Social Network

Person Node (Alice)              Person Node (Bob)
Properties:                      Properties:
name: "Alice"                    name: "Bob"
age: 25                          age: 27
city: "Bangalore"                city: "Mumbai"
      │                                │
      │ FRIEND_OF (since: 2020)        │
      └────────────────────────────────┘
      │                                │
      │ LIVES_IN                       │ WORKS_AT
      ↓                                ↓
City Node (Bangalore)          Company Node (ABC Corp)
Properties:                     Properties:
name: "Bangalore"              name: "ABC Corp"
country: "India"               industry: "IT"
                               location: "Bangalore"

1.4 In Simple Terms

Nodes = Things
Relationships = Connections
Properties = Details about things/connections

1.5 Why Graph Databases?

Graph databases are ideal when:

  • Relationships are first-class citizens — stored directly, not inferred via joins
  • Highly connected data — social networks, recommendations, fraud detection
  • Complex traversals — friends-of-friends, shortest paths
  • Evolving schema — flexible, schema-optional

2. Relational Databases vs Graph Databases

2.1 Comparison Table

AspectRelational DatabaseGraph Database
Data ModelTables with rows and columnsNodes (entities), relationships (edges), properties
SchemaPredefined schema (fixed structure)Flexible schema (schema optional, can evolve)
RelationshipsRepresented using foreign keys and joinsFirst-class citizens (stored directly as relationships)
Best Suited ForStructured data with well-defined schemaHighly connected data with complex relationships
Query LanguageSQL (MySQL, PostgreSQL, Oracle)Graph query languages (Cypher, Gremlin, SPARQL)
PerformanceJoins can be expensive for complex relationshipsFast traversal of relationships, efficient for connected data
ScalabilityScales well for large structured datasetsScales well for highly connected, evolving data
Common Use CasesBanking, ERP, inventory, transaction processingSocial networks, recommendation systems, fraud detection, knowledge graphs
ExamplesMySQL, PostgreSQL, Oracle, SQL ServerNeo4j, Amazon Neptune, JanusGraph, ArangoDB

2.2 Example: Student Data

Relational Database — Student Table:

IDNameAgeDepartment
1Alice23CSE
2Bob24ECE
3Carol22ME

Graph Database — Student Graph:

Alice ──FRIEND_OF──→ Bob
  │                    │
  │ STUDIES_AT         │ STUDIES_AT
  ↓                    ↓
ABC University ←───────┘

2.3 In Simple Terms

“Relational databases store data in tables. Graph databases store data as connected entities, making relationships easier and faster to work with.”


3. Property Graph Model

3.1 What is the Property Graph Model?

The property graph model is a graph data model in which data is represented using nodes and relationships, and both nodes and relationships can have properties in the form of key-value pairs.

3.2 Nodes

  • Represent entities or objects in the real world
  • Can have one or more labels
  • Contain a set of properties (key-value pairs)
  • Examples: a person, a student, a course, a company

3.3 Labels

  • A label identifies the type or category of a node
  • A node can have a single label or multiple labels
  • Labels help to group and query nodes
  • Examples: Student, Teacher, Course, Company
  • Example of multiple labels: {Student:Scholar {name: "Alice"}}

3.4 Relationship Types

  • A relationship type describes the nature of the connection between two nodes
  • Relationships are usually directed (from one node to another)
  • Can also have properties (key-value pairs)
  • Examples: ENROLLED_IN, FRIEND_OF, WORKS_AT, TEACHES, PURCHASED

3.5 Example: University Graph

:Student (Alice)                    :Course (NoSQL)
{id: 1, name: "Alice", age: 20}     {id: 101, name: "NoSQL", credits: 4}
      │                                     │
      │ ENROLLED_IN (year: 2026)            │ TAUGHT_BY (semester: "Fall 2026")
      └─────────────────────────────────────┘
      │                                     │
      │ WORKS_AT (since: 2023)              │
      ↓                                     ↓
:Company (ABC Corp)                 :Teacher (Dr. Kumar)
{id: 201, name: "ABC Corp",         {id: 301, name: "Dr. Kumar",
 industry: "IT"}                     department: "CSE"}

3.6 Legend

SymbolMeaning
○Node
→Relationship (with direction)
{…}Properties (key-value pairs)
:LabelNode label

3.7 Key Takeaway

In the property graph model, labels tell us what a node is, while relationship types tell us how two nodes are connected.


4. Cypher — Query Language for Neo4j

4.1 What is Cypher?

Cypher is a declarative, SQL-like query language used in Neo4j to create, read, update, and delete graph data.

4.2 Cypher Pattern Syntax

(a:Label)-[r:RELATIONSHIP_TYPE]->(b:Label)
ElementMeaning
( )Nodes
[ ]Relationships
->Outgoing direction
<-Incoming direction
:LabelNode label
:RELATIONSHIP_TYPERelationship type
{key: value}Properties

4.3 CREATE Example

Create two Person nodes and a FOLLOWS relationship:

CREATE (a:Person {name: 'Alice', age: 25}),
       (b:Person {name: 'Bob', age: 27})
CREATE (a)-[:FOLLOWS]->(b)
RETURN a, b;

Explanation:

  • Creates two nodes with the label Person and properties name and age
  • Creates a directed relationship of type FOLLOWS from Alice to Bob
  • Returns the created nodes

Graph Result:

:Person (Alice)  ──FOLLOWS──→  :Person (Bob)
name: "Alice"                  name: "Bob"
age: 25                        age: 27

4.4 Key Points

  • CREATE is used to add new nodes and relationships
  • Nodes are labeled using :Person
  • Properties are added as key-value pairs
  • Relationships have a type, here FOLLOWS
  • The arrow (→) shows the direction (from Alice to Bob)

5. CREATE vs MERGE in Cypher

5.1 CREATE

  • Always creates new nodes or relationships
  • Does not check if the data already exists
  • Can result in duplicate nodes/relationships if run multiple times
  • Useful when you are sure the data does not exist

Example:

CREATE (p:Person {name: 'Alice', age: 25})
RETURN p;

Run twice → Two separate nodes (duplicates):

:Person (Alice)  :Person (Alice)
name: "Alice"    name: "Alice"
age: 25          age: 25

5.2 MERGE

  • Creates a node or relationship only if it does not exist
  • If it exists, it matches the existing one
  • Helps avoid duplicate data
  • Commonly used to ensure uniqueness

Example:

MERGE (p:Person {name: 'Alice', age: 25})
RETURN p;

Run twice → Only one node created:

:Person (Alice)
name: "Alice"
age: 25

5.3 Comparison Table

AspectCREATEMERGE
BehaviourAlways creates new dataCreates only if not exists; otherwise matches
Duplicate DataCan create duplicatesPrevents duplicates
Use CaseWhen you want to always create a new node/relationshipWhen you want to ensure uniqueness
Result on Repeated ExecutionMultiple identical nodes/relationshipsSingle node/relationship (existing one returned)

5.4 Key Takeaway

“Use CREATE when you want to always create. Use MERGE when you want to create only if it doesn’t exist (otherwise match).”


6. Graph Traversal

6.1 What is Graph Traversal?

Graph traversal is the process of navigating through a graph by following relationships (edges) from one node to another to find connected nodes.

6.2 Example Graph: Social Network

        Carol
          ↑
          │ FOLLOWS
          │
David ←─────── Alice ───────→ Bob
  FOLLOWS     (center)    FOLLOWS

6.3 One-Hop Traversal

Find the immediate neighbors (directly connected nodes) from a given node.

Cypher Query:

MATCH (a:Person {name: 'Alice'})-[:FOLLOWS]->(b:Person)
RETURN b;

Result:

b
Bob
Carol

From Alice, the one-hop traversal returns Bob and Carol (nodes directly connected to Alice).

6.4 Two-Hop Traversal

Find nodes that are two relationships away from a given node.

Cypher Query:

MATCH (a:Person {name: 'Alice'})-[:FOLLOWS]->()-[:FOLLOWS]->(c:Person)
RETURN c;

Result:

c
David

From Alice, the two-hop traversal returns David (a node that is two steps away: Alice → Bob → David).

6.5 Variable-Length Traversal

Find nodes reachable within a variable number of hops.

Cypher Query:

MATCH (a:Person {name: 'Alice'})-[:FOLLOWS*1..3]->(p:Person)
RETURN DISTINCT p.name;

Result:

Bob
Carol
David

6.6 Shortest Path Query

Find the shortest path between two nodes.

Cypher Query:

MATCH p = shortestPath(
    (a:Person {name: 'Alice'})-[:FOLLOWS*]-(e:Person {name: 'Eve'})
)
RETURN [n in nodes(p) | n.name] AS path;

Result:

path
["Alice", "Carol", "Eve"]

6.7 Other Traversal Techniques

TechniqueDescriptionExample Use Case
Depth-First Traversal (DFS)Explores as far as possible along each branchPath exploration, hierarchy traversal
Breadth-First Traversal (BFS)Explores all neighbors level by levelFinding shortest paths, social networks
Filtered TraversalUse WHERE to apply conditionsFind friends in a specific location
Multi-relationship TraversalTraverse multiple relationship typesFind people who follow or like a user
Bidirectional TraversalUse undirected patternsFind any connection between two nodes

6.8 Relationship-Based Search with Conditions

Find people Alice follows since 2023:

MATCH (a:Person {name: 'Alice'})-[r:FOLLOWS]->(b:Person)
WHERE r.since >= 2023
RETURN b.name, r.since;

Result:

name    since
Bob     2023

6.9 Key Takeaway

Graph traversals in Neo4j help you explore, analyze, and discover relationships in connected data, enabling powerful insights such as recommendations, influence, and network analysis.


7. Graph Algorithms

Graph algorithms analyze the structure and relationships in a graph to find meaningful patterns. They help identify important nodes, discover communities, find connections, and measure similarity.

7.1 Algorithm Categories

CategoryPurposeExamples
CentralityMeasure importance of nodesPageRank, Degree, Betweenness, Closeness
Community DetectionFind groups of densely connected nodesLouvain, Leiden, Label Propagation
Path FindingFind routes between nodesDijkstra, A*, BFS, DFS
SimilarityMeasure how similar two nodes areNode Similarity, KNN, Jaccard, Cosine

7.2 Centrality Algorithms

Measure the importance of nodes based on their position and connections. Help identify key individuals, items, or entities in a network.

Examples:

  • PageRank
  • Degree Centrality
  • Betweenness Centrality
  • Closeness Centrality

Example — PageRank:

Measures the importance of nodes based on the number and quality of incoming links. A node is important if it is linked by other important nodes.

A → C ← B
    ↑
    D
    ↑
    E

PageRank Scores:

NodePageRank Score
C0.42
A0.21
D0.18
B0.12
E0.07

Use Case: Finding influential users in a social network.


7.3 Community Detection Algorithms

Partition the graph into communities where nodes are more connected within the group than with outside nodes. Useful for finding natural groups, such as social circles or customer segments.

Examples:

  • Louvain
  • Leiden
  • Label Propagation
  • Weakly Connected Components

Example:

Community 1 (Friends)     Community 2 (Colleagues)
   B ── C                    D ── E
   │    │                    │    │
   A ───┘                    F ───┘

The graph is divided into communities using the Louvain/Leiden algorithm.

Use Case: Detecting groups of users with similar interests.


7.4 Path Finding Algorithms

Find paths or shortest routes between nodes. Determine paths based on distance, cost, or other criteria.

Examples:

  • Dijkstra’s Shortest Path
  • A* Shortest Path
  • Breadth-First Search (BFS)
  • Depth-First Search (DFS)

Example:

        B
     2 ↗   ↘ 5
A → 1 → C → 2 → E
     4 ↘   ↗ 1
        D

Shortest path from A to E: A → C → E (total cost = 3)

Use Case: Finding the shortest route between two cities.


7.5 Similarity Algorithms

Measure how similar two nodes are, typically based on shared neighbors or attributes. Useful for recommendations, fraud detection, and finding similar items or users.

Examples:

  • Node Similarity
  • K-Nearest Neighbors (KNN)
  • Jaccard Similarity
  • Cosine Similarity

Example:

     Item A
    ↗      ↘
  U1        U2
    ↘      ↗
     Item B
    ↗      ↘
  U1        U2
    ↘      ↗
     Item C

U1 and U2 are similar because they are connected to the same items (Item A, Item B, Item C).

Similarity Scores:

Node PairSimilarity Score
A – B0.80
A – C0.65
B – D0.60

Use Case: Recommending similar products or suggesting friends.


7.6 Key Takeaway

Graph algorithms turn connected data into actionable insights — helping us find what is important, how things are related, what groups exist, and what is similar, enabling smarter decisions in real-world applications.


8. Graph Analytics Use Cases

8.1 Social Network Analysis

Graph Model:

Person (Bob) ←─FRIENDS_WITH─→ Person (Alice) ←─FOLLOWS─→ Person (Carol)
                                    │
                          ┌─────────┼─────────┐
                          │         │         │
                       LIKES    CREATED   COMMENTED
                          ↓         ↓         ↓
                       Like      Post      Comment
                                  │
                              HAS_TAG
                                  ↓
                                Tag

8.2 Sample Cypher Queries

1. Create a user:

CREATE (p:Person {
    userid: 'u1001',
    name: 'Alice',
    age: 25,
    location: 'Bangalore',
    joinDate: date()
});

2. Create a friendship:

MATCH (a:Person {name: 'Alice'}), (b:Person {name: 'Bob'})
MERGE (a)-[:FRIENDS_WITH {since: date()}]->(b);

3. Find a user’s friends:

MATCH (p:Person {name: 'Alice'})-[:FRIENDS_WITH]-(f:Person)
RETURN f.name, f.location;

4. Find posts by a user:

MATCH (p:Person {name: 'Alice'})-[:CREATED]->(post:Post)
RETURN post.postid, post.content, post.createdAt;

5. Add a tag to a post:

MERGE (t:Tag {name: 'Neo4j'})
MATCH (p:Post {postid: 'p100'})
MERGE (p)-[:HAS_TAG]->(t);

6. Find popular posts:

MATCH (p:Post)<-[:LIKES]-(Person)
RETURN p.postid, p.content, count(*) AS likeCount
ORDER BY likeCount DESC
LIMIT 5;

7. Friend recommendations (friends-of-friends):

MATCH (p:Person {name: 'Alice'})-[:FRIENDS_WITH]-(f:Person)
WHERE NOT (p)-[:FRIENDS_WITH]-(f)
AND p <> f
RETURN DISTINCT f.name, f.location
LIMIT 10;

9. Neo4j Architecture Overview

9.1 What is Neo4j?

Neo4j is a native graph database that stores data as nodes and relationships. It uses a property graph model and provides a high-performance graph engine, Cypher query language, and tools for data management and visualization.

9.2 Architecture Layers

┌─────────────────────────────────────────────────────┐
│  Applications     │  Cypher Query    │  Tools       │
│  (Web, Mobile)    │  Language        │  (Browser,   │
│                   │                  │   Bloom)     │
├─────────────────────────────────────────────────────┤
│           Neo4j Database Engine                     │
│  Stores, indexes, processes and traverses the graph │
├─────────────────────────────────────────────────────┤
│              Graph Storage                          │
│  Nodes │ Relationships │ Labels │ Properties        │
└─────────────────────────────────────────────────────┘

9.3 Property Graph Data Model

:Person (Alice)  ←──FRIENDS_WITH──→  :Person (Bob)
{name: "Alice",                     {name: "Bob",
 age: 25,                            age: 27,
 location: "Bangalore"}              location: "Mumbai"}
      │                                    │
      │ CREATED                            │ LIKES
      ↓                                    ↓
:Post (Graph DB)                    :Post (Graph DB)
{title: "Graph DB",                 {createdAt: "2024-09-01"}
 content: "Neo4j is amazing!",
 createdAt: "2024-09-01"}

9.4 Nodes

  • Represent entities (e.g., people, posts, products)
  • Can have one or more labels
  • Store properties as key-value pairs
  • Represent a real-world entity

9.5 Relationships

  • Connect two nodes and represent how they are related
  • Always have a direction (start → end)
  • Can have a type (e.g., FRIENDS_WITH, LIKES)
  • Can store properties (e.g., since, createdAt)
  • Represent meaningful connections between entities

9.6 Labels and Properties

Node Labels and Properties:

LabelExample Properties
:Personname, age, location
:Posttitle, content, createdAt
:Productname, price

Relationship Types and Properties:

TypeExample Properties
:FRIENDS_WITHsince
:LIKEScreatedAt
:CREATEDcreatedAt

Key Points:

  • Labels define the type of node or relationship
  • Properties store information as key-value pairs
  • Both labels and properties make the data flexible and easy to query
  • You can have multiple labels and multiple properties
  • Indexes can be created on labels and properties for faster search

9.7 Key Takeaway

Neo4j’s architecture and property graph model make it ideal for representing and querying highly connected data such as social networks, recommendation systems, fraud detection, knowledge graphs, and more.


10. Graph Traversal in Neo4j — Detailed

10.1 What is Graph Traversal?

Graph traversal is the process of navigating through a graph by following relationships (edges) from one node to another. In Neo4j, traversals are performed using Cypher pattern matching. Traversals can be fixed-length, variable-length, or based on specific conditions such as shortest path.

10.2 Why Use Graph Traversals?

  • Find connected data and explore relationships
  • Discover hidden patterns and connections
  • Build recommendations, perform network analysis
  • Understand complex data with simple queries

10.3 Cypher Pattern Syntax

(a:Label)-[r:RELATIONSHIP_TYPE]->(b:Label)
  • Nodes are written in parentheses ( )
  • Relationships are written in square brackets [ ]
  • Direction is specified using > (outgoing) or <- (incoming)
  • Labels and properties can be used to filter results

10.4 Simple Relationship Traversal

Find people that Alice directly follows:

MATCH (a:Person {name: 'Alice'})-[:FOLLOWS]->(b:Person)
RETURN b.name;

Result:

name
Bob

10.5 Variable-Length Traversal

Find people reachable from Alice within 1 to 3 hops:

MATCH (a:Person {name: 'Alice'})-[:FOLLOWS*1..3]->(p:Person)
RETURN DISTINCT p.name;

Result:

name
Bob
Carol
David

10.6 Shortest-Path Analysis

Find the shortest path between two nodes:

MATCH p = shortestPath(
    (a:Person {name: 'Alice'})-[:FOLLOWS*]-(b:Person {name: 'Eve'})
)
RETURN [n in nodes(p) | n.name] AS path;

Result:

path
["Alice", "Carol", "Eve"]

10.7 Key Takeaways

  • Neo4j stores data as nodes and relationships, making traversals natural and efficient
  • Cypher provides a powerful and expressive way to perform graph traversals
  • Use relationship-based patterns, variable-length traversals, and shortest path functions to explore and analyze connected data
  • Graph traversals enable real-world applications such as friend suggestions, recommendations, fraud detection, and network analysis

11. Unit Summary

NoSQL UNIT 4 — GRAPH DATABASES, CYPHER, GRAPH ALGORITHMS & NEO4J
│
├── Introduction to Graph Databases
│   ├── Definition (nodes, relationships, properties)
│   ├── Social network example
│   └── Why graph databases
│
├── Relational vs Graph Databases
│   ├── Data model comparison
│   ├── Schema comparison
│   ├── Relationship handling
│   └── Use case comparison
│
├── Property Graph Model
│   ├── Nodes (entities)
│   ├── Labels (categories)
│   ├── Relationship types (connections)
│   ├── Properties (key-value pairs)
│   └── University graph example
│
├── Cypher — Query Language
│   ├── Pattern syntax
│   ├── CREATE example
│   ├── CREATE vs MERGE
│   └── Key points
│
├── Graph Traversal
│   ├── One-hop traversal
│   ├── Two-hop traversal
│   ├── Variable-length traversal
│   ├── Shortest path query
│   ├── DFS / BFS
│   └── Filtered traversal
│
├── Graph Algorithms
│   ├── Centrality (PageRank, Degree, Betweenness, Closeness)
│   ├── Community Detection (Louvain, Leiden, Label Propagation)
│   ├── Path Finding (Dijkstra, A*, BFS, DFS)
│   └── Similarity (Node Similarity, KNN, Jaccard, Cosine)
│
├── Graph Analytics Use Cases
│   ├── Social network analysis
│   ├── Sample Cypher queries
│   │   ├── Create user
│   │   ├── Create friendship
│   │   ├── Find friends
│   │   ├── Find posts
│   │   ├── Add tag
│   │   ├── Find popular posts
│   │   └── Friend recommendations
│   └── Key insights
│
└── Neo4j Architecture
    ├── Architecture layers
    ├── Property graph data model
    ├── Nodes
    ├── Relationships
    ├── Labels and properties
    └── Graph traversal in Neo4j

12. Key Syntax — Quick Reference

ConceptSyntax/Example
Create nodeCREATE (p:Person {name: 'Alice', age: 25})
Create relationshipCREATE (a)-[:FOLLOWS]->(b)
Match nodeMATCH (p:Person {name: 'Alice'})
Match relationshipMATCH (a)-[:FOLLOWS]->(b)
ReturnRETURN p.name
MERGEMERGE (p:Person {name: 'Alice'})
WHEREWHERE r.since >= 2023
Variable-length[:FOLLOWS*1..3]
Shortest pathshortestPath((a)-[:FOLLOWS*]-(b))
Countcount(*)
Order byORDER BY likeCount DESC
LimitLIMIT 5
DistinctRETURN DISTINCT p.name
List comprehension`[n in nodes(p)
Date functiondate()
Label:Person, :Post
Relationship type:FOLLOWS, :FRIENDS_WITH
Property{name: 'Alice', age: 25}

13. Exam-Focused Points

  1. Graph database — Stores data as nodes, relationships, properties.
  2. Node — Entity; has label and properties.
  3. Relationship — Connection between nodes; directed; has type.
  4. Property — Key-value pair storing details.
  5. Relational vs Graph — Tables vs connected entities.
  6. Property graph model — Nodes + relationships + properties + labels.
  7. Label — Type/category of a node.
  8. Relationship type — Nature of connection (FRIEND_OF, WORKS_AT).
  9. Cypher — Query language for Neo4j.
  10. CREATE — Always creates new data.
  11. MERGE — Creates only if not exists.
  12. CREATE vs MERGE — Duplicates vs uniqueness.
  13. Graph traversal — Navigating through relationships.
  14. One-hop traversal — Direct neighbors.
  15. Two-hop traversal — Nodes two steps away.
  16. Variable-length traversal — [:FOLLOWS*1..3].
  17. Shortest path — shortestPath().
  18. DFS — Depth-first; explores branch.
  19. BFS — Breadth-first; level by level.
  20. Centrality algorithms — PageRank, Degree, Betweenness, Closeness.
  21. PageRank — Importance based on incoming links.
  22. Community detection — Louvain, Leiden.
  23. Path finding — Dijkstra, A*, BFS, DFS.
  24. Similarity — Node similarity, KNN, Jaccard, Cosine.
  25. Neo4j — Native graph database.
  26. Neo4j architecture — Applications → Cypher → Engine → Storage.
  27. Neo4j storage — Nodes, relationships, labels, properties.
  28. Indexes — On labels and properties for faster search.
  29. Social network use case — Friends, posts, likes, tags.
  30. Friend recommendations — Friends-of-friends query.

14. Glossary of Key Terms

TermDefinition
Graph DatabaseNoSQL database storing data as nodes, relationships, and properties
NodeEntity or object in a graph
RelationshipConnection between two nodes
PropertyKey-value pair storing information
LabelType/category of a node
Relationship TypeNature of connection between nodes
Property Graph ModelGraph model with nodes, relationships, labels, properties
CypherDeclarative query language for Neo4j
CREATECypher command to create new data
MERGECypher command to create if not exists
MATCHCypher command to find data
RETURNCypher command to output results
WHERECypher clause for filtering
Graph TraversalNavigating through relationships
One-HopDirectly connected nodes
Two-HopNodes two steps away
Variable-LengthTraversal with variable hops (*1..3)
Shortest PathMinimum cost path between nodes
DFSDepth-First Search
BFSBreadth-First Search
CentralityMeasure of node importance
PageRankCentrality based on incoming links
Degree CentralityNumber of connections
Betweenness CentralityHow often a node lies on shortest paths
Closeness CentralityAverage distance to other nodes
Community DetectionFinding densely connected groups
LouvainCommunity detection algorithm
LeidenImproved Louvain algorithm
Path FindingFinding routes between nodes
DijkstraShortest path algorithm
A*Heuristic shortest path algorithm
SimilarityMeasure of how alike two nodes are
Jaccard SimilarityIntersection over union of neighbors
Cosine SimilarityCosine of angle between vectors
KNNK-Nearest Neighbors
Neo4jNative graph database
Graph AnalyticsAnalyzing graph structure for insights
Graph Data Science (GDS)Neo4j library for graph algorithms

On this page

1. Introduction to Graph Databases1.1 What is a Graph Database?1.2 Core Components of a Graph1.3 Example: Social Network1.4 In Simple Terms1.5 Why Graph Databases?2. Relational Databases vs Graph Databases2.1 Comparison Table2.2 Example: Student Data2.3 In Simple Terms3. Property Graph Model3.1 What is the Property Graph Model?3.2 Nodes3.3 Labels3.4 Relationship Types3.5 Example: University Graph3.6 Legend3.7 Key Takeaway4. Cypher — Query Language for Neo4j4.1 What is Cypher?4.2 Cypher Pattern Syntax4.3 CREATE Example4.4 Key Points5. CREATE vs MERGE in Cypher5.1 CREATE5.2 MERGE5.3 Comparison Table5.4 Key Takeaway6. Graph Traversal6.1 What is Graph Traversal?6.2 Example Graph: Social Network6.3 One-Hop Traversal6.4 Two-Hop Traversal6.5 Variable-Length Traversal6.6 Shortest Path Query6.7 Other Traversal Techniques6.8 Relationship-Based Search with Conditions6.9 Key Takeaway7. Graph Algorithms7.1 Algorithm Categories7.2 Centrality Algorithms7.3 Community Detection Algorithms7.4 Path Finding Algorithms7.5 Similarity Algorithms7.6 Key Takeaway8. Graph Analytics Use Cases8.1 Social Network Analysis8.2 Sample Cypher Queries9. Neo4j Architecture Overview9.1 What is Neo4j?9.2 Architecture Layers9.3 Property Graph Data Model9.4 Nodes9.5 Relationships9.6 Labels and Properties9.7 Key Takeaway10. Graph Traversal in Neo4j — Detailed10.1 What is Graph Traversal?10.2 Why Use Graph Traversals?10.3 Cypher Pattern Syntax10.4 Simple Relationship Traversal10.5 Variable-Length Traversal10.6 Shortest-Path Analysis10.7 Key Takeaways11. Unit Summary12. Key Syntax — Quick Reference13. Exam-Focused Points14. Glossary of Key Terms