[Neo4j] HowTo: Dijkstra with Limited Depth
Hi there, I'm having performance issues with Neo4J while using GraphAlgoFactory to find a path between two nodes. I want to calculate the cost between the two nodes (each relation type has a different cost), with the maximum depth of 3 (paths with more length can be discarded). I'm using the findAllPaths method, since the findShorthestPath method takes into account the path length and not the cost associated to it. But this is not the ideal solution, because of the performance issues I'm having. I'm thinking about using something like the Dijkstra algorithm, but with a maximum depth of 3. I already took a look at the Neo4J source code and found the class *org.neo4j.graphalgo.impl.shortestpath.Dijkstra, *which I have tried to use with limitMaxRelationShipsToTraverse set to 3. Most of the times it doesn't found any path, and throws the exception: java.lang.RuntimeException: Trying to decrease to a greater key at org.neo4j.graphalgo.impl.util.FibonacciHeap.decreaseKey(FibonacciHeap.java:318) at org.neo4j.graphalgo.impl.shortestpath.DijkstraPriorityQueueFibonacciImpl.decreaseValue(DijkstraPriorityQueueFibonacciImpl.java:103) at org.neo4j.graphalgo.impl.shortestpath.Dijkstra$DijstraIterator.next(Dijkstra.java:393) at org.neo4j.graphalgo.impl.shortestpath.Dijkstra.calculate(Dijkstra.java:516) Is this class appropriate for what I want to accomplish? I also would like to know if this is a good solution for the discribed problem, or if there is a better solution out there. Best regards, Joel Filipe Antunes Cordeiro jkorde...@gmail.com j...@student.dei.uc.pt ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
[Neo4j] org.neo4j.kernel.impl.nioneo.store.InvalidRecordException while trying to delete relationships of a node, followed by a delete of the node
Hi, i'm getting the followed stack trace after trying to delete the relationships of a node, followed by the delete of the node (the goal is to remove the node from the store, which must have no relationships, before doing that). org.neo4j.kernel.impl.nioneo.store.InvalidRecordException: Record[2592] not in use at org.neo4j.kernel.impl.nioneo.store.RelationshipStore.getRecord(RelationshipStore.java:230) at org.neo4j.kernel.impl.nioneo.store.RelationshipStore.getRecord(RelationshipStore.java:97) at org.neo4j.kernel.impl.nioneo.xa.WriteTransaction.disconnectRelationship(WriteTransaction.java:778) at org.neo4j.kernel.impl.nioneo.xa.WriteTransaction.relDelete(WriteTransaction.java:729) at org.neo4j.kernel.impl.persistence.PersistenceManager.relDelete(PersistenceManager.java:166) at org.neo4j.kernel.impl.core.NodeManager.deleteRelationship(NodeManager.java:864) at org.neo4j.kernel.impl.core.RelationshipImpl.delete(RelationshipImpl.java:148) at org.neo4j.kernel.impl.core.RelationshipProxy.delete(RelationshipProxy.java:50) at pt.uc.dei.sdic.plugin.knowledge.neo4j.Neo4JRepository.remove(Neo4JRepository.java:1064) The code i implemented to do that is the follow: Node node = indexService.get(SDKE.FIELD_LOCAL_PATH, sdkeID).getSingle(); Transaction t = graphDb.beginTx(); try { indexService.remove(node); for(Relationship relation: node.getRelationships()) { relation.delete(); } node.delete(); t.success(); } catch (Exception e) { t.failure(); LoggerFactory.getLogger(this.getClass()).error(e.getMessage(), e); } finally { t.finish(); } Can anyone figure out a reason for it? I already read questions with similar stack traces on the mailing list, but didn't found a solution to this. Best regards, Joel Filipe Antunes Cordeiro jkorde...@gmail.com j...@student.dei.uc.pt ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] org.neo4j.kernel.impl.nioneo.store.InvalidRecordException while trying to delete relationships of a node, followed by a delete of the node
Yes, the data was inserted with BatchInserter on 1.4M04. Joel Filipe Antunes Cordeiro jkorde...@gmail.com j...@student.dei.uc.pt 2011/7/21 Mattias Persson matt...@neotechnology.com Was your data inserted with the BatchInserter on 1.4.M05 or 1.4.M04 or similar? 2011/7/21 Joel Cordeiro jkorde...@gmail.com Hi, i'm getting the followed stack trace after trying to delete the relationships of a node, followed by the delete of the node (the goal is to remove the node from the store, which must have no relationships, before doing that). org.neo4j.kernel.impl.nioneo.store.InvalidRecordException: Record[2592] not in use at org.neo4j.kernel.impl.nioneo.store.RelationshipStore.getRecord(RelationshipStore.java:230) at org.neo4j.kernel.impl.nioneo.store.RelationshipStore.getRecord(RelationshipStore.java:97) at org.neo4j.kernel.impl.nioneo.xa.WriteTransaction.disconnectRelationship(WriteTransaction.java:778) at org.neo4j.kernel.impl.nioneo.xa.WriteTransaction.relDelete(WriteTransaction.java:729) at org.neo4j.kernel.impl.persistence.PersistenceManager.relDelete(PersistenceManager.java:166) at org.neo4j.kernel.impl.core.NodeManager.deleteRelationship(NodeManager.java:864) at org.neo4j.kernel.impl.core.RelationshipImpl.delete(RelationshipImpl.java:148) at org.neo4j.kernel.impl.core.RelationshipProxy.delete(RelationshipProxy.java:50) at pt.uc.dei.sdic.plugin.knowledge.neo4j.Neo4JRepository.remove(Neo4JRepository.java:1064) The code i implemented to do that is the follow: Node node = indexService.get(SDKE.FIELD_LOCAL_PATH, sdkeID).getSingle(); Transaction t = graphDb.beginTx(); try { indexService.remove(node); for(Relationship relation: node.getRelationships()) { relation.delete(); } node.delete(); t.success(); } catch (Exception e) { t.failure(); LoggerFactory.getLogger(this.getClass()).error(e.getMessage(), e); } finally { t.finish(); } Can anyone figure out a reason for it? I already read questions with similar stack traces on the mailing list, but didn't found a solution to this. Best regards, Joel Filipe Antunes Cordeiro jkorde...@gmail.com j...@student.dei.uc.pt ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user -- Mattias Persson, [matt...@neotechnology.com] Hacker, Neo Technology www.neotechnology.com ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] org.neo4j.kernel.impl.nioneo.store.InvalidRecordException while trying to delete relationships of a node, followed by a delete of the node
Thank you for the answer. The data set is not critical. It is easy to reinsert with the BatchInserter of 1.4. What is critical on my dataset is to keep it updated at runtime, that's why i need to add and remove nodes, and consequently their relationships. How can i solve that issue? Best regards, Joel Filipe Antunes Cordeiro jkorde...@gmail.com j...@student.dei.uc.pt 2011/7/21 Mattias Persson matt...@neotechnology.com I'm sad to say that there was a bug in BatchInserter in M04 and M05 which could create some invalid relationship records. Is it a critical data set or is it easy to reinsert it with the BatchInserter of 1.4? 2011/7/21 Joel Cordeiro jkorde...@gmail.com Yes, the data was inserted with BatchInserter on 1.4M04. Joel Filipe Antunes Cordeiro jkorde...@gmail.com j...@student.dei.uc.pt 2011/7/21 Mattias Persson matt...@neotechnology.com Was your data inserted with the BatchInserter on 1.4.M05 or 1.4.M04 or similar? 2011/7/21 Joel Cordeiro jkorde...@gmail.com Hi, i'm getting the followed stack trace after trying to delete the relationships of a node, followed by the delete of the node (the goal is to remove the node from the store, which must have no relationships, before doing that). org.neo4j.kernel.impl.nioneo.store.InvalidRecordException: Record[2592] not in use at org.neo4j.kernel.impl.nioneo.store.RelationshipStore.getRecord(RelationshipStore.java:230) at org.neo4j.kernel.impl.nioneo.store.RelationshipStore.getRecord(RelationshipStore.java:97) at org.neo4j.kernel.impl.nioneo.xa.WriteTransaction.disconnectRelationship(WriteTransaction.java:778) at org.neo4j.kernel.impl.nioneo.xa.WriteTransaction.relDelete(WriteTransaction.java:729) at org.neo4j.kernel.impl.persistence.PersistenceManager.relDelete(PersistenceManager.java:166) at org.neo4j.kernel.impl.core.NodeManager.deleteRelationship(NodeManager.java:864) at org.neo4j.kernel.impl.core.RelationshipImpl.delete(RelationshipImpl.java:148) at org.neo4j.kernel.impl.core.RelationshipProxy.delete(RelationshipProxy.java:50) at pt.uc.dei.sdic.plugin.knowledge.neo4j.Neo4JRepository.remove(Neo4JRepository.java:1064) The code i implemented to do that is the follow: Node node = indexService.get(SDKE.FIELD_LOCAL_PATH, sdkeID).getSingle(); Transaction t = graphDb.beginTx(); try { indexService.remove(node); for(Relationship relation: node.getRelationships()) { relation.delete(); } node.delete(); t.success(); } catch (Exception e) { t.failure(); LoggerFactory.getLogger(this.getClass()).error(e.getMessage(), e); } finally { t.finish(); } Can anyone figure out a reason for it? I already read questions with similar stack traces on the mailing list, but didn't found a solution to this. Best regards, Joel Filipe Antunes Cordeiro jkorde...@gmail.com j...@student.dei.uc.pt ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user -- Mattias Persson, [matt...@neotechnology.com] Hacker, Neo Technology www.neotechnology.com ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user -- Mattias Persson, [matt...@neotechnology.com] Hacker, Neo Technology www.neotechnology.com ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user