neo4j / graph-data-science

Source code for the Neo4j Graph Data Science library of graph algorithms.
https://neo4j.com/docs/graph-data-science/current/
Other
639 stars 161 forks source link

Set relationship property in a specific range in Neo4j #125

Closed samasalam closed 1 year ago

samasalam commented 3 years ago

I follow this link to use a graph generator to create a graph scaling to +10000 nodes and to execute the shortest path algorithm between two nodes.

How can I set the relationship property for all the nodes to be in a specific range?

This link provides more options, but I don't know how to use it. Any help?

Update: I do as follow:

CALL gds.beta.graph.generate('test', 10, 3, 
{
  relationshipDistribution: 'random',
  relationshipProperty: {
                        name:'myProperty',
                        type: 'RANDOM',
                        min : 40.0,
                        max : 80.0
                        }
})
YIELD name, nodes, relationships, generateMillis, relationshipSeed, averageDegree, relationshipDistribution, relationshipProperty

The following error occurs:

Neo.ClientError.Procedure.ProcedureCallFailed
Failed to invoke procedure `gds.beta.graph.generate`: Caused by: java.lang.NullPointerExcep
FlorentinD commented 3 years ago

Hey @samasalam , thank you for reporting the bug. Your provided query is correct.

Unfortunately, you found a bug in our code, which will be fixed in the next days. I will follow up, when the bug is pushed to the open repository.

As a side note, the APOC and GDS plugin are completely separate. A graph generated by APOC still needs to be imported into the GDS graph-catalog (see: https://neo4j.com/docs/graph-data-science/1.7-preview/graph-create/).

samasalam commented 3 years ago

Hey @samasalam , thank you for reporting the bug. Your provided query is correct.

Unfortunately, you found a bug in our code, which will be fixed in the next days. I will follow up, when the bug is pushed to the open repository.

As a side note, the APOC and GDS plugin are completely separate. A graph generated by APOC still needs to be imported into the GDS graph-catalog (see: https://neo4j.com/docs/graph-data-science/1.7-preview/graph-create/).

Hello @FlorentinD Thanks for your effort. Is their any hope that the bug will be fixed? and when? since I need this query and waiting it desperately :)

FlorentinD commented 3 years ago

Sorry I forgot to notify you. We fixed the bug and your query should work if you build the project locally. @samasalam

samasalam commented 3 years ago

Hello @FlorentinD How can I install the 1.7 Graph Data Science release ? I didn't find it. I follow this link: https://neo4j.com/graph-data-science-software/ The latest release is 1.6.4. I install it, but the same error occur: Failed to invoke procedure `gds.beta.graph.generate`: Caused by: java.lang.NullPointerException

FlorentinD commented 3 years ago

Hey @samasalam, we are currently working on 1.7. We do publish individual modules to maven-central as part of our pre-releases (also called alpha-release).

However, the easiest way to get a single jar is to build the project locally. To build the project, follow our instructions in the README (https://github.com/neo4j/graph-data-science#building-the-library).

FlorentinD commented 3 years ago

1.6.4 was released before the fix.

samasalam commented 3 years ago

Hey @samasalam, we are currently working on 1.7. We do publish individual modules to maven-central as part of our pre-releases (also called alpha-release).

However, the easiest way to get a single jar is to build the project locally. To build the project, follow our instructions in the README (https://github.com/neo4j/graph-data-science#building-the-library).

Sorry I didn't understand how to build the project locally. can you help me in this?

FlorentinD commented 3 years ago

Can you tell me at which point you are struggling? First you need to clone the repository. Then follow the steps described in the README of this project.

samasalam commented 3 years ago

Can you tell me at which point you are struggling? First you need to clone the repository. Then follow the steps described in the README of this project. @FlorentinD I did not understand the steps. I clone the whole repository. Then what shall I do? I don't have enough experience in this. Please can anybody help me in understanding the section building-the-library ?
I'm in great need to this procedure (Graph Generation). Please I need help.

FlorentinD commented 3 years ago

Hey @samasalam, the more concrete steps are: (1) Clone this repository via git clone https://github.com/neo4j/graph-data-science.git (2) Run ./gradlew packaging:shadowJar (you need to be inside the project directory) (3) Locate the generated jar under packaging/build/libs/neo4j-graph-data-science-VERSION.jar (4) Copy the jar into the plugins folder of your neo4j db (if you use Neo4j Browser go via Open folder > Plugins) (*5) Delete the old gds jar if already installed (probably gdsLibrary-1.6.4.jar)

On running the db you can verify the version via RETURN gds.version()

Hope this helps

samasalam commented 3 years ago

@FlorentinD Sorry for disturbing you. How can I get to the project directory? I know my questions are naive. sorry.

FlorentinD commented 3 years ago

No worries :)

After cloning the github repo (step 1) you should see a new directory called graph-data-science. The directory should contain the same folders as you can see on our github page. Move to this directory and execute step 2 inside there.

samasalam commented 3 years ago

Hello @FlorentinD Thanks a lot for your efforts. I did exactly what you wrote in the last comment. But the following error occur (note: java version is jre1.8.0_301):

c:\graph-data-science>gradlew packaging:shadowJar Could not unzip C:\Users\Sama\.gradle\wrapper\dists\gradle-7.0.2-all\7era6s5ay7zsbhuvl0oc9g94s\gradle-7.0.2-all.zip to C:\Users\Sama\.gradle\wrapper\dists\gradle-7.0.2-all\7era6s5ay7zsbhuvl0oc9g94s. Reason: error in opening zip file Exception in thread "main" java.util.zip.ZipException: error in opening zip file at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.<init>(Unknown Source) at java.util.zip.ZipFile.<init>(Unknown Source) at java.util.zip.ZipFile.<init>(Unknown Source) at org.gradle.wrapper.Install.unzip(Install.java:239) at org.gradle.wrapper.Install.access$900(Install.java:27) at org.gradle.wrapper.Install$1.call(Install.java:81) at org.gradle.wrapper.Install$1.call(Install.java:48) at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69) at org.gradle.wrapper.Install.createDist(Install.java:48) at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107) at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:63)

samasalam commented 3 years ago

Mornings @FlorentinD I tried my best & followed the steps you wrote but the error (listed in the above comment) occur. What shall I do to overcome this? Please any help.

FlorentinD commented 3 years ago

I just tried the steps on a Windows machine and could not reproduce the error. Your problem occurs when trying to install gradle.

Are you using a vpn? Maybe try without an vpn.

You can also try to remove the .gradle directory specified in the error message and try again.

It seems to be a problem with your environment, so trying on another computer can also be a workaround.

samasalam commented 3 years ago

Hello @FlorentinD I followed the steps exactly as you wrote. The following error occur:

c:\graph-data-science>gradlew packaging:shadowJar
Starting a Gradle Daemon, 2 incompatible and 1 stopped Daemons could not be reused, use --status for details
> Task :annotations:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':annotations:compileJava'.
> invalid source release: 11

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 16s
1 actionable task: 1 executed
FlorentinD commented 3 years ago

Great you could make progress. Out of curiosity, what fixed your zip problem?

Your current problem is due to your installed java version. This project needs at least Java 11, and you have only 8 installed. Updating the version should fix your issue (f.i. from https://www.oracle.com/java/technologies/javase-jdk11-downloads.html).

samasalam commented 3 years ago

Great you could make progress. Out of curiosity, what fixed your zip problem?

Your current problem is due to your installed java version. This project needs at least Java 11, and you have only 8 installed. Updating the version should fix your issue (f.i. from https://www.oracle.com/java/technologies/javase-jdk11-downloads.html).

I download it and the same error occur. here what I have relating to Java

java
FlorentinD commented 3 years ago

After downloading it, you also have to edit the JAVA_HOME and PATH variable. Otherwise the old one is still picked. To be sure, use 'java --version' in the command line.

samasalam commented 3 years ago

Finally it works :) Many thanks @FlorentinD

samasalam commented 2 years ago

Hello @FlorentinD I hope you are doing well. I'm trying to do the exact steps and this error occurs. What shall I do?

c:\graph-data-science>gradlew packaging:shadowJar

FAILURE: Build failed with an exception.

* What went wrong:
Project 'packaging' not found in root project 'open-gds'.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
FlorentinD commented 2 years ago

Hey @samasalam , Great to see you are still working with GDS.

Since last year, we worked further on the product and are at version 2.2. As a side-effect, we also updated the instructions on how to build the library (https://github.com/neo4j/graph-data-science#building-the-library). In your case, instead of packaging you should try open-packaging, but best you look at the instructions for more details.

In general, we suggest to use our public artifacts found at https://github.com/neo4j/graph-data-science/releases/tag/2.2.2. Why are you interested in building the library locally this time? :)

samasalam commented 2 years ago

Hello @FlorentinD. Great to hear from you. Hope you are doing well.

FlorentinD commented 2 years ago

Thanks for describing your use-case. Its always great to understand what people actually try to achieve :)

First, I would suggest to use the published jar at https://github.com/neo4j/graph-data-science/releases/tag/2.2.2 then you dont need to build the jar yourself. This is possible without using Aura and actually similar how Neo4j Desktop retrieves our jar. Last year, I suggested to build the library locally, as we didn't release the bug-fix yet.

For load balancing you want evenly sized communities, which is indeed can be different then what Louvain will produce. As you also referred to in your other issue, I would also think of trying out KMeans

samasalam commented 2 years ago

Hello @FlorentinD I build it and it works :) Well, I downloaded Graph DBMS 4.4.9. Then I put the jar that I built according to your previous post (trying open-packaging). Now it is working very well. Many thanks For load balancing, if you like, take a look at this Suggestion. Many thanks for your great help.

FlorentinD commented 2 years ago

Glad to hear, I will have a look at your link!