Important announcement

Dear visitor,

Please note that this OpenCourseWare platform will be replaced at the end of 2026 by a new platform (under the same url ocw.tudelft.nl).

Courses and their contents that are currently available the platform will partly be migrated. URL’s for this content will change and content might be unavailable for some time. In addition, some courses will not be available anymore.

If you are linking to specific courses on this platform (for instance for your students), please take timely measures to avoid problems with access. Possible actions are:

  • Download the materials to your local platform (laptop, server)
  • For educators only (including TU Delft lecturers): Contact us at ocw@tudelft.nl and inform us what course you are using in what context (institute, program, period of use, number of students). We will research (in collaboration with the authors of the course) and decide if we will migrate the course, and if yes, can supply you with a new url.

Thank you.

8.3 Graph solutions

Course subject(s) 8. Alternatives Neo4J

Introduction on Neo4j, a very specialised tool used to store and analyse graphs. Keep in mind, you should not run to your spreadsheet immediately, it is not always the best solution.

Sorry but there don't seem to be any downloads..

Subtitles (captions) in other languages than provided can be viewed at YouTube. Select your language in the CC-button of YouTube.

Commands used

Creating the movies:

LOAD CSV WITH HEADERS FROM

“file:/path/to/file/file.csv”

as row

CREATE (m:movie {name:row.movie})

A simple match command for the graph:

MATCH(n) return n

Creating the actors:

LOAD CSV WITH HEADERS FROM

“file:/path/to/file/file.csv”

as row

CREATE (a:actor {fullname:row.fullname})

Creating the links between movies and actors:

LOAD CSV WITH HEADERS FROM

“file:/path/to/file/file.csv”

as row

MATCH (a:actor {fullname:row.fullname})

MATCH (m:movie {name:row.movie})

CREATE (a-[:acted]->m)

Looking for a path of 2 hops from Bacon to another actor:

MATCH (b:actor {fullname:”Kevin Bacon”})-[*2]-(a:actor)

RETURN a.fullname

Looking for all unique actors with a path of 4 hops from Bacon:

MATCH (b:actor {fullname:”Kevin Bacon”})-[*4]-(a:actor)

RETURN distinct a.fullname

Looking for the shortestpath from Bacon to other actors (“0..” is added to include Kevin Bacon in the list):

MATCH p=shortestpath(

((b:actor {fullname:”Kevin Bacon”})-[*0..]-(a:actor))

)

RETURN a.fullname, length(p)

Looking for the shortestpath from Bacon to other actors and outputting the Bacon Number (“0..” is added to include Kevin Bacon in the list):

MATCH p=shortestpath(

((b:actor {fullname:”Kevin Bacon”})-[*0..]-(a:actor))

)

RETURN a.fullname, 1+length(p)/2

Creative Commons License
Data Analysis: Take it to the Max by TU Delft OpenCourseWare is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Based on a work at https://ocw.tudelft.nl/courses/data-analysis-take-it-to-the-max/.
Back to top
[sg_popup id=6]