简体   繁体   English

Neo4j和算法

[英]Neo4j and algorithms

I am using Neo4j for the school project. 我正在将Neo4j用于学校项目。

My assingment contains writing algorithms for graph databases(Neo4j) and executing them in the server mode. 我的总结包括为图形数据库(Neo4j)编写算法并在服务器模式下执行它们。 As far as I know in Neo4j, you can only do that in Cypher, which is not good enough for writing more complex algorithms. 据我在Neo4j中了解到的,您只能在Cypher中做到这一点,这不足以编写更复杂的算法。

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 在Neo4j的世界中,我们称之为非托管扩展

If you are looking for a framework which will help you to write that extension I suggest to you look on GraphAware Neo4j Framework . 如果您正在寻找可以帮助您编写该扩展的框架,我建议您使用GraphAware Neo4j Framework

So, you want to make some algorithms ? 那么,您想制定一些算法吗? Neo4j has tools for you! Neo4j为您提供工具!

Embedded mode 嵌入式模式

Embedded mode is straightforward: 嵌入式模式非常简单:

1) Add neo4j embedded to your project. 1)将内嵌的neo4j添加到您的项目中。
2) Create your GraphDatabaseService 2) 创建您的GraphDatabaseService
3) Start coding. 3)开始编码。

API layers API层

Neo4j provides 3 API layers. Neo4j提供3个API层。

Core API 核心API
Most low-level one. 最底层的。 It contains methods such as GraphDatabaseService::createNode() , GraphDatabaseService::findNode() , Node::createRelationshipTo() and other. 它包含诸如GraphDatabaseService::createNode()GraphDatabaseService::findNode()Node::createRelationshipTo()等方法。 Use this one to be really bare-metal. 用这个真的是裸机。

Traversal API 遍历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() . 入口点GraphDatabaseService::traversalDescription()

Cypher API 密码API
This is true power of Neo4j. 这是Neo4j的真正力量。 Cypher can be used to get answers for quite complex graph-related questions. Cypher可用于获取与图形有关的非常复杂的问题的答案。
Entry point - GraphDatabaseService::execute() 入口点GraphDatabaseService::execute()

Other stuff 其他的东西
Probably you should look into graph alghoritms that comes with Neo4j. 可能您应该研究Neo4j附带的图形算法 Neo4j server REST API also has some graph alghoritms available. Neo4j服务器REST API还提供了一些图形算法。 And here you can find list with Neo4j resources (maybe there is something interesting for you). 在这里,您可以找到带有Neo4j资源的列表(也许您会发现一些有趣的东西)。

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. 为Neo4j服务器编写扩展时,您还使用GraphDatabaseService与数据库进行交互。

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). 注意:规则是-如果您使用可与GraphDatabaseService一起使用的服务创建了库,则可以在任何地方(嵌入式模式,插件,扩展等)重用此库。

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. 此选项可轻松创建REST端点,该端点可以根据请求接受某些数据,并可以在响应时返回图形数据。

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

GraphAware framework can give you some nice instruments to develop Neo4j extension. GraphAware框架可以为您提供一些不错的工具来开发Neo4j扩展。 You should probably give it a try. 您应该尝试一下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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