Neo4j_tutorial

For beginner

1.Install java jdk 15 because 16 is not capatable with neo4j desktop 4.33

https://mac.filehorse.com/download-java-development-kit/16362/

2.how to change jdk version in mac os

3.find /Library/Java/JavaVirtualMachines

image

4.open terminal

input java -version

image

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-15.0.1.jdk/Contents/Home/

export PATH=$JAVA_HOME/bin:$PATH

image

1.Download neo4j desktop.

WITH "https://github.com/neo4j-graph-analytics/book/raw/master/data/" AS base

WITH base + "transport-nodes.csv" AS uri

LOAD CSV WITH HEADERS FROM uri AS row

MERGE (place:Place {id:row.id})

SET place.latitude = toFloat(row.latitude),

place.longitude = toFloat(row.longitude),

place.population = toInteger(row.population);

WITH "https://github.com/neo4j-graph-analytics/book/raw/master/data/" AS base

WITH base + "transport-relationships.csv" AS uri

LOAD CSV WITH HEADERS FROM uri AS row

MATCH (origin:Place {id: row.src})

MATCH (destination:Place {id: row.dst})

MERGE (origin)-[:EROAD {distance: toInteger(row.cost)}]->(destination);

or

WITH "https://gitee.com/lfshao/book/raw/master/data/" AS base

WITH base + "transport-relationships.csv" AS uri

LOAD CSV WITH HEADERS FROM uri AS row

MATCH (origin:Place {id: row.src})

MATCH (destination:Place {id: row.dst})

MERGE (origin)-[:EROAD {distance: toInteger(row.cost)}]->(destination);

image

MATCH (source:Place {id: "Amsterdam"}), (destination:Place {id: "London"}) CALL gds.alpha.shortestPath.stream({ startNode: source, endNode: destination, nodeProjection: "", relationshipProjection: { all: { type: "", orientation: "UNDIRECTED" } } }) YIELD nodeId, cost RETURN gds.util.asNode(nodeId).id AS place, cost;

5.Random algorithm

MATCH (source:Place {id: "London"}) CALL gds.alpha.randomWalk.stream({ start: id(source), nodeProjection: "", relationshipProjection: { all: { type: "", properties: "distance", orientation: "UNDIRECTED" } }, steps: 5, walks: 1 }) YIELD nodeIds UNWIND gds.util.asNodes(nodeIds) as place RETURN place.id AS place