Mattias,

Ok well, after a little bit of greymatter work, I finally got it.

I didn't realized that links provides reachability of the nodes, not
"filtering" of the nodes.

Since all nodes are linked to a root node, i can reach all nodes by
traversing from rootnode only on CONTAINS links.
I have then to "filter" nodes depending on interesting attributes...

The following code does what I want.

        final int sOffset = 3;
        Traverser friendsTraverser = world.traverse(
                Traverser.Order.BREADTH_FIRST,
                StopEvaluator.END_OF_GRAPH,
                new ReturnableEvaluator() {
                    public boolean isReturnableNode(TraversalPosition pos) {

                        boolean atLeastAnIncomingKnowsBoundedLink = false;
                        boolean atLeastAnOutgoingKnowsBoundedLink = false;

                        Iterator allOutRels =
pos.currentNode().getRelationships(Direction.OUTGOING).iterator();

                        while (allOutRels.hasNext()) {
                            Relationship object = (Relationship)
allOutRels.next();

if(((Integer)object.getProperty("beginDateOffset")) >= sOffset){
                                    atLeastAnOutgoingKnowsBoundedLink |=
true;
                                }
                        }
                        Iterator allInRels =
pos.currentNode().getRelationships(Direction.INCOMING).iterator();
                        while (allInRels.hasNext()) {
                            Relationship object = (Relationship)
allInRels.next();

if(((Integer)object.getProperty("beginDateOffset")) >= sOffset){
                                    atLeastAnIncomingKnowsBoundedLink |=
true;
                                }
                        }

                        return atLeastAnIncomingKnowsBoundedLink ||
atLeastAnOutgoingKnowsBoundedLink;
                    }
                },
                MyRelationshipTypes.CONTAINS,
                Direction.OUTGOING);

Since I can reach all nodes with CONTAINS link type, I doesn't need to
'traverse' the other type like I've naively done before.

I tried various values for the links properties, and the result is OK !

On top of that, I would add a subsidiary question : is my solution not
performance killer ? Iterating through all incoming and outgoing links from
a node is not overkill ?

Thank you in advance,

Best regards,

sni.





2009/7/31 <[email protected]>

> Send User mailing list submissions to
>        [email protected]
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        https://lists.neo4j.org/mailman/listinfo/user
> or, via email, send a message with subject or body 'help' to
>        [email protected]
>
> You can reach the person managing the list at
>        [email protected]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of User digest..."
>
>
> Today's Topics:
>
>   1. Re: Searching 'links', based on their attributes ?
>      (Mattias Persson)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 31 Jul 2009 10:50:24 +0200
> From: Mattias Persson <[email protected]>
> Subject: Re: [Neo] Searching 'links', based on their attributes ?
> To: Neo user discussions <[email protected]>
> Message-ID:
>        <[email protected]>
> Content-Type: text/plain; charset=UTF-8
>
> Hi Sebastian,
>
> I'm not sure I really grasp your problem, but one solution that seems
> appropriate would be to connect all those object graphs to one "super
> root node" of your choice. So that you create this super root node,
> maybe connect it to the neo reference node and let all your object
> graphs have some relationship to that super root node. That way
> they'll all be connected in a way and you could have that node as a
> starting node when you traverse.
>
> Alternatively you could connect all your object graphs to the neo
> reference node directly and use that as a starting point for your
> traversals.
>
> Would that help you?
>
> 2009/7/31 sebastien nichele <[email protected]>:
> > Hi,
> >
> > I'm currently evaluating neo4j and I'am really satisfied/impressed by it.
> >
> > However, I'm asking myself several questions.
> >
> > In my "node space" I have several dissocied objects graphs.
> > Links between nodes bears two attributes "startDate" and "endDate".
> >
> > ?At one time, i want to display all nodes in my graph that have links
> > ?that match some combinations of startDate and endDate (ie. 'give me all
> > nodes linked by links that
> > ?have dates between 1st january and 3 march'), whatever the link nature
> is.
> >
> > ?I started using traversing for that, using exemples I found on
> > documentation.
> > ?My problem is that I don't have any "super root node" in my "node space"
> to
> > start traversing (since traversing needs a 'root' node), but several
> graphs
> > with several root nodes.
> >
> > ?In realize that in fact, I don't really want to "traverse" a graph, but
> > simply pick links based on their attributes, and then, return nodes on
> links
> > sides.
> >
> > ?I digged upon the documentation, but didn't find a way to do that simply
> > and efficiently.
> >
> > ?I have the feeling that I am missing something...
> >
> > ?Can anyone shed some light on my matter ? ;)
> >
> > ?Thanks in advance for your answers,
> >
> > ?Best regards,
> >
> > ?sni.
> > _______________________________________________
> > Neo mailing list
> > [email protected]
> > https://lists.neo4j.org/mailman/listinfo/user
> >
>
>
>
> --
> Mattias Persson, [[email protected]]
> Neo Technology, www.neotechnology.com
>
>
> ------------------------------
>
> _______________________________________________
> User mailing list
> [email protected]
> https://lists.neo4j.org/mailman/listinfo/user
>
>
> End of User Digest, Vol 28, Issue 35
> ************************************
>
_______________________________________________
Neo mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to