2010/5/24 Peter Neubauer <peter.neuba...@neotechnology.com>: > Thomas, > sorry for taking so long to answer. Welcome to Neo4j! > > On Fri, May 21, 2010 at 10:37 PM, Thomas Sant'ana <maill...@gmail.com> wrote: >> 1) In the Matrix example (I saw it in several videos), what whould be the >> proper way to query: "All people that Neo knows and love him?' In this case >> it's a single hops, so I think the way is to iterate through all "love" >> relations and see if the come back to Neo. But if we have more hops would we >> need to have a traversal in a traversal? > In this case, one approach would be to go along the KNOWS > relationships of Neo (probably later in several hops) and check if > there is an outgoing LOVES relationship back to Neo, something like > http://gist.github.com/411695 (where Trinity doesn't know Neo so we go > 2 KNOWS hops deep. > > >> >> 2) Is there a simple way to know how many edges/relation of a certain type >> come out of a node? I figure I can iterate throw the relations, but I was >> thinking of using this to choose the cheapest starting node for a traversal. > Not really, since there are no global measures stored per se and > almost all data is loaded lazy. However, if you want that, you could > store the number of relationships when you operate on that node in an > index (e.g. Lucene). Who useful that is regarding update performance > and keeping things in sync depends on your usecase. Or you could store that number on the node directly, which to me seems like a better place. > >> >> 3) Let say I have a Car graph, with: >> >> ReferenceNode (RN) --> Cars >> RN ---> Manufactures --> Ford / GM/ SAAB/ Volvo etc. >> RN ---> Colors ---> Grey, Silver, .... >> RN ---> MakeYear ---> 2000, 2001, 2002 >> >> A given car has a relaction to a Manufactures, Color, and Make year: >> >> Cars ---> aCar >> aCar --> Silver >> aCar ---> 2000 >> aCar ---> SAAB >> >> How can I get all the 2000 - 2001, Silver, SAAB? > > I have made the basic structure in http://gist.github.com/411699 . > Now, the question is about how best to optimize set operations between > the different criteria. You could start at the year_2000 node (finding > it with an index lookup for the year 2000, to be added to the code) as > I did and iterate through all car nodes, and return everything that > has a COLOR connection to the Silver node, and a MANUFACTURER > connection to SAAB. However, having multiple years, you even could add > an index on top of e.g. the year nodes in order to be able to > effectively select multiple years. Do you have some more info on the > dataset sizes of your domain so I can flesh the GIST out a bit with > your search? > > /peter > _______________________________________________ > Neo mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user >
-- Mattias Persson, [matt...@neotechnology.com] Hacker, Neo Technology www.neotechnology.com _______________________________________________ Neo mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user