我刚开始用 R、neo4j 和 R-neo4j 编程,所以如果我的问题是微不足道的,请多多包涵。
我使用 R-neo4j 和以下 R 项目代码 [2] 创建了以下数据库(请附上照片)[1]。
该数据库包含四个玩家之间的计算机游戏比赛的结果。数据集由四个节点组成,玩家 1 到玩家 4。这些节点通过关系“失败”连接,表示比赛的结果。每个关系都有两个标签条目,包含以下数据:judge、game。
从使用 Cypher 查询的图形数据库中,我想提取以下形式的数据(请在 [1] 中提供图片):
Winning player Loosing player Game Judge
player 1 player 4 Starcraft player 2
player 1 player 4 LOL player 3
player 4 player 1 LOL player 2
player 1 player 4 Starcraft player 3
player 1 player 2 LOL player 3
player 2 player 1 LOL player 4
player 4 player 1 Starcraft player 4
我想对图形数据库进行查询(在 R-neo4j 环境中首选),其中输入为“玩家 1”并返回上表。
我希望我的问题很清楚,有人可以帮助我。
祝你有美好的一天。
基督教
[2] R (Rneo4j) 代码:
clear(graph)
Y
player1 = createNode(graph,"user",ID="Player 1",male=T)
player2 = createNode(graph,"user",ID="Player 2",male=T)
player3 = createNode(graph,"user",ID="Player 3",male=F)
player4 = createNode(graph,"user",ID="Player 4",male=F)
addConstraint(graph,"user","ID")
rel1 = createRel(player1,"defeats",player4)
rel2 = createRel(player1,"defeats",player4)
rel3 = createRel(player4,"defeats",player1)
rel4 = createRel(player1,"defeats",player4)
rel5 = createRel(player1,"defeats",player2)
rel6 = createRel(player2,"defeats",player1)
rel7 = createRel(player3,"defeats",player1)
rel1 = updateProp(rel1, game = "Starcraft", judge = "Player 2")
rel2 = updateProp(rel2, game = "League of Legends", judge = "Player 3")
rel3 = updateProp(rel3, game = "League of Legends", judge = "Player 2")
rel4 = updateProp(rel4, game = "Starcraft", judge = "Player 3")
rel5 = updateProp(rel5, game = "League of Legends", judge = "Player 3")
rel6 = updateProp(rel6, game = "League of Legends", judge = "Player 4")
rel7 = updateProp(rel7, game = "Starcraft", judge = "Player 4")