简体   繁体   中英

Neo4j and algorithms

I am using Neo4j for the school project.

My assingment contains writing algorithms for graph databases(Neo4j) and executing them in the server mode. As far as I know in Neo4j, you can only do that in Cypher, which is not good enough for writing more complex algorithms.

Are there any other possibilities, plug-ins or frameworks, that provide more complex writing of algorithm and running them in the server mode?

Yes, there is a way. In world of Neo4j we call it Unmanaged Extension

If you are looking for a framework which will help you to write that extension I suggest to you look on GraphAware Neo4j Framework .

So, you want to make some algorithms ? Neo4j has tools for you!

Embedded mode

Embedded mode is straightforward:

1) Add neo4j embedded to your project.
2) Create your GraphDatabaseService
3) Start coding.

API layers

Neo4j provides 3 API layers.

Core API
Most low-level one. It contains methods such as GraphDatabaseService::createNode() , GraphDatabaseService::findNode() , Node::createRelationshipTo() and other. Use this one to be really bare-metal.

Traversal API
This one is nice framework for doing any kind of traversal. Probably this is what you are looking for to implement alghoritms.
Entry point - GraphDatabaseService::traversalDescription() .

Cypher API
This is true power of Neo4j. Cypher can be used to get answers for quite complex graph-related questions.
Entry point - GraphDatabaseService::execute()

Other stuff
Probably you should look into graph alghoritms that comes with Neo4j. Neo4j server REST API also has some graph alghoritms available. And here you can find list with Neo4j resources (maybe there is something interesting for you).

Server

But it's not fun. Whe wanna to extend server, so everyone can get access to our fancy alghoritms?

When writing extensions for Neo4j server you are also using GraphDatabaseService to interact with database.

Note: Rule there is - if you created library with service that works with GraphDatabaseService , then you can reuse this anywhere (embedded mode, plugins, extensions and etc).

Plugin

You can create server plugin . Probably this is something you are looking for to implement algoritms. This options to easily create REST endpoint that accepts some data on request, and can return graph data on response.

Server plugin example developed by me .

Unmanaged extension

Other option - unmanaged extension . This one gives you true power. But remember - with great power, comes responsibility.
You will be responsible to handle all input and output.

Unmanaged extension example developed by me .

GraphAware

GraphAware framework can give you some nice instruments to develop Neo4j extension. You should probably give it a try.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM