Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,49 @@ Be sure to replace `path/to/local/neo4j` and `password` with your settings.
cat ./cypher/Get_Graph_Data_Science_Library_Version.cypher | path/to/local/neo4j/bin/cypher-shell -u neo4j -p password --format plain
```

Query parameter can be added with the option `--param`. Here is an example:

```shell
cat ./cypher/Get_Graph_Data_Science_Library_Version.cypher | path/to/local/neo4j/bin/cypher-shell -u neo4j -p password --format plain --param {a: 1}
```

For a full list of options use the help function:

```shell
path/to/local/neo4j/bin/cypher-shell --help
```

### HTTP API

Use [executeQuery.sh](./scripts/executeQuery.sh) to execute a Cypher query from the file given as an argument.
It uses `curl` and `jq` to access the HTTP API of Neo4j.
It uses `curl` and `jq` to access the [HTTP API of Neo4j](https://neo4j.com/docs/http-api/current/query).
Here is an example:

```shell
./scripts/executeQuery.sh ./cypher/Get_Graph_Data_Science_Library_Version.cypher
```

Query parameters can be added as arguments after the file name. Here is an example:

```shell
./scripts/executeQuery.sh ./cypher/Get_Graph_Data_Science_Library_Version.cypher a=1
```

### executeQueryFunctions

The script [executeQueryFunctions.sh](./scripts/executeQueryFunctions.sh) contains functions to simplify the
call of [executeQuery.sh](./scripts/executeQuery.sh) for different purposes. For example, `execute_cypher_summarized`
prints out the results on the console in a summarized manner and `execute_cypher_expect_results` fails when there are no results.

The script also provides an API abstraction that defaults to [HTTP](#http-api), but can easily be switched to [cypher-shell](#cypher-shell).

Query parameters can be added as arguments after the file name. Here is an example:

```shell
source "${SCRIPTS_DIR}/executeQueryFunctions.sh"
execute_cypher ./cypher/Get_Graph_Data_Science_Library_Version.cypher a=1
```

## Stop Neo4j

Use [stopNeo4j.sh](./scripts/stopNeo4j.sh) to stop the locally running Neo4j Graph Database. It does nothing if the database is already stopped. It runs the script with a temporary `NEO4J_HOME` environment variable to not interfere with a possibly globally installed Neo4j installation.
Expand Down

This file was deleted.

8 changes: 0 additions & 8 deletions cypher/Centrality/Centrality_1_Create_Projection.cypher

This file was deleted.

22 changes: 22 additions & 0 deletions cypher/Centrality/Centrality_1a_List_TopPercentile.cypher
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// List the top centrality nodes with a 99.5 percentile or higher

MATCH (member)
WHERE $dependencies_projection_node IN LABELS(member)
AND member[$dependencies_projection_write_property] IS NOT NULL
WITH count(DISTINCT member) AS memberCount
,percentileDisc(member[$dependencies_projection_write_property], 0.995) AS centralityPercentile995
,collect(DISTINCT member) AS members
UNWIND members AS member
WITH memberCount
,centralityPercentile995
,member
ORDER BY member[$dependencies_projection_write_property] DESCENDING
WHERE member[$dependencies_projection_write_property] >= centralityPercentile995
WITH memberCount
,centralityPercentile995
,max(member[$dependencies_projection_write_property]) AS maxCentrality
,collect(DISTINCT member) AS topMembers
RETURN memberCount
,maxCentrality
,centralityPercentile995
,topMembers

This file was deleted.

12 changes: 12 additions & 0 deletions cypher/Centrality/Centrality_1b_List_TopPercent.cypher
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// List the top 2% nodes with the highest centrality score.

MATCH (member)
WHERE $dependencies_projection_node IN labels(member)
AND member[$dependencies_projection_write_property] IS NOT NULL
WITH toInteger(toFloat(count(DISTINCT member)) * 0.02) AS memberCount2Percent
,collect(DISTINCT member) AS members
UNWIND members AS member
WITH memberCount2Percent, member
ORDER BY member[$dependencies_projection_write_property] DESCENDING
WITH memberCount2Percent, collect(DISTINCT member)[0..memberCount2Percent] AS topMembers
RETURN memberCount2Percent, topMembers
11 changes: 11 additions & 0 deletions cypher/Centrality/Centrality_1c_Label_Delete.cypher
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Centrality Label Delete

CALL db.labels() YIELD label
WHERE label = 'Top' + apoc.text.capitalize($dependencies_projection_write_property)
WITH collect(label) AS selectedLabels
MATCH (member)
WHERE $dependencies_projection_node IN LABELS(member)
AND member[$dependencies_projection_write_property] IS NOT NULL
WITH collect(member) AS members, selectedLabels
CALL apoc.create.removeLabels(members, selectedLabels) YIELD node
RETURN COUNT(node) AS nodesCount;
16 changes: 16 additions & 0 deletions cypher/Centrality/Centrality_1d_Label_Add.cypher
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Centrality Add label to the top 2% nodes with the highest centrality score

MATCH (member)
WHERE $dependencies_projection_node IN labels(member)
AND member[$dependencies_projection_write_property] IS NOT NULL
WITH toInteger(toFloat(count(DISTINCT member)) * 0.02) AS memberCount2Percent
,collect(DISTINCT member) AS members
UNWIND members AS member
WITH memberCount2Percent, member
ORDER BY member[$dependencies_projection_write_property] DESCENDING
WITH memberCount2Percent
,collect(DISTINCT member)[0..memberCount2Percent] AS topMembers
,'Top' + apoc.text.capitalize($dependencies_projection_write_property) AS labelName
UNWIND topMembers AS topMember
CALL apoc.create.addLabels(topMember, [labelName]) YIELD node
RETURN count(node) AS nodesCount
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
//Centrality 2a Page Rank Estimate Memory

CALL gds.pageRank.write.estimate('package-centrality-without-empty', {
writeProperty: 'pageRank'
CALL gds.pageRank.write.estimate(
$dependencies_projection + '-without-empty', {
writeProperty: $dependencies_projection_write_property
,maxIterations: 50
,dampingFactor: 0.85
,tolerance: 0.00000001
,relationshipWeightProperty: 'weight25PercentInterfaces'
,relationshipWeightProperty: $dependencies_projection_weight_property
,scaler: "L1Norm"
})
YIELD nodeCount, relationshipCount, bytesMin, bytesMax, heapPercentageMin, heapPercentageMax, treeView
Expand Down
5 changes: 3 additions & 2 deletions cypher/Centrality/Centrality_2b_Page_Rank_Statistics.cypher
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
//Centrality 2b Page Rank Statistics

CALL gds.pageRank.stats('package-centrality-without-empty', {
CALL gds.pageRank.stats(
$dependencies_projection + '-without-empty', {
maxIterations: 50
,dampingFactor: 0.85
,tolerance: 0.00000001
,relationshipWeightProperty: 'weight25PercentInterfaces'
,relationshipWeightProperty: $dependencies_projection_weight_property
,scaler: "L1Norm"
})
YIELD ranIterations
Expand Down
16 changes: 8 additions & 8 deletions cypher/Centrality/Centrality_3c_Page_Rank_Stream.cypher
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
//Centrality 3c Page Rank Stream

CALL gds.pageRank.stream('package-centrality-without-empty', {
CALL gds.pageRank.stream(
$dependencies_projection + '-without-empty', {
maxIterations: 50
,dampingFactor: 0.85
,tolerance: 0.00000001
,relationshipWeightProperty: 'weight25PercentInterfaces'
,relationshipWeightProperty: $dependencies_projection_weight_property
,scaler: "L2Norm"
})
YIELD nodeId, score
WITH gds.util.asNode(nodeId) AS package, score
RETURN package.fqn AS fullQualifiedPackageName
,package.name AS packageName
WITH gds.util.asNode(nodeId) AS member, score
RETURN coalesce(member.fqn, member.fileName, member.name) AS memberName
,score
,package.incomingDependencies AS incomingDependencies
,package.outgoingDependencies AS outgoingDependencies
ORDER BY score DESC, packageName ASC
,member.incomingDependencies AS incomingDependencies
,member.outgoingDependencies AS outgoingDependencies
ORDER BY score DESC, memberName ASC
7 changes: 4 additions & 3 deletions cypher/Centrality/Centrality_3d_Page_Rank_Write.cypher
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
//Centrality 3d Page Rank Write

CALL gds.pageRank.write('package-centrality-without-empty', {
CALL gds.pageRank.write(
$dependencies_projection + '-without-empty', {
maxIterations: 50
,dampingFactor: 0.85
,tolerance: 0.00000001
,relationshipWeightProperty: 'weight25PercentInterfaces'
,relationshipWeightProperty: $dependencies_projection_weight_property
,scaler: "L2Norm"
,writeProperty: "pageRank25PercentInterfaces"
,writeProperty: $dependencies_projection_write_property
})
YIELD nodePropertiesWritten
,ranIterations
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
//Centrality 4a Article Rank Estimate Memory
CALL gds.articleRank.write.estimate('package-centrality-without-empty', {
writeProperty: 'articleRank'
CALL gds.articleRank.write.estimate(
$dependencies_projection + '-without-empty', {
writeProperty: $dependencies_projection_write_property
,maxIterations: 30
,dampingFactor: 0.85
,tolerance: 0.00000001
,relationshipWeightProperty: 'weight25PercentInterfaces'
,relationshipWeightProperty: $dependencies_projection_weight_property
,scaler: "L1Norm"
})
YIELD nodeCount, relationshipCount, bytesMin, bytesMax, heapPercentageMin, heapPercentageMax, treeView
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
//Centrality 4b Article Rank Statistics
CALL gds.articleRank.stats('package-centrality-without-empty', {
CALL gds.articleRank.stats(
$dependencies_projection + '-without-empty', {
maxIterations: 30
,dampingFactor: 0.85
,tolerance: 0.00000001
,relationshipWeightProperty: 'weight25PercentInterfaces'
,relationshipWeightProperty: $dependencies_projection_weight_property
,scaler: "L1Norm"
})
YIELD ranIterations
Expand Down
16 changes: 8 additions & 8 deletions cypher/Centrality/Centrality_4c_Article_Rank_Stream.cypher
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
//Centrality 4c Article Rank Stream

CALL gds.articleRank.stream('package-centrality-without-empty', {
CALL gds.articleRank.stream(
$dependencies_projection + '-without-empty', {
maxIterations: 30
,dampingFactor: 0.85
,tolerance: 0.00000001
,relationshipWeightProperty: 'weight25PercentInterfaces'
,relationshipWeightProperty: $dependencies_projection_weight_property
,scaler: "L2Norm"
})
YIELD nodeId, score
WITH gds.util.asNode(nodeId) AS package, score
RETURN package.fqn AS fullQualifiedPackageName
,package.name AS packageName
WITH gds.util.asNode(nodeId) AS member, score
RETURN coalesce(member.fqn, member.fileName, member.name) AS memberName
,score
,package.incomingDependencies AS incomingDependencies
,package.outgoingDependencies AS outgoingDependencies
ORDER BY score DESC, packageName ASC
,member.incomingDependencies AS incomingDependencies
,member.outgoingDependencies AS outgoingDependencies
ORDER BY score DESC, memberName ASC
7 changes: 4 additions & 3 deletions cypher/Centrality/Centrality_4d_Article_Rank_Write.cypher
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
//Centrality 4d Article Rank Write

CALL gds.articleRank.write('package-centrality-without-empty', {
CALL gds.articleRank.write(
$dependencies_projection + '-without-empty', {
maxIterations: 50
,dampingFactor: 0.85
,tolerance: 0.00000001
,relationshipWeightProperty: 'weight25PercentInterfaces'
,relationshipWeightProperty: $dependencies_projection_weight_property
,scaler: "L2Norm"
,writeProperty: "articleRank25PercentInterfaces"
,writeProperty: $dependencies_projection_write_property
})
YIELD nodePropertiesWritten
,ranIterations
Expand Down
6 changes: 4 additions & 2 deletions cypher/Centrality/Centrality_5a_Betweeness_Estimate.cypher
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//Centrality 5a Betweeness Estimate

CALL gds.betweenness.write.estimate('package-centrality-without-empty', {
writeProperty: 'betweenness'
CALL gds.betweenness.write.estimate(
$dependencies_projection + '-without-empty', {
relationshipWeightProperty: $dependencies_projection_weight_property
,writeProperty: $dependencies_projection_write_property
})
YIELD nodeCount, relationshipCount, bytesMin, bytesMax, heapPercentageMin, heapPercentageMax, treeView
RETURN nodeCount, relationshipCount, bytesMin, bytesMax, heapPercentageMin, heapPercentageMax, treeView
5 changes: 3 additions & 2 deletions cypher/Centrality/Centrality_5b_Betweeness_Statistics.cypher
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//Centrality 5b Betweeness Statistics

CALL gds.betweenness.stats('package-centrality-without-empty', {
relationshipWeightProperty: 'weight25PercentInterfaces'
CALL gds.betweenness.stats(
$dependencies_projection + '-without-empty', {
relationshipWeightProperty: $dependencies_projection_weight_property
})
YIELD preProcessingMillis
,computeMillis
Expand Down
16 changes: 8 additions & 8 deletions cypher/Centrality/Centrality_5c_Betweeness_Stream.cypher
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Centrality 5c Betweeness Stream

CALL gds.betweenness.stream('package-centrality-without-empty', {
relationshipWeightProperty: 'weight25PercentInterfaces'
CALL gds.betweenness.stream(
$dependencies_projection + '-without-empty', {
relationshipWeightProperty: $dependencies_projection_weight_property
})
YIELD nodeId, score
WITH gds.util.asNode(nodeId) AS package, score
RETURN package.fqn AS fullQualifiedPackageName
,package.name AS packageName
WITH gds.util.asNode(nodeId) AS member, score
RETURN coalesce(member.fqn, member.fileName, member.name) AS memberName
,score
,package.incomingDependencies AS incomingDependencies
,package.outgoingDependencies AS outgoingDependencies
ORDER BY score DESC, packageName ASC
,member.incomingDependencies AS incomingDependencies
,member.outgoingDependencies AS outgoingDependencies
ORDER BY score DESC, memberName ASC
7 changes: 4 additions & 3 deletions cypher/Centrality/Centrality_5d_Betweeness_Write.cypher
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Centrality 5d Betweeness Write

CALL gds.betweenness.write('package-centrality-without-empty', {
relationshipWeightProperty: 'weight25PercentInterfaces',
writeProperty: 'betweenness25PercentInterfaces'
CALL gds.betweenness.write(
$dependencies_projection + '-without-empty', {
relationshipWeightProperty: $dependencies_projection_weight_property
,writeProperty: $dependencies_projection_write_property
})
YIELD nodePropertiesWritten
,preProcessingMillis
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Centrality 6c Cost-effective Lazy Forward (CELF) Estimate

CALL gds.beta.influenceMaximization.celf.write.estimate(
$dependencies_projection + '-without-empty', {
seedSetSize: 5
,writeProperty: $dependencies_projection_write_property
})
YIELD nodeCount, relationshipCount, bytesMin, bytesMax, heapPercentageMin, heapPercentageMax, treeView
RETURN nodeCount, relationshipCount, bytesMin, bytesMax, heapPercentageMin, heapPercentageMax, treeView
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Centrality 6b Cost-effective Lazy Forward (CELF) Estimate

CALL gds.beta.influenceMaximization.celf.stats(
$dependencies_projection + '-without-empty', {
seedSetSize: 5
})
YIELD computeMillis
,totalSpread
,nodeCount
RETURN computeMillis
,totalSpread
,nodeCount
Loading