Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Unique middle-man in traversal
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
hyperutila  
View profile  
 More options Apr 30 2012, 4:03 pm
From: hyperutila <derrickbrin...@gmail.com>
Date: Mon, 30 Apr 2012 13:03:42 -0700 (PDT)
Local: Mon, Apr 30 2012 4:03 pm
Subject: Re: Unique middle-man in traversal
Ah, perfect! I think this is exactly what I was looking for. I just
didn't know how to go about implementing your own Uniqueness class. At
first glance, it looked like they only have the built-in Uniqueness
filters that you can create from the Uniqueness class. But I got it
all set up with a UniquenessFactory that generates a UniquenessFilter
and does what I want. Thank you so much!

On Apr 29, 6:32 am, Mattias Persson <matt...@neotechnology.com> wrote:

> It sounds like you'd need to implement your own UniquenessFilter, one which
> checks uniqueness on the last pair of nodes in a Path, right?

> Look at Uniqueness class for an example of a factory for common
> UniquenessFilters. I would implement it something like this (type in this
> mail client only):

> class NodePairUniqueness implements UniquenessFilter {
>     private final Set<Pair<Long,Long>> pairs = new
> HashSet<Pair<Long,Long>>();

>     public bollean checkFirst( TraversalBranch branch ) {
>         return true;
>     }

>     public boolean check( TraversalBranch branch ) {
>         Path position = branch.position();
>         Node nextToLast = null;
>         Node last = null;
>         Iterator<Node> nodes = position.nodes().iterator();
>         while ( nodes.hasNext() ) {
>             nextToLast = last;
>             last = nodes.next();
>         }
>         Pair<Long,Long> lastTwoNodes = Pair.of( nextToLast.getId(),
> last.getId() );
>         return pairs.add( lastTwoNodes );
>     }

> }

> I also realize that it would be grand with a Path#reversedNodes() or
> something this started from the end node and back to the start node. And
> memory-wise it would be more efficient with a custom PrimitiveLongPair
> class or similar instead of the Pair<Long,Long>.

> Den lördagen den 28:e april 2012 skrev hyperutila<derrickbrin...@gmail.com>:

> > I have a graph where there are sometimes multiple relationships
> > between the same two nodes. I want to perform a traversal wherein one
> > of those relationships can be visited once, but once one is visited,
> > none of the others can be.

> > In other words, I don't want to implement uniqueness of relationships,
> > if you were to define a relationship as a means of getting from node A
> > to node B. Once the traversal has gone from node A to node B at some
> > point, it would never do that again, even if there are other
> > relationships that connect those same two nodes. Does that make sense?
> > How do I do this? Can I implement my own version of Uniqueness in
> > order to specify this behavior?

> > Thanks!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.