我已经使用neo4j Java API为下面的数据集创建了一个图形。
论文:被引用论文
纸张1:纸张2,Paper3,Paper4
论文2:论文3,Paper1
Paper3:Paper4
Paper4:[]
论文5:论文6
Paper6:[]
用于图形创建的PseudoCode
GraphDatabaseService graph;
IndexManager idx;
//In a for loop
Node node = idx.get(""); // For each Paper
if(node == null) {
node = graph.createNode();
idx.add(node);
}
node.createRelationship(); // For cited Papers完成上述步骤后,我如何找到所有节点(论文)是否都已连接的form Neo4j接口。
发布于 2014-04-22 09:08:53
如果我理解得很好,您尝试实现的是所谓的“连接组件”计算,这里描述了一些方法:http://en.wikipedia.org/wiki/Connected_component_(graph_theory)。
你应该能够通过一次简单的遍历来做你想做的事情。这里描述了Neo4j遍历框架:http://docs.neo4j.org/chunked/stable/tutorial-traversal.html。
https://stackoverflow.com/questions/23208415
复制相似问题