Re: [Neo4j] TraversalDescription order

2011-06-24 Thread Igor Dovgiy
Hi Jacob, thanks for answer. )

Followed your idea, found plenty of BranchSelector examples at
https://github.com/neo4j/graphdb/tree/master/kernel/src/main/java/org/neo4j/kernel
(link
you've quoted somehow didn't work). I guess modified
PostorderBreadthFirstSelector method, with gatherSourceIterator() sorting
its queue by node weight, will fit in my model just right. )

By the way, I'm a bit confused about how to design this. I suppose the queue
sorting algorithm should be based on properties of wrapper objects, not the
ones of nodes. Does it mean it's better to apply something like...

ArrayList Interest.sort(ArrayList),

... wrapping all the nodes into objects? Or will it suffice to design some
helper method in Domain class, working directly with Nodes?
(sorry if it looks a bit complicated: it has to be, I've just started to use
Java :) )

About processing the weights outside of traversal: yes, that's definitely a
sensible option, and may be we'll just go that way after all... But what I'm
trying to do is to use the laziness of Traverser: fetch only the required
quantity of matching nodes (best first), not all of them, and then opt out
of its cycle.

Again, thank you for your suggestions!

-- iD

On 23 June 2011 19:38, Jacob Hansson  wrote:

> The order method indeed does decide what order the graph is traversed, you
> can either use it with the predefined traversal orders like so:
>
> td.order(CommonBranchOrdering.PREORDER_DEPTH_FIRST)
>
> or you can pass it your own branch selector implementation, see
>
> https://github.com/neo4j/community/blob/master/kernel/src/main/java/org/neo4j/kernel/PreorderDepthFirstSelector.javafor
> an example.
>
> An easier way to include weights would be to make the traversal only follow
> LIKES relationships that are over a certain weight threshold.

You can also process the weights outside of the traversal entirely. For
> instance, you can calculate the average weight for each path returned by
> the
> traversal, sort the result by that, and only return the top results.


> /jake
>
> On Thu, Jun 23, 2011 at 8:30 AM, Igor Dovgiy  wrote:
>
> > Hi all,
> >
> > I'm trying to implement a recommendations system app with Neo4j (1.4).
> > Basically, I intend to have some 'User' nodes and some 'Interest' nodes
> in
> > my graph. Then, to find users with similar interests, traverse it by
> > something like...
> >
> > TraversalDescription td = new Traversal.description()
> >   .relationships(RelTypes.LIKES)
> >   .evaluator(Evaluators.atDepth(2));
> >
> > The real question is, though, whether I'll be able to choose what
> Interest
> > nodes to walk through first, depending on their weights (i.e., number of
> > users linked to them)? As I understand, the order() method is designed
> > right
> > for this case, but sadly I was unable to find examples of its usage...
> >
> > Any help will be greatly appreciated!
> >
> > -- iD
> > ___
> > Neo4j mailing list
> > User@lists.neo4j.org
> > https://lists.neo4j.org/mailman/listinfo/user
> >
>
>
>
> --
> Jacob Hansson
> Phone: +46 (0) 763503395
> Twitter: @jakewins
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
-- iD
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] TraversalDescription order

2011-06-23 Thread Jacob Hansson
The order method indeed does decide what order the graph is traversed, you
can either use it with the predefined traversal orders like so:

td.order(CommonBranchOrdering.PREORDER_DEPTH_FIRST)

or you can pass it your own branch selector implementation, see
https://github.com/neo4j/community/blob/master/kernel/src/main/java/org/neo4j/kernel/PreorderDepthFirstSelector.javafor
an example.

An easier way to include weights would be to make the traversal only follow
LIKES relationships that are over a certain weight threshold.

You can also process the weights outside of the traversal entirely. For
instance, you can calculate the average weight for each path returned by the
traversal, sort the result by that, and only return the top results.

/jake

On Thu, Jun 23, 2011 at 8:30 AM, Igor Dovgiy  wrote:

> Hi all,
>
> I'm trying to implement a recommendations system app with Neo4j (1.4).
> Basically, I intend to have some 'User' nodes and some 'Interest' nodes in
> my graph. Then, to find users with similar interests, traverse it by
> something like...
>
> TraversalDescription td = new Traversal.description()
>   .relationships(RelTypes.LIKES)
>   .evaluator(Evaluators.atDepth(2));
>
> The real question is, though, whether I'll be able to choose what Interest
> nodes to walk through first, depending on their weights (i.e., number of
> users linked to them)? As I understand, the order() method is designed
> right
> for this case, but sadly I was unable to find examples of its usage...
>
> Any help will be greatly appreciated!
>
> -- iD
> ___
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Jacob Hansson
Phone: +46 (0) 763503395
Twitter: @jakewins
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


[Neo4j] TraversalDescription order

2011-06-23 Thread Igor Dovgiy
Hi all,

I'm trying to implement a recommendations system app with Neo4j (1.4).
Basically, I intend to have some 'User' nodes and some 'Interest' nodes in
my graph. Then, to find users with similar interests, traverse it by
something like...

TraversalDescription td = new Traversal.description()
   .relationships(RelTypes.LIKES)
   .evaluator(Evaluators.atDepth(2));

The real question is, though, whether I'll be able to choose what Interest
nodes to walk through first, depending on their weights (i.e., number of
users linked to them)? As I understand, the order() method is designed right
for this case, but sadly I was unable to find examples of its usage...

Any help will be greatly appreciated!

-- iD
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user