Re: [Neo4j] New tentative API in trunk: Expander/Expansion

2010-07-09 Thread Tobias Ivarsson
Thanks for all the input guys! As of revision 4717 these methods no longer exist in trunk. Since this was just a tentative API. I will continue experimenting with this API in a branch and it will likely make it back into the core API in a later release. Cheers, Tobias -- Tobias Ivarsson Hacker,

Re: [Neo4j] New tentative API in trunk: Expander/Expansion

2010-06-24 Thread Craig Taverner
I guess I would have just added a clear() method to the expansion. But of course I understand that using mutable expansions requires that the user actually understand the implications, which goes against the simplicity of the DSL. On Thu, Jun 24, 2010 at 12:23 AM, Tobias Ivarsson < tobias.ivars...

Re: [Neo4j] New tentative API in trunk: Expander/Expansion

2010-06-24 Thread Atle Prange
I agree, lets keep it immutable, then its safe to keep the expander around. Two suggestions: Your could provide a reusable expander: Expander e = Expanders.outgoing().along(FRIEND).and(ENEMY); for(Node n:e.expand(node)){ ... } or a onetime expander: for(Node n : node.expand().outgoing().along

Re: [Neo4j] New tentative API in trunk: Expander/Expansion

2010-06-23 Thread Tobias Ivarsson
The problem with the code below is that once you've used the Person.getFriends(minAge)-method once, the friends-expansion will have that filter added to it forever (if it's mutable), and that means that you will never be able to get the younger friends of that person. However, reusing an expansion

Re: [Neo4j] New tentative API in trunk: Expander/Expansion

2010-06-23 Thread Craig Taverner
Mutable objects have their issues, and yet this is a common and popular paradigm in DSL design. I guess however the point with a DSL is that it is so simple and limited that it compensates for the potential risks. Similar to the dynamic versus static language argument. Now there are ways to reduce

Re: [Neo4j] New tentative API in trunk: Expander/Expansion

2010-06-23 Thread Tobias Ivarsson
Because mutable objects are evil. It would for example make it impossible to write classes like this: class Person { private final Expansion friends; Person(Node node) { this.friends = node.expand( FRIEND ).nodes(); } Iterable getFriends() { return persons( friends

Re: [Neo4j] New tentative API in trunk: Expander/Expansion

2010-06-23 Thread Craig Taverner
Why not have includes() return the same instance with internal state changed, then the various call options are equivalent. On Jun 23, 2010 6:41 PM, "Tobias Ivarsson" < tobias.ivars...@neotechnology.com> wrote: On Wed, Jun 23, 2010 at 6:10 PM, Craig Taverner wrote: > > (I also noticed that r...

Re: [Neo4j] New tentative API in trunk: Expander/Expansion

2010-06-23 Thread Tobias Ivarsson
On Wed, Jun 23, 2010 at 6:10 PM, Craig Taverner wrote: > > (I also noticed that reading the examples with and() correctly indicates > that the order of definition is irrelevant, while includes() almost implies > that the first relationship type has some kind of precedence. Could it?) I get that

Re: [Neo4j] New tentative API in trunk: Expander/Expansion

2010-06-23 Thread Craig Taverner
I like this new API. It is a tiny first step towards making the Java API a little more DSL-like (1% of the way to the current scala and ruby API's :-) My vote is actually for the includes() approach only because *and* is such a widely used keyword. However, a quick test in Ruby showed that while i

Re: [Neo4j] New tentative API in trunk: Expander/Expansion

2010-06-23 Thread Alex Averbuch
Hi, Personally I'd prefer and/not. It's intuitive to any programmer and has the bonus of being much shorter, so long complex expansions will appear less messy in practice. On Wed, Jun 23, 2010 at 5:45 PM, Tobias Ivarsson < tobias.ivars...@neotechnology.com> wrote: > Did anyone have an opinion on

Re: [Neo4j] New tentative API in trunk: Expander/Expansion

2010-06-23 Thread Tobias Ivarsson
Did anyone have an opinion on what to call the methods on the Expansion interface that specify which types to expand. Alternative 1) Expansion and( RelationshipType type ); Expansion and( RelationshipType type, Direction direction ); Expansion not( RelationshipType type ); Examples: for (Node nod

Re: [Neo4j] New tentative API in trunk: Expander/Expansion

2010-06-23 Thread Alex Averbuch
Sweet, Experiments are running fine again. Thanks for the quick help! Alex On Wed, Jun 23, 2010 at 4:17 PM, Mattias Persson wrote: > It works with graph-algo 0.6-SNAPSHOT and there's an AStar.java (which is > the "old" version) and one ExperimentalAStar.java which uses the new > traversal framew

Re: [Neo4j] New tentative API in trunk: Expander/Expansion

2010-06-23 Thread Mattias Persson
It works with graph-algo 0.6-SNAPSHOT and there's an AStar.java (which is the "old" version) and one ExperimentalAStar.java which uses the new traversal framework. 2010/6/23 Alex Averbuch > Hi guys, > thanks! > > I've pulled the latest java-astar-routing and looking at it now. > Have changed to

Re: [Neo4j] New tentative API in trunk: Expander/Expansion

2010-06-23 Thread Alex Averbuch
Hi guys, thanks! I've pulled the latest java-astar-routing and looking at it now. Have changed to SNAPSHOT 0.6 too. Has the AStar algorithm been changed to use the Traversal framework now? If so, is there any way I can use the old AStar version? The last one required neo4j-apoc 1.1-SNAPSHOT & ne

Re: [Neo4j] New tentative API in trunk: Expander/Expansion

2010-06-23 Thread Mattias Persson
Also, the latest graph-algo is 0.6-SNAPSHOT... so use that instead 2010/6/23 Anders Nawroth > Hi! > > See: > http://www.mail-archive.com/user@lists.neo4j.org/msg04044.html > > /anders > > On 06/23/2010 03:44 PM, Alex Averbuch wrote: > > Hi Tobias, > > It seems as though the new changes have brok

Re: [Neo4j] New tentative API in trunk: Expander/Expansion

2010-06-23 Thread Anders Nawroth
Hi! See: http://www.mail-archive.com/user@lists.neo4j.org/msg04044.html /anders On 06/23/2010 03:44 PM, Alex Averbuch wrote: > Hi Tobias, > It seems as though the new changes have broken the AStar code I'm using. > > I use: > neo4j-apoc 1.1-SNAPSHOT > neo4j-graph-algo 0.5-SNAPSHOT > > AStar uses

Re: [Neo4j] New tentative API in trunk: Expander/Expansion

2010-06-23 Thread Alex Averbuch
Hi Tobias, It seems as though the new changes have broken the AStar code I'm using. I use: neo4j-apoc 1.1-SNAPSHOT neo4j-graph-algo 0.5-SNAPSHOT AStar uses DefaultExpander and can no longer find it. Here's an example of the code that worked until now. DefaultExpander relExpander = new DefaultEx

[Neo4j] New tentative API in trunk: Expander/Expansion

2010-06-23 Thread Tobias Ivarsson
Hi Neo4j enthusiasts! Yesterday I committed an API that Mattias and I have been working on for a few days. It comes in the form of two new interfaces Expander and Expansion (in the org.neo4j.graphdb package), and four new methods in the Node interface (method names starting with "expand"). The tw