Java in neo4j interface

Hello all,
I am a new user in the neo4j community. I have been wondering is there a way i could use java in the neo4j interface? I know i can use neo4j-driver and use neo4j in the java, but i would ideally want it the other way around.

I am using a remote graph database and i am applying graph algorithms. I want to modify the java graph algorithms source code, use the my updated code in neo4j browser or neuler.
Any help will be much appreciated

Thanks in advance, Andreas.

Hi Andreas,
welcome to Neo4j!

To your question: Yes, this is possible. You can write your own user-defined procedures and functions or modify the existing algorithms. Let me give you some links on how to do that:

If you have any further questions, let me know :slight_smile:
Regards,
Elena

For GDS, and algorithms specifically, we actually offer a simplified API for implementing algorithms yourself: Pregel API - Neo4j Graph Data Science

If you want to look at the GDS source code, check out GitHub - neo4j/graph-data-science: Source code for the Neo4j Graph Data Science library of graph algorithms.

So i am using the driver. For now i have managed to connect with database and apply very simple queries and obtain results in the java interface in type String. Is there a way i can see the results in visuals as well? Additionally i know where i can find the GDS algorithms, however is there a way i can run modified versions of them in neuler? My goal is to modify the Louvain algorithm and run my personal modified one and visualise the results.

Is Pregel a way i write java scripts and then use it as a plugin? What i want to do is to modify an already existing algorithm (Louvain Modularity) and then run the modified algorithm in neuler and obtain and also visualise the results. Can i have some general guidance how to do this? I would prefer is their a video tutorial offered somewhere.

Hi Andreas,

using the driver is not getting you where you want to go, I guess. What you are doing now, is probably something like:

try( Session session = driver.session()) {                 
 String name = session.run("MATCH (a:Node {id: 4}) RETURN a.name AS name").single().get( "name").asString();
}

From here you are not able to deploy any user defined functions.
What you should do:

  • clone the github repository of GDS
  • adapt the Louvain algorithm to what you need
  • deploy the adapted algorithm to the plugins folder of your Neo4j database.

I am not sure if you are able to deploy it in NEuler...

Hey elena,

I am working with a remote database. Is this still a way to do it?

So if i understood correctly my goal can be done by applying the following steps:

  1. Clone the GDS repo
  2. Apply the modifications i want on the GDS algorithms
  3. replace the plugin folder of GDS with my modified one
  4. the procedures in neo4j browser when i call the louvain function, it will use my modified louvain code rather than the original GDS plugin one?

If i understood the process correct and this is feasible. Then for me that i am working with the a remote database and not with one on my local system, is this still a solution and do where do i need to replace the GDS code?

Hi,
about the remote database: Do you have access to the plugins folder of that remote database? If so, everything should work fine. If not, I don't know.

Concerning the steps:
Step 3 would be "replace the gds plugin in the 'plugins' folder of your database with your modified gds plugin" (this is replace the .jar file)
The rest is correct. Once you have replaced the plugin your modified procedure will be called when you call the louvain function.

In Neo4j Desktop you can open the plugins folder of your database like that:
Unbenannt

1 Like

We have some video walk throughs of writing your own algorithms with Pregel: 46. Write Your Own Algorithms Using the Pregel API - YouTube , as well as examples in our docs.

However, if your focus is on Louvain, it's easier to clone our library and modify the java code, then compile your own version of the plug in. The code sits here.

If you overwrite the existing Louvain procedure and don't change the signature (inputs or outputs), so you just have a different version of the GDS plug in, it should work with NEuler, but we don't guarantee that.

As @elena_kohlwey said above, though, you will need access to the plug ins folder for your instance to be able to deploy your modified version of GDS.

1 Like