DEV Community

Nisa J. Thani
Nisa J. Thani

Posted on • Updated on

Neo4j basics

What is a graph?

A graph is a set of objects in which some pairs of the objects are connected. The objects are known as nodes and the connections are known as relationships. With these two elements, we can solve real-world problems by creating or inferring connections between objects. We can also create predictions given the strength of the connections.

A set of connected circles

How are graphs structured?

In an undirected graph, the relationships are bi-directional or symmetric; in a directed graph, the relationships have one direction.

Undirected graph vs directed graph

In a weighted graph, the relationships carry measurable values such as cost, time, distance or priority.

Weighted graph

The structure of a graph enables traversal. The process consists of following the relationships. With Neo4j's Cypher query language, relationships are not be followed multiple times.

Some common use-cases for graphs

  • E-commerce and real-time recommendations:
    Recommendations like "People who bought {Product X} also bought…" can be generated by having a proportion of the graph be traversed. In this example, you traverse from one Product node to the Persons nodes who have purchased that product and then to the subsequent Products nodes that they have bought.

  • Investigative journalism:
    The graph known as Panana Papers was created to identify possible corruption based upon the relationships between people, companies, and most importantly financial institutions.

  • Network and IT operations:
    A typical graph would describe how information flows through a system and how components of a network are related

  • Transportation and logistics:
    A typical graph would describe how locations are related and the distances between them

Top comments (0)