Traverse the graph returning all nodes with at least 1 matching property. For each node returned add up the matching properties to node A and put that in a list. Sort the list.
On Thu, Feb 24, 2011 at 1:49 AM, Cedric Hurst <[email protected]> wrote: > Not sure if its the best one, but one possible strategy would be to > define a comparator with a constructor that takes an argument of your > comparison node (A), and then implement the compareTo() function to > retrieve the number of common properties for one node against the > number of common properties for other node and return the difference. > Then, you would simply iterate through all the nodes using > graph.getAllNodes(), load them into an arraylist, sort it using your > comparator, and navigate it in reverse. This doesn't leverage any > features of the graph, really, but it does give you a solution. I'm > curious to know if there's a "graphier" way of doing this. > > On Thu, Feb 24, 2011 at 12:36 AM, Agam Dua <[email protected]> wrote: >> Hey >> >> I'm a graph database and Neo4j newbie and I'm in a bit of a fix: >> >> *Problem Description* >> Let's say I have 'n' nodes in the graph, representing the same type of >> object. They have certain undirected links between them. >> Now each of these 'n' nodes has the same 10 properties, the *values* of >> which may differ. >> >> *Problem Statement* >> Take starting node A. I need to find a way to traverse all the nodes of the >> graph and print out which nodes have the most properties in common with A. >> For example, if A, C, D, E, F, G have 'x' properties in common I want to >> print the nodes. >> Then, I want to print the nodes which have 'x-1' properties with the same >> value. Then 'x-2', and so on. >> >> *Question* >> Now my question is, is this possible? If so, what would be the best way to >> go about it? >> >> Thanks in advance! >> Agam. >> * >> * >> _______________________________________________ >> Neo4j mailing list >> [email protected] >> https://lists.neo4j.org/mailman/listinfo/user >> > _______________________________________________ > Neo4j mailing list > [email protected] > https://lists.neo4j.org/mailman/listinfo/user > _______________________________________________ Neo4j mailing list [email protected] https://lists.neo4j.org/mailman/listinfo/user

