如何切换图形(在 Neo4j 上)?

发布于 2024-12-06 11:10:24 字数 695 浏览 0 评论 0原文

使用后如何返回 Neo4J 图

g = new TinkerGraph() 

我想它类似于

g.loadGraphML(...)

编辑:

您的答案帮助我更好地理解 loadGraphML() 的工作原理,但它没有解决我的问题。

我要重新表述我的问题。我使用 Neo4j 和 Gremlin,当我第一次启动服务器时,我在 Gremlin 控制台下看到以下几行。

==> Available variables:
==>   g = neo4jgraph[EmbeddedGraphDatabase [/home/user/software/neo4j-community-1.5.M01/data/graph.db]]

然后我输入

gremlin> g = TinkerGraphFactory.createTinkerGraph()
==> tinkergraph[vertices:6 edges:6]

But how I can back to "g = neo4jgraph[EmbeddedGraphDatabase [/home/user/software/neo4j-community-1.5.M01/data/graph.db]]"

How do I come back on the Neo4J graph after using

g = new TinkerGraph() 

I guess it's something like

g.loadGraphML(...)

EDIT:

Your answer helped me to better understand how loadGraphML() works, but it didn't solve my problem.

I'm going to rephrase my question. I use Neo4j and Gremlin, and when I first start the server, I get the following lines under Gremlin console.

==> Available variables:
==>   g = neo4jgraph[EmbeddedGraphDatabase [/home/user/software/neo4j-community-1.5.M01/data/graph.db]]

Then I type

gremlin> g = TinkerGraphFactory.createTinkerGraph()
==> tinkergraph[vertices:6 edges:6]

But how can I come back to "g = neo4jgraph[EmbeddedGraphDatabase [/home/user/software/neo4j-community-1.5.M01/data/graph.db]]"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

粉红×色少女 2024-12-13 11:10:25

我不完全理解你的问题,但我相信你的意思是你已经用 TinkerGraph 做了一些工作,并且你想将这些数据导入 Neo4jGraph 吗?此外,鉴于您正在执行 g.loadGraphML(...),我假设您正在谈论从 Gremlin。如果没有,请使用相应的 GraphMLReader/Writer 类由蓝图提供。

gremlin> g
==>tinkergraph[vertices:6 edges:6]
gremlin> g.V
==>v[3]
==>v[2]
==>v[1]
==>v[6]
==>v[5]
==>v[4]
gremlin> h = new Neo4jGraph('/tmp/test')
==>neo4jgraph[EmbeddedGraphDatabase [/tmp/test]]
gremlin> g.saveGraphML('test.xml') 
==>null
gremlin> h.loadGraphML('test.xml')
gremlin> h.V
==>v[1]
==>v[2]
==>v[3]
==>v[4]
==>v[5]
==>v[6]

简而言之,您可以将图形从 TinkerGraph 输出到 GraphML,然后通过 loadGraphML() 方法将其加载到 Neo4jGraph 中。您可能会对蓝图中有一个 GraphMigrator 工具感兴趣——请参阅蓝图 JavaDoc 了解更多信息。

I don't fully understand your question, but I believe you mean that you have done some work with TinkerGraph and you want to import that data into Neo4jGraph? Moreover, given that you are doing g.loadGraphML(...), I will assume you are talking about doing this from Gremlin. If not, please use the respective GraphMLReader/Writer classes provided by Blueprints.

gremlin> g
==>tinkergraph[vertices:6 edges:6]
gremlin> g.V
==>v[3]
==>v[2]
==>v[1]
==>v[6]
==>v[5]
==>v[4]
gremlin> h = new Neo4jGraph('/tmp/test')
==>neo4jgraph[EmbeddedGraphDatabase [/tmp/test]]
gremlin> g.saveGraphML('test.xml') 
==>null
gremlin> h.loadGraphML('test.xml')
gremlin> h.V
==>v[1]
==>v[2]
==>v[3]
==>v[4]
==>v[5]
==>v[6]

In short, you can output your graph to GraphML from TinkerGraph and then load it up into Neo4jGraph via the loadGraphML() method. There is a GraphMigrator tool in Blueprints that you might be interested---see the Blueprints JavaDoc for more information.

优雅的叶子 2024-12-13 11:10:25

在 gremlin 控制台中,您应该只需键入:
g = new Neo4jGraph("/home/path_to_your_neo4j/data/graph.db")

如果这回答了您的问题,请告诉我。

Within the gremlin console, you should be able to just type:
g = new Neo4jGraph("/home/path_to_your_neo4j/data/graph.db")

Let me know if this answers your question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文