Re: [Neo4j] simple traverse of tree
Matej, in this case, IteratorPath paths = Traversal.description().relationship(TICKET_STATUS,INCOMING).relationship(TICKET_STATUS_EVENT,INCOMING).traverse(db.getNodeById(1001)).iterator(); should give you an iterator of Paths, where you can just get the end node by doing paths.next().endNode() Would that help? Cheers, /peter neubauer GTalk: neubauer.peter Skype peter.neubauer Phone +46 704 106975 LinkedIn http://www.linkedin.com/in/neubauer Twitter http://twitter.com/peterneubauer http://www.neo4j.org - Your high performance graph database. http://startupbootcamp.org/ - Öresund - Innovation happens HERE. http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party. On Sat, Mar 26, 2011 at 7:55 PM, Matěj Plch plchm...@fit.cvut.cz wrote: Well maybe the best one to show the graph: https://webdev.fit.cvut.cz/~plchmate/mi-w20/neoclipse.png https://webdev.fit.cvut.cz/%7Eplchmate/mi-w20/neoclipse.png There is a ticket node:1001 and I would like to get all nodes under for example node Status_Events. Now there is only one node, in real there will be more nodes. But not so much (not more than 100 Im quite sure). Dne 26.3.2011 19:35, Michael Hunger napsal(a): Sure, if the tree from your root node is just a cluster that is not connected anywhere else (with those 3 relationship-types) it should be as simple as. (Just written from my head, so please check the correct syntax). Traversal.description().relationship(T1,OUTGOING).relationship(T2,OUTGOING).relationship(T3,OUTGOING).traverse(rootNode); That returns an iterator of all paths going from your root node. You can limit the nodes with .uniqueness() and then add the path's (path.nodes()) to a set to collect all nodes. For getting the one with the highest id, you can use java.util.Collections.max(collection, new ComparatorNode(){}); How big is your tree? Something like that should be in Graph-Algo perhaps as subgraph or tree. HTH Michael Am 26.03.2011 um 19:26 schrieb Matěj Plch: Thank you for so fast answer. I will look at it. I have milestone tomorrow so dont have a lot of time=) and have never worked with Groovy. Well so there isnt any simple method how to do it in classic neo4j Java API? Dne 26.3.2011 19:16, Saikat Kanjilal napsal(a): You can do all of these things using gremlin and pipes. Check out github for more details. Sent from my iPhone On Mar 26, 2011, at 11:13 AM, Matěj Plchplchm...@fit.cvut.cz wrote: Hi, I have some graph and, part of it is a tree. I simple get root of this tree through id. How to simple tranverse only tree under this root node? From root goes three unique type relationship to three unique group type nodes. Under this three nodes are a lot of nodes. And I need to write a method which gives me all nodes under that group node. Second question is if its possible ho to get from this group noe with the highest id (last added). Matěj Plch ___ 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 ___ 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 ___ 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] cycle detection
In case you are interested, I implemented cycle detection by using Tarjan algorithm, not the traversal. The code is visible in the Italian Wikipedia, I hope it's intelligible although the language. http://it.wikipedia.org/wiki/Algoritmo_di_Tarjan_per_le_componenti_fortemente_connesse#Implementazione_in_Java Hi Jacopo Farina Il giorno ven, 25/03/2011 alle 13.51 +0100, Mattias Persson ha scritto: I think you could implement this using RELATIONSHIP_GLOBAL uniqueness, like (from the top of my head): Traversal.description().uniqueness( Uniqueness.RELATIONSHIP_GLOBAL ) .evaluator(new Evaluator() { public Evaluation(Path path) { return path.length() 0 endNodeOccursPreviouslyInPath( path ) ? Evaluation.INCLUDE_AND_CONTINUE : Evaluation.EXCLUDE_AND_CONTINUE; } private boolean endNodeOccursPreviouslyInPath(Path path) { Node endNode = path.endNode(); int counter = 0; for ( Node node : path.nodes() ) { if ( counter++ path.length() node.equals( endNode ) ) return true; } return false; } } ).traverse(...); This should (if it even compiles :) ) return paths containing cycles. Something like this you're looking for? 2011/3/25 Wouter De Borger w.debor...@gmail.com Hi all, I would like to detect all cycles in a traversal. I know the traversal framework has cycle avoidance built-in, but there doesn't seem to be an API for cycle detection! Has anyone already implemented a cycle detector for traversals? Thanks in advance, Wouter ___ 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
[Neo4j] Glassfish problem
Hi! So we deployed our application, but we get Caused by: java.lang.IllegalStateException: Unable to lock store ... SEVERE: 0-database/neostore], this is usually caused by another Neo4j kernel already running in this JVM for this particular store Is there any best practise how to avoid this? The database is opened or created from class with is Singleton. Can this be the problem? I googled this problem, but no solution found. Matěj Plch ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] Glassfish problem
Can you show the code of the (I assume SessionBean) that connects to the Neo4j store? Thanks Michael Am 28.03.2011 um 00:29 schrieb Matěj Plch: Hi! So we deployed our application, but we get Caused by: java.lang.IllegalStateException: Unable to lock store ... SEVERE: 0-database/neostore], this is usually caused by another Neo4j kernel already running in this JVM for this particular store Is there any best practise how to avoid this? The database is opened or created from class with is Singleton. Can this be the problem? I googled this problem, but no solution found. Matěj Plch ___ 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] Glassfish problem
Hi Matěj, As the error message says, most likely this is caused by another instance already being open in the same JVM. If I were to have I guess, I think that your code (in the singleton you mention) create a new GraphDatabaseService without invoking shutdown() on the existing one first. Probably what you've done is just null out the reference (which is why your code thinks it has to start a new instance). There is no need to startup and shutdown the graph database multiple times (are you doing this for each request?), it is not a database connection, it is the database, and startup and shutdown takes time. It is better to tie the lifecycle of the graph database to the lifecycle of your application. Cheers, Tobias 2011/3/28 Matěj Plch plchm...@fit.cvut.cz Hi! So we deployed our application, but we get Caused by: java.lang.IllegalStateException: Unable to lock store ... SEVERE: 0-database/neostore], this is usually caused by another Neo4j kernel already running in this JVM for this particular store Is there any best practise how to avoid this? The database is opened or created from class with is Singleton. Can this be the problem? I googled this problem, but no solution found. Matěj Plch ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user -- Tobias Ivarsson tobias.ivars...@neotechnology.com Hacker, Neo Technology www.neotechnology.com Cellphone: +46 706 534857 ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user