[Neo4j] Gremlin steps in JavaDoc.

2011-12-09 Thread Marko Rodriguez
Hi,

For those using Gremlin and wanting a complete list of all provided steps and 
their various overloadings, please see:


http://tinkerpop.com/maven2/com/tinkerpop/gremlin/gremlin-java/1.4/api/com/tinkerpop/gremlin/java/GremlinPipeline.html

Note that this is for Gremlin 1.4 (released 2 days ago). Any method that takes 
a PipeFunction in Gremlin Groovy is a closure and in Gremlin Scala is an 
anonymous function.

Finally, apologies for the lack of commenting -- JavaDoc didn't inherit from 
respective interfaces as I expected it to.

Hope that is useful,
Marko.

http://markorodriguez.com

___
NOTICE: THIS MAILING LIST IS BEING SWITCHED TO GOOGLE GROUPS, please register 
and consider posting at https://groups.google.com/forum/#!forum/neo4j

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


Re: [Neo4j] Neo4jClient - Query optmised

2011-12-08 Thread Marko Rodriguez
Nice! 

BTW: Great work on the Neo4j .Net Client.

Marko.

http://markorodriguez.com

On Dec 7, 2011, at 9:14 PM, Romiko Derbynew wrote:

 Finally thanks to Peter and Marko, the .Net Neo4jClient code has been 
 optimised to use short hand version of in('') and out('').
 ChangeSet is http://hg.readify.net/neo4jclient/changeset/91ef447a9053
 ___
 NOTICE: THIS MAILING LIST IS BEING SWITCHED TO GOOGLE GROUPS, please register 
 and consider posting at https://groups.google.com/forum/#!forum/neo4j
 
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

___
NOTICE: THIS MAILING LIST IS BEING SWITCHED TO GOOGLE GROUPS, please register 
and consider posting at https://groups.google.com/forum/#!forum/neo4j

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


[Neo4j] TinkerPop Stack Release

2011-12-08 Thread Marko Rodriguez
Hello,

Yesterday TinkerPop did another stable release. This release depends on Neo4j 
1.5. Here are the notes for those that are interested:

New homepage design: http://tinkerpop.com

Blueprints 1.1 (Blueberry):
https://github.com/tinkerpop/blueprints/wiki/Release-Notes
Pipes 0.9 (Sink):
https://github.com/tinkerpop/pipes/wiki/Release-Notes
Gremlin 1.4 (Ain't No Thing But a Chicken Wing):
https://github.com/tinkerpop/gremlin/wiki/Release-Notes
Frames 0.6 (Truss):
https://github.com/tinkerpop/frames/wiki/Release-Notes
Rexster 0.7 (Brian)
https://github.com/tinkerpop/rexster/wiki/Release-Notes
Rexster-Kibbles 0.7 (http://rexster-kibbles.tinkerpop.com)


PLEASE READ THE FOLLOWING NOTES:
1. Be aware that old rexster.xml files will not work with Rexster 0.7. 
The tag graph-file has been changed to graph-location.
2. Realize that when you download Gremlin, there are two versions to 
pick from --- Groovy and Scala.
- Gremlin Groovy is what everyone is familiar with.
- Gremlin Scala is making its debut as an experiment in 
exposing the Gremlin style in other JVM languages besides Groovy. (thank you 
Zach Cox)
- Gremlin Java exists (via Maven2 or raw .jar) for those 
wanting to do the Gremlin style in pure Java -or- add Gremlin to another JVM 
language.
- See: 
https://github.com/tinkerpop/gremlin/wiki/JVM-Language-Implementations
3. Pipes no longer depends on Blueprints. All the graph specific pipes 
have been moved to Gremlin. Pipes is simply a generic data flow framework now.
- depend on gremlin-java if you want to use Blueprints 
specific pipes.

Enjoy!,
Marko.

http://markorodriguez.com

___
NOTICE: THIS MAILING LIST IS BEING SWITCHED TO GOOGLE GROUPS, please register 
and consider posting at https://groups.google.com/forum/#!forum/neo4j

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


Re: [Neo4j] println and Table Projections

2011-12-07 Thread Marko Rodriguez
Hi,

Peter brings up a good point. Its hard for us to parse complex queries and see 
where Exceptions are happening. If you can isolate the problem via a simpler 
traversal, that would be best for us -- and our little baby brains.

Also, note the following syntax optimizations for your traversal:
1. outE[[label:'HOSTS']].inV --- out('HOSTS')
2. Similarly, inE[[label:'X']].outV - in('X')

Using out() and in() is much more efficient (faster) and more concise. Unless 
you plan to reason on the properties of an edge, then there is no reason to use 
outE.inV style syntax as out will do the full vertex-to-vertex jump for you.

HTH,
Marko.

http://markorodriguez.com

On Dec 7, 2011, at 1:00 AM, Peter Neubauer wrote:

 Mmh,
 I was thinking on how to return the contents of the output stream, I
 am not quite sure how to return that. What woudl be a good format for
 you?
 
 Also could you reduce this into a small testcase that I can work on?
 
 Cheers,
 
 /peter neubauer
 
 GTalk:  neubauer.peter
 Skype   peter.neubauer
 Phone   +46 704 106975
 LinkedIn   http://www.linkedin.com/in/neubauer
 Twitter  http://twitter.com/peterneubauer
 
 brew install neo4j  neo4j start
 heroku addons:add neo4j
 
 
 
 On Wed, Dec 7, 2011 at 8:10 AM, Romiko Derbynew
 romiko.derby...@readify.net wrote:
 Hi,
 
 I have this statement.
 g.v('0').outE[[label:'HOSTS']].inV.filter{ 
 it['Key'].equalsIgnoreCase('romikoagency') 
 }.inE[[label:'USER_BELONGS_TO']].outV.filter{ 
 it['Username'].equalsIgnoreCase('romiko.derbynew') 
 }.ifThenElse{it.outE[[label:'USER_LINKED_TO_CENTRE']].inV.hasNext()}{it.outE[[label:'USER_LINKED_TO_CENTRE']].inV.Name}{println
  ${it} Unknown}.as('Centre')
 
 I then take this query and do a table projection, however I get the 
 following error.
 println java.lang.String cannot be cast to 
 com.tinkerpop.blueprints.pgm.Vertex
 
 Is there a better way to do this then? I want to reduce our calls to the DB 
 for performance and finding it a bit tough wrapping everything into one  
 query. Currently the above query is split into two different queries.
 
 Much appreciated.
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] [Neo4j-User] Re: Gremlin Query - Help

2011-12-06 Thread Marko Rodriguez
Hi,

You can do nested ifThenElses. One way to think about things is not as big ol' 
one-liners.


g.V.ifThenElse{ ifStatement } {
thenStatement
} {
elseStatement
}

With new lines, the embeddness then starts to look like plain ol' C-style 
syntax.

Also note that in Gremlin 1.4 (releasing this week), the _() will not be needed 
anymore for start objects. I learned how to solve that at SpringONE :).

Thanks,
Marko.

http://markorodriguez.com

On Dec 5, 2011, at 8:27 PM, Romiko Derbynew wrote:

 Marko,
 
 I am thinking of using this statement.
 g.V.ifThenElse{it.out('hasCentre').filter{it == aCentre}.hasNext()}{}{println 
 ${it} has center unknown}
 
 to get nodes that DO NOT have a relationship, is this the best way to do it? 
 I guess so, if this is the case, I am now adding support to the .NET graph 
 client to support ifThenElse expressions. I am wondering though, as I am 
 designing the interface for it, can and ifThenElse have nested ifThenElse 
 expressions as well? I guess it and _() can be used within them?
 
 Cheers
 
 -Original Message-
 From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org] On 
 Behalf Of Marko Rodriguez
 Sent: Saturday, 3 December 2011 4:10 AM
 To: Neo4j user discussions
 Subject: Re: [Neo4j] Gremlin Query - Help
 
 Hi,
 
 Scenario 1:
 I would like to get all Nodes that do not have a relationship to another 
 node. What is the best way to do this Gremlin?
 
 Root = NodeA = NodeB
 Root = NodeC
 
 Output should be NodeC
 
   I don't understand the problem.
 
 Scenario 2:
 Root =  User - Centre
 
 I would like to get all centres for userA, and then get all users who 
 are also linked to the same centres of the userA
 
   userA.out('hasCentre').in('hasCentre').except([userA])
 
 Scenario 3:
 User = Centre
 I would like to get all users that do not have a link to a Centre, and if 
 this is the case, do a projection that returns a fake centre with property 
 Unknown
 
   g.V.ifThenElse{it.out('hasCentre').filter{it == 
 aCentre}.hasNext()}{}{println ${it} has center unknown}
 
 If you have an index of your Users, then its more efficient to hit that 
 index, then iterate through all vertices (g.V). E.g.
 
   g.idx(T.v)[[type:'User']].ifThenElse
 
 Scenario 4:
 
 REFERRAL = PERSON
 
 I would like to combine a query that gets all Referrals that are 
 linked to a person and project a table result (contains referrals and 
 person property values (this is easy to do) However, I then want to do a 
 SPLIT query, that gets referrals without the persons, and then MERGE both 
 back into the table projection? So table projecton might look like this.
 I guess this is done with .table().it{}cap, but what I am not sure, is 
 how to do a split and merge in parallel and then get that merge projected 
 into the same table.
 
 
 I don't quite understand your problem, but here is an example of splitting 
 and merging.
 
   g.v(1).out('knows').copySplit(_().out('knows').name, 
 _().out('created').name).fairMerge
 
 This will get all the people that v[1] knows and then generate two parallel 
 pipeline. Each friend of v[1] is copied to each of the 2 parallel pipelines. 
 One pipeline will get their friend's names and one will get their created 
 project's names. It will then merge those two parallel pipelines into a 
 single stream. You can do either fairMerge or exhaustMerge depending on the 
 merging algorithm you want. fairMerge is more memory efficient. I need to 
 write more about split/merge in the Gremlin documentation.
 
   https://github.com/tinkerpop/gremlin/wiki/Split-Merge-Pattern -- will 
 work on it :)
 
 HTH,
 Marko.
 
 http://markorodriguez.com
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 Neo4j User Discussions group.
 To post to this group, send email to u...@neo4j.org.
 To unsubscribe from this group, send email to user+unsubscr...@neo4j.org.
 For more options, visit this group at 
 http://groups.google.com/a/neo4j.org/group/user/?hl=en.
 

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


Re: [Neo4j] Aggregates inside copySplit()

2011-12-05 Thread Marko Rodriguez
Hi,

 I had to use Aggregate here, instead of Store(), else the Except does not 
 work.

The except() does work, but you have you understand how it works with respects 
to the semantics of aggregate() and store().

store = lazily store objects in the pipeline to some collection x
aggregate = greedily aggregate objects in the pipeline to some 
collection x before moving onto the next step.

So, except's excepted collection will be growing over time. However, with 
aggregate(), its collection is stable as it has already been greedily filled. 
Get it?

 I am not sure if I can call _() an identityPipe, any inspiration here?


You mean between the two as()? Why not?

Enjoy,
Marko.

http://markorodriguez.com


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


Re: [Neo4j] Anyone try out the PageRank function on Gremlin?

2011-12-05 Thread Marko Rodriguez
Hi,

 Anyone try out the PageRank function on Gremlin?
 
 https://github.com/tinkerpop/gremlin/wiki/Working-with-JUNG-Algorithms/0506c193f30abe0bc18d40d7a08c9257d9311b13
 
 How does it perform with just under 100k nodes on a sparse graph (3000
 relationship max, average of 100)?
 
 I've been doing my pagerank via the power method in rb-gsl and while it's
 fine for around 10k items,  it's sucking all the memory on my server when
 trying to do 92k items.

Blueprints ( https://github.com/tinkerpop/blueprints/wiki/JUNG-Ouplementation ) 
implements the JUNG graph interface and thus, makes any Blueprints-enabled 
graph database into a JUNG graph. Unfortunately, JUNG was engineered from the 
perspective of in-memory use. As such, you will be running into memory issues 
on very large graphs. For example, if you have a 1million+ vertex graph and you 
are running PageRank on it, then your eigenvector vector is 1million+ entries. 
JUNG isn't serializing this vector to disk for you---its doing it all in 
memory. And if you don't have the memory to support a 1million+ vector (i.e. 
MapVertex,Double), then, well 

So, in short, be wary of doing memory intensive algorithms with JUNG (i.e. 
understand the intermediate data structures generated from the various 
supported graph algorithms). For non-memory intensive algorithms like shortest 
path, it should meet your needs. Into the future, TinkerPop will be filling out 
Furnace (http://furnace.tinkerpop.com) and this package will provide memory 
conscious implementations of classic and non-classical graph algorithms.

HTH,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Aggregates inside copySplit()

2011-12-05 Thread Marko Rodriguez
Hi Romiko,

 I am interested to learn more about the inner workings of Gremlin?

I would too! :P

This might help you out:
http://markorodriguez.com/2011/08/03/on-the-nature-of-pipes/

Marko.

http://markorodriguez.com

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


Re: [Neo4j] Unique constraint and transaction over REST

2011-12-05 Thread Marko Rodriguez
Hey,

Matt: This isn't related to this thread, but I noticed you are from Scholar.ly. 
I thought you might like this:

http://arxiv.org/abs/0905.1594

Go Canucks!,
Marko.

http://markorodriguez.com

On Dec 4, 2011, at 12:58 AM, Matt Luongo wrote:

 Well, I had already started writing this before I saw your response- so, if
 you do decide down the road that you care more about immediate performance
 than keeping DRY... ;)
 
g.setMaxBufferSize(0) //turn on tx handlings
g.startTransaction()
 
found = g.idx('node_auto_index')[[name:'uni...@example.com']].count()
if (found == 0) {
//other custom create code could go here, and/or have vars passed
 through json
results = g.addVertex([:])
} else {
results = g.idx('node_auto_index')[[name:'uni...@example.com
 ']].count().next()
}
 
g.stopTransaction(TransactionalGraph.Conclusion.SUCCESS)
g.setMaxBufferSize(1)
 
results
 
 would be something like the Groovy you'd use.
 
 I don't blame you for wanting to avoid the many choices available right now
 - I'm already generating Javascript for traversal pruning and templating
 Gremlin, all in the name of performance...
 
 --
 Matt Luongo
 Co-Founder, Scholr.ly
 
 
 
 On Sun, Dec 4, 2011 at 2:38 AM, dnagir dna...@gmail.com wrote:
 
 Thanks Matt.
 
 Yeah. I think the transaction API is in making. Would be great addition.
 
 The server-side plugin will definitely work, but I personally prefer to
 use one way of doing things. At least until I will start speaking neo4j
 natively :)
 
 Cheers,
 Dmytrii
 http://www.ApproachE.com
 
 
 On 04/12/2011, at 6:35 PM, mhluongo [via Neo4j Community Discussions]
 wrote:
 
 I've run into this problem, and resorted to using the Gremlin/Groovy over
 REST (via the server-included plugin).
 
 There really isn't a way to transactionally express a conditional (or
 get-or-create) like that over the vanilla REST API, though I'm sure it's
 in
 the works.
 
 --
 Matt Luongo
 Co-Founder, Scholr.ly
 
 
 
 On Thu, Dec 1, 2011 at 5:45 PM, dnagir [hidden email] wrote:
 
 Hi,
 
 I wonder what's the best way to do something similar to unique
 constraints
 in RDBMS.
 
 For example, user registration requires that the user's email to be
 unique.
 
 Working over in Ruby over REST API, how do you achieve this?
 
 I assume I need an auto-index on email property of User nodes. Then
 query
 it
 to check the property.
 
 But how can I make it transactional? So that I am sure that between
 querying
 and inserting the node, no similar has been inserted.
 
 The transactional part better applies to reservation instead of user
 creation. But you get the point.
 
 Cheers.
 
 --
 View this message in context:
 
 http://neo4j-community-discussions.438527.n3.nabble.com/Unique-constraint-and-transaction-over-REST-tp3553148p3553148.html
 Sent from the Neo4j Community Discussions mailing list archive at
 Nabble.com.
 ___
 Neo4j mailing list
 [hidden email]
 https://lists.neo4j.org/mailman/listinfo/user
 
 ___
 Neo4j mailing list
 [hidden email]
 https://lists.neo4j.org/mailman/listinfo/user
 
 
 If you reply to this email, your message will be added to the discussion
 below:
 
 http://neo4j-community-discussions.438527.n3.nabble.com/Unique-constraint-and-transaction-over-REST-tp3553148p3558628.html
 To unsubscribe from Unique constraint and transaction over REST, click
 here.
 NAML
 
 
 
 --
 View this message in context:
 http://neo4j-community-discussions.438527.n3.nabble.com/Unique-constraint-and-transaction-over-REST-tp3553148p3558630.html
 Sent from the Neo4j Community Discussions mailing list archive at
 Nabble.com.
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] [Neo4j-User] Re: Unique constraint and transaction over REST

2011-12-05 Thread Marko Rodriguez

 We have an alpha release coming up- would you be interested in seeing what
 we have?

Oh would I! Golly gee. 

:P,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Gremlin/Groovy UNIQUE + Closure support

2011-12-03 Thread Marko Rodriguez
Hi,

unique() is a Groovy construct, not a Gremlin construct. The Gremlin equivalent 
is uniqueObject(). And, in Gremlin 1.4, being released next week, its called 
dedup(). Gremlin constructs Pipelines in the backend (toString() an 
expression). If you drop out of pipeline construction by moving to a Groovy 
iterator method, then the pipeline is gone.

https://github.com/tinkerpop/gremlin/wiki/Gremlin-Steps 
(note that this is being updated for Gremlin 1.4 and a few 
names have changed)
(refer to the distribution /wiki for your versions steps)

HTH,
Marko.

http://markorodriguez.com

On Dec 2, 2011, at 9:13 PM, Romiko Derbynew wrote:

 Hi Guys,
 
 If I do a query with out.as(xyz)...out.unique()..out.tablecap I find that 
 the table projections for the closure do not work and I lose all AS 
 references.
 So to get closure support I do this
 
 Out.unique._().out..table
 
 The above sorts out the closure error, but then I lose my previous as 
 projections, is there a way to ensure _() preserves all my previous pipes and 
 placeholders?
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] Gremlin/Groovy UNIQUE + Closure support

2011-12-03 Thread Marko Rodriguez
Hi,

uniqueObject is in Gremlin 1.3 and below. The online docs are for Gremlin
1.4 and uniqueObject is now called dedup. To see the Gremlin 1.3
documentation, see the wiki/ directory of the distribution.

HTH,
Marko.

http://markorodriguez.com

On Dec 3, 2011 4:13 PM, Romiko Derbynew romiko.derby...@readify.net
wrote:

Hi Marko,

Thank you very much for this information, is it possible that the
documentation will include these gremlin methods, since on the
Gremlin-Steps page, I failed to notice any mention of UniqueObject()? I am
now updating the .NetClient asap :) Thank you once again!


-Original Message-
From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org]...
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Gremlin Query - Help

2011-12-02 Thread Marko Rodriguez
Hi,

 Scenario 1:
 I would like to get all Nodes that do not have a relationship to another 
 node. What is the best way to do this Gremlin?
 
 Root = NodeA = NodeB
 Root = NodeC
 
 Output should be NodeC

I don't understand the problem.

 Scenario 2:
 Root =  User - Centre
 
 I would like to get all centres for userA, and then get all users who are 
 also linked to the same centres of the userA

userA.out('hasCentre').in('hasCentre').except([userA])

 Scenario 3:
 User = Centre
 I would like to get all users that do not have a link to a Centre, and if 
 this is the case, do a projection that returns a fake centre with property 
 Unknown

g.V.ifThenElse{it.out('hasCentre').filter{it == 
aCentre}.hasNext()}{}{println ${it} has center unknown}

If you have an index of your Users, then its more efficient to hit that index, 
then iterate through all vertices (g.V). E.g.

g.idx(T.v)[[type:'User']].ifThenElse

 Scenario 4:
 
 REFERRAL = PERSON
 
 I would like to combine a query that gets all
 Referrals that are linked to a person and project a table result (contains 
 referrals and person property values (this is easy to do)
 However, I then want to do a SPLIT query, that gets referrals without the 
 persons, and then MERGE both back into the table projection? So table 
 projecton might look like this.
 I guess this is done with .table().it{}cap, but what I am not sure, is 
 how to do a split and merge in parallel and then get that merge projected 
 into the same table.


I don't quite understand your problem, but here is an example of splitting and 
merging.

g.v(1).out('knows').copySplit(_().out('knows').name, 
_().out('created').name).fairMerge

This will get all the people that v[1] knows and then generate two parallel 
pipeline. Each friend of v[1] is copied to each of the 2 parallel pipelines. 
One pipeline will get their friend's names and one will get their created 
project's names. It will then merge those two parallel pipelines into a single 
stream. You can do either fairMerge or exhaustMerge depending on the merging 
algorithm you want. fairMerge is more memory efficient. I need to write more 
about split/merge in the Gremlin documentation.

https://github.com/tinkerpop/gremlin/wiki/Split-Merge-Pattern -- will 
work on it :)

HTH,
Marko.

http://markorodriguez.com

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


Re: [Neo4j] New Bug Logged - Gremlin 114

2011-11-30 Thread Marko Rodriguez
Hi,

Please put this into the Gremlin issue tracker. 

https://github.com/tinkerpop/gremlin/issues

The table is not intended to be ordered with the location of the named as 
steps. It was just not engineered that way. However, others have brought this 
up. I suspect for Gremlin 1.5 (Gremlin 1.4 is being released soon), we can have 
the behavior ordered.

Thanks Romiko and Peter,
Marko.

http://markorodriguez.com

On Nov 30, 2011, at 1:20 AM, Peter Neubauer wrote:

 Thanks Romiko,
 will look into it first time when I have time. How critical is it for you?
 
 Cheers,
 
 /peter neubauer
 
 GTalk:  neubauer.peter
 Skype   peter.neubauer
 Phone   +46 704 106975
 LinkedIn   http://www.linkedin.com/in/neubauer
 Twitter  http://twitter.com/peterneubauer
 
 brew install neo4j  neo4j start
 heroku addons:add neo4j
 
 
 
 On Wed, Nov 30, 2011 at 1:31 AM, Romiko Derbynew
 romiko.derby...@readify.net wrote:
 Hi,
 
 New bugged logged at: https://github.com/neo4j/community/issues/114
 
 Details below for others to peruse.
 
 Gremlin Table Projections - Column Order Incorrect when using chained 
 .As('x').As('y')
 
 EXPECTED Order: Createdy, ReferralGroup, ReferralId, ReferralData
 
 When AS statements appear next to each other.
 Consider A (WORKS - But not logical - have to reverse order when more than 1 
 AS statement is chained together right after each other for column array to 
 match):
 {script:g.v(0).outE[[label:'HOSTS']].inV.filter{ it.Key == 'romikoagency' 
 }.inE[[label:'USER_BELONGS_TO']].outV.filter{ it.Username == 
 'romiko.derbynew' 
 }.as('CreatedBy').outE[[label:'USER_LINKED_TO_PROGRAM']].inV.as('ReferralGroup').inE[[label:'HAS_SUGGESTED_PROGRAM']].outV.inE[[label:'REFERRAL_HAS_DECISIONS_SECTION']].outV.as('ReferralDate').as('ReferralId').table(new
  Table()){it.Username}{it.Name}{it.UniqueId}{it.DateInitiatedUtc}.cap
 }
 
 notice: as('ReferralDate').as('ReferralId') and then notice the column order 
 below is opposite this: columns  ReferralId, ReferralDate ]
 
 Results
 [ [ {
 data : [ [ romiko.derbynew, Testa, 331, /Date(1322007153048+1100)/ 
 ], [ romiko.derbynew, Testa, 321, /Date(1322003375637+1100)/ ]],
 columns : [ CreatedBy, ReferralGroup, ReferralId, ReferralDate ]
 } ] ]
 
 
 Consider B (Does not work - this is more LOGICAL from gremlin perspective 
 but is bugged, the Chained AS right after each other gets reversed in the 
 column array.)
 {script:g.v(0).outE[[label:'HOSTS']].inV.filter{ it.Key == 'romikoagency' 
 }.inE[[label:'USER_BELONGS_TO']].outV.filter{ it.Username == 
 'romiko.derbynew' 
 }.as('CreatedBy').outE[[label:'USER_LINKED_TO_PROGRAM']].inV.as('ReferralGroup').inE[[label:'HAS_SUGGESTED_PROGRAM']].outV.inE[[label:'REFERRAL_HAS_DECISIONS_SECTION']].outV.as('ReferralId').as('ReferralDate').table(new
  Table()){it.Username}{it.Name}{it.UniqueId}{it.DateInitiatedUtc}.cap
 }
 
 Notice: .as('ReferralId').as('ReferralDate') and then the columns columns 
  ReferralDate, ReferralId ]
 
 Results
 [ [ {
 data : [ [ romiko.derbynew, Testa, 331, /Date(1322007153048+1100)/ 
 ]],
 columns : [ CreatedBy, ReferralGroup, ReferralDate, ReferralId ]
 } ] ]
 
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] New Bug Logged - Gremlin 114

2011-11-30 Thread Marko Rodriguez
Hi,

Actually, I know how to solve your problem. See below.

 g.v(0).outE[[label:'HOSTS']].inV.filter{ it.Key == 'romikoagency' 
 }.inE[[label:'USER_BELONGS_TO']].outV.filter{ it.Username == 
 'romiko.derbynew' 
 }.as('CreatedBy').outE[[label:'USER_LINKED_TO_PROGRAM']].inV.as('ReferralGroup').inE[[label:'HAS_SUGGESTED_PROGRAM']].outV.inE[[label:'REFERRAL_HAS_DECISIONS_SECTION']].outV.as('ReferralId').as('ReferralDate').table(new
  Table()){it.Username}{it.Name}{it.UniqueId}{it.DateInitiatedUtc}.cap

You can not do two as() steps in a row. Do a toString() on your Pipeline 
representation (e.g. cap.toString()). You will notice that your first as() 
step is wrapped by the second one. To rectify this, insert an identity. For 
example: as('ReferralId')._.as('ReferralDate').

Also, here are some optimizations to your expression that you might want to 
consider. The first and the third are to make it easier on the eyes (and a bit 
faster as well). The second is to make it faster.

outE[[label:'HOSTS']].inV   ---turn into-- 
 out('HOSTS')
filter{it.Key == 'romikoagency'}---turn into-- 
filter{it.getProperty('Key') == 'romikoagency'}
inE[[label:'USER_BELONGS_TO']].outV ---turn into-- 
in('USER_BELONGS_TO')

See: https://github.com/tinkerpop/gremlin/wiki/Gremlin-Groovy-Path-Optimizations

Enjoy!,
Marko.

http://markorodriguez.com

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


Re: [Neo4j] Securing scripting in the server

2011-11-28 Thread Marko Rodriguez
Hi Peter,

 Now, the question is if any of you has some experience tweaking the Java
 Security Manager to remove System.exit, File write permissions and other
 bad stuff from that code. Would love to see some examples of real-life
 securing JSR232 script engines. Or are there other mechanisms that work
 better than
 http://docs.oracle.com/javase/tutorial/essential/environment/security.htmlfor
 this type fo task?

Remember you, me, and Josh worked on LinkedProcess a few years back ( 
http://xmpp.org/extensions/inbox/lop.html ). Given that any random user on the 
web could execute arbitrary code on another users machines, we had to solve the 
security hole problem. In our Java-based reference implementation LoPSideD, 
we tweaked the JVM such that arbitrary JSR223 code does not violate particulate 
security constraints. See:


https://github.com/tinkerpop/tinkubator/blob/master/lopsided/lopsided-farm/sweden_countryside.properties

and...


https://github.com/tinkerpop/tinkubator/blob/master/lopsided/lopsided-farm/src/main/java/org/linkedprocess/farm/Farm.java#L189

...the full codebase is in the Tinkubator at this location:
https://github.com/tinkerpop/tinkubator/tree/master/lopsided

In short, I believe that this was all set at the thread-level -- ?? -- however, 
Josh was the one who did the work on security so you might want to ask him.

Hope that gives you some starting points,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Exporting Neo4j subgraphs to graphml/gexf....

2011-11-21 Thread Marko Rodriguez
Hi,

I added this to the StackOverflow discussion: 


http://stackoverflow.com/questions/2204440/convert-neo4j-db-to-xml/8214750#8214750

HTH,
Marko.

http://markorodriguez.com

On Nov 21, 2011, at 4:54 AM, Pablo Pareja wrote:

 Hi,
 
 I was wondering whether there's (or are any plans to implement) any way to
 export sub-graphs to graphml/gexf files?
 I did a quick google search and found this:
 
 http://stackoverflow.com/questions/2204440/convert-neo4j-db-to-xml
 
 However I think it'd be better being able to do this as part of Neo4j core
 API,  so that once you are situated in an specific node/relationship of the
 graph you could just export its neighborhood (specifying some parameters
 like depth) to one of these formats.
 Cheers,
 
 Pablo
 
 -- 
 Pablo Pareja Tobes
 
 My site http://about.me/pablopareja
 LinkedInhttp://www.linkedin.com/in/pabloparejatobes
 Twitter   http://www.twitter.com/pablopareja
 
 Creator of Bio4j -- http://www.bio4j.com
 
 http://www.ohnosequences.com
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] Gremlin Script broken in 1.5 GA

2011-11-19 Thread Marko Rodriguez
Hi,

With Gremlin 1.3, filter{} is required. No shorthands. Thus, outE{} needs
to be outE.filter{}. Moreover, you can now do out(label) or outE(label).

HTH,
Marko.

http://markorodriguez.com

On Nov 19, 2011 10:25 AM, Haensel thehaen...@gmail.com wrote:

Don't know if this is a bug or a feature, so here we go:

In 1.5.M01 I used a gremlin query to find edges like that:

 '{script:g.v(1).outE{it.label==\relationshipName\}}'

which now leads to a MissingMethod exception in 1.5 GA:

javax.script.ScriptException: groovy.lang.MissingMethodException: No
signature of method:
com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jVertex.outE() is applicable
for argument types: (Script16$_run_closure1) values:
[Script16$_run_closure1@7889fe65]\nPossible solutions:
outE([Ljava.lang.String;), out([Ljava.lang.String;), dump(),
use([Ljava.lang.Object;), both([Ljava.lang.String;),
inE([Ljava.lang.String;)

I got it working by changing the syntax to:

{script:g.v(1).outE(\relationshipName\)}

I don't know if this is intended or a bug so I wanted you guys to know about
it

Anyways, thanks for efforts ;)

Hannes

--
View this message in context:
http://neo4j-community-discussions.438527.n3.nabble.com/Gremlin-Script-broken-in-1-5-GA-tp3521258p3521258.html
Sent from the Neo4j Community Discussions mailing list archive at
Nabble.com.
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Max flow using gremlin

2011-11-18 Thread Marko Rodriguez
Hi,

 has anyone implemented any of the max flow algorithms using gremlin?

Most of the algorithms in my toolbox are flow-based algorithms. What in 
particular are you trying to do?

Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Max flow using gremlin

2011-11-18 Thread Marko Rodriguez
Hey,

Perhaps the simplist way to explore flow is to simply get the paths between 
source and sink and then calculate some function f over the path to determine 
its flow. For example:

def f = { List path -
// some function over the path where every other element is an 
edge (see traversal below)
}

source.outE.inV.loop(2){it.object.equals(sink)}.paths.each{
println(it +  has a flow of  + f(it))
}

This assumes you have a determined source and a determined sink and that there 
are no cycles in your gas pipeline. If there are cycles, then you can tweak the 
expression to make sure you break out of the loop when appropriate.

From this basic idea you can then tweak it to simulate decay over time/step or 
implement random walks through the gasline if you are interested in sampling 
or studying local eigenvectors in the pipeline.

Hope that provides you a good starting point.

Enjoy!,
Marko

http://markorodriguez.com

On Nov 18, 2011, at 1:20 PM, Alfredas Chmieliauskas wrote:

 Hey Marko,
 
 I'm modeling the european gas transport/pipeline network. I need to
 have a good way to calculate maximum flow from source to sink and get
 the nodes in the path .
 
 Alfredas
 
 On Fri, Nov 18, 2011 at 2:48 PM, Marko Rodriguez okramma...@gmail.com wrote:
 Hi,
 
 has anyone implemented any of the max flow algorithms using gremlin?
 
 Most of the algorithms in my toolbox are flow-based algorithms. What in 
 particular are you trying to do?
 
 Marko.
 
 http://markorodriguez.com
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] Max flow using gremlin

2011-11-18 Thread Marko Rodriguez
 This seems to calculate the max flow (edges have capacity):
 
 source.outE.inV.loop(2){!it.object.equals(sink)}.paths.each{flow =
 it.capacity.min(); maxFlow += flow;
 it.findAll{it.capacity}.each{it.capacity -= flow}};
 
 I can't believe this is so short!

Thats the beauty of Gremlin. Once you get it, you can rip some very complex 
traversals in just a few characters. 

NOTES: For speed, make it.capacity - it.getProperty('capacity')
Some good notes here: 
https://github.com/tinkerpop/gremlin/wiki/Gremlin-Groovy-Path-Optimizations

Glad we could help you with your problem. 

Enjoy!,
Marko.

http://markorodriguez.com

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


Re: [Neo4j] Neo4j-Scala Wrapper 0.1.0 released

2011-11-17 Thread Marko Rodriguez
Hey,

It might be a little too soon to bring it up, but early December, we are 
releasing Gremlin Scala in Gremlin 1.4 which will allow you to import Gremlin 
into your Scala project (e.g. Neo4j-Scala Wrapper) and evaluate Gremlin queries 
natively. 

https://github.com/tinkerpop/gremlin/tree/master/gremlin-scala

For example, in Gremlin Scala:

g.v(1).out(knows).out(created).filter{v:Vertex = 
v(name).equals(marko)}

This way Scala developers can use Gremlin-style traversing natively in their 
Scala code.

See ya,
Marko.

http://markorodriguez.com

On Nov 17, 2011, at 5:21 AM, Christopher Schmidt wrote:

 Peter, I think its not possible because [ and ] are reserved for Scalas
 type declarations.
 The String (fe. KNOWS) is implicitly converted
 into DynamicRelationshipType.withName(KNOWS).
 
 What would be possible to get something like this (which is actually just a
 change of method names):
 
 start - KNOWS - end
 
 Regarding the Cypher language:
 Its an interpreted language, so it is possible to define a completely free
 syntax. In case of Scala, all we are doing has to be fit into the language
 syntax, although it looks like a freely designed DSL. Cypher has some
 similarities to SQL as a special query language. And to be honest, I think
 using it programmatically will cause the same symtoms as SQL with respect
 to runtime errors, type safety, abstraction etc.
 
 Nevertheless, it would be interesting to create a nearly Cypher compilable
 DSL, which includes type safety and transparent DAO or Case Class mapping.
 Something like:
 
 case class User(name:String)
 val nodes = createNode(User(name1)) :: createNode(User(name2))
 :: createNode(User(name3)) :: Nil
 . . .
 for (f - START nodes MATCH user-friend-follower WHERE follower.name =~
 /S.*/ RETURN follower)
   println(User Follower:  + f.name)
 
 
 This would be basically the same idea JPA tries with its criteria api. But
 that will be hard work :-)
 
 Christopher
 
 On Wednesday, November 16, 2011, Peter Neubauer wrote:
 
 Chstopher,
 this looks really cool! I notice the similarity to the cypher syntax
 in the ASCII art part of the notation. Do you think there is a chance
 to make it even more similar to that so you could actually write
 
 start -[:KNOWS]- intermediary - [KNOWS] - end
 
 instead of
 
 start -- KNOWS -- intermediary -- KNOWS -- end ? Would be
 quite cool to be closely in line with
 http://docs.neo4j.org/chunked/snapshot/cypher-query-lang.html, maybe
 we could even use this for a modifying cypher in the future ...
 
 Cheers,
 
 /peter neubauer
 
 GTalk:  neubauer.peter
 Skype   peter.neubauer
 Phone   +46 704 106975
 LinkedIn   http://www.linkedin.com/in/neubauer
 Twitter  http://twitter.com/peterneubauer
 
 http://www.neo4j.org  - NOSQL for the Enterprise.
 http://startupbootcamp.org/- Öresund - Innovation happens HERE.
 
 
 
 On Wed, Nov 16, 2011 at 6:36 AM, Christopher Schmidt
 fakod...@googlemail.com wrote:
 Hi all,
 
 I released version 0.1.0 of the Neo4j Scala Wrapper neo4j-scala (base is
 neo4j-scala by jawher).
 Main features are
 
 - simple Traits for the wrapper itself, GraphDatabaseService provider,
 index provider and batch insertion
 - transaction wrapping:
 
 withTx {...}
 
 - natural usage of relations:
 
 start -- KNOWS -- intermediary -- KNOWS -- end
 
 - setting and getting properties:
 
 node(foo) = bar
 node[String](foo) match {
   case Some(x) = println(x)
   case None = println(aww)
 }
 
 - easy CaseClass to/from Node/Relation properties marshaling
 
 withTx {
 implicit neo =
   // create new Node with Case Class Test
   val node1 = createNode(Test(Something, 1, 2, 3.3, 10, true))
 
   // or using Option[T] (returning Some[T] if possible)
   val nodeOption: Option[Test] = node.toCC[Test]
 
   // create new relation with Case Class Test
   node1 -- foo -- node2  Test(other, 0, 1, 1.3, 1, false)
 }
 
 - transparent batch processing (simply replace 2 traits to use the same
 code for batch- and non batch processing)
 
 For now I am using a simple Github Maven repository.
 Neo4j-scala should be usable with the following POM settings:
   repositories
 repository
   idfakod-releases/id
   urlhttps://raw.github.com/FaKod/fakod-mvn-repo/master/releases
 /url
 /repository
   /repositories
 
   dependencies
 dependency
   groupIdorg.neo4j/groupId
   artifactIdneo4j-scala/artifactId
   version0.1.0/version
 /dependency
   /dependencies
 
 The Sources are hosted on Github:
 
 https://github.com/FaKod/neo4j-scala/tree/0.1.0
 
 
 A simple Matrix example GIST is here:
 
 https://gist.github.com/1331556
 
 
 Enjoy...
 
 
 PS: Maybe you are using Neo4j Server via Jersey? So sjersey-client may be
 interesting for you as well: see @
 Githubhttps://github.com/FaKod/sjersey-client/tree/0.1.0 and
 this example https://gist.github.com/1366334.
 
 --
 Christopher
 twitter: @fakod
 blog: http://blog.fakod.eu
 
 
 
 --
 Christopher
 twitter: @fakod
 blog: 

Re: [Neo4j] Gremlin plugin and script engine question

2011-11-17 Thread Marko Rodriguez
Hey Alfredas,

Be sure to iterate your pipeline

x = []; g.v(1).out(from).out(to).aggregate(x).loop(3){it.loops  
4}.iterate(); x

* NOTE: You can also do:
g.v(1).out(from).out(to).aggregate(x).loop(3){it.loops  4} -1
   but the  convention is no longer with us in Gremlin 1.4-SNAPSHOT.

HTH,
Marko.

http://markorodriguez.com

On Nov 17, 2011, at 7:21 AM, Alfredas Chmieliauskas wrote:

 Dear all,
 This concerns gremlin plugin and the script engine.
 Maybe there's an explanation for this behavior:
 1) gremlin x = [];
 g.v(1).out(from).out(to).aggregate(x).loop(3){it.loops  4};
 gremlin x;
 
 == v[7]
 == v[3]
 == v[5]
 
 2) gremlin x = [];
 g.v(1).out(from).out(to).aggregate(x).loop(3){it.loops  4}; x;
 returns nothing...
 
 Thanks,
 
 Alfredas
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] Gremlin plugin and script engine question

2011-11-17 Thread Marko Rodriguez
 What exactly does iterate() do?

A Gremlin expression yields a Pipeline and
PipelineS,E implements IteratorS,E

Thus, a Gremlin expression doesn't return the results of a traversal, only a 
lazy iterator for .next()'ing results. For people doing a traversal to yield a 
sideEffect (e.g. aggregate, groupCount, etc.), iterate() is there to 
while(hasNext()) { next() } for you to fill up your side effect data 
structure.

Finally, the Gremlin REPL automagically iterates and System.out.printlns() any 
objects in an Iterator it gets so thats why the behavior in the Gremlin REPL 
looks like a Gremlin expression returns results.

Hope that is clear,
Marko.

http://markorodriguez.com

 A
 
 On Thu, Nov 17, 2011 at 4:07 PM, Marko Rodriguez okramma...@gmail.com wrote:
 Hey Alfredas,
 
 Be sure to iterate your pipeline
 
x = []; g.v(1).out(from).out(to).aggregate(x).loop(3){it.loops  
 4}.iterate(); x
 
 * NOTE: You can also do:
g.v(1).out(from).out(to).aggregate(x).loop(3){it.loops  4} -1
   but the  convention is no longer with us in Gremlin 1.4-SNAPSHOT.
 
 HTH,
 Marko.
 
 http://markorodriguez.com
 
 On Nov 17, 2011, at 7:21 AM, Alfredas Chmieliauskas wrote:
 
 Dear all,
 This concerns gremlin plugin and the script engine.
 Maybe there's an explanation for this behavior:
 1) gremlin x = [];
 g.v(1).out(from).out(to).aggregate(x).loop(3){it.loops  4};
 gremlin x;
 
 == v[7]
 == v[3]
 == v[5]
 
 2) gremlin x = [];
 g.v(1).out(from).out(to).aggregate(x).loop(3){it.loops  4}; x;
 returns nothing...
 
 Thanks,
 
 Alfredas
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] why g.V[6].both is not returning any thing

2011-11-16 Thread Marko Rodriguez
Hi,

...or it means that g.V[6] isn't connected to anything. Do this:

v = g.V[6].next()
v.both
v.map()

That will tell you if the 6th vertex of V is connected and if it has properties.

Marko.

http://markorodriguez.com

On Nov 16, 2011, at 4:28 AM, Peter Neubauer wrote:

 Rahul,
 this probably is an effect of getting a pipe back, that you explicitly
 need to empty in order to be able to see anything (try g.V[6]  -1),
 which the console and REST endpoints are doing automatically for you.
 
 Could you try that?
 
 Cheers,
 
 /peter neubauer
 
 GTalk:  neubauer.peter
 Skype   peter.neubauer
 Phone   +46 704 106975
 LinkedIn   http://www.linkedin.com/in/neubauer
 Twitter  http://twitter.com/peterneubauer
 
 http://www.neo4j.org  - NOSQL for the Enterprise.
 http://startupbootcamp.org/- Öresund - Innovation happens HERE.
 
 
 
 On Wed, Nov 16, 2011 at 11:56 AM, Rahul Mehta rahul23134...@gmail.com wrote:
 by neo4j console and also with gremlin
 
 On Wed, Nov 16, 2011 at 4:23 PM, Peter Neubauer
 peter.neuba...@neotechnology.com wrote:
 
 Rahul,
 are you using neo4j.rb or Gremlin/Pacer here?
 
 Cheers,
 
 /peter neubauer
 
 GTalk:  neubauer.peter
 Skype   peter.neubauer
 Phone   +46 704 106975
 LinkedIn   http://www.linkedin.com/in/neubauer
 Twitter  http://twitter.com/peterneubauer
 
 http://www.neo4j.org  - NOSQL for the Enterprise.
 http://startupbootcamp.org/- Öresund - Innovation happens HERE.
 
 
 
 On Wed, Nov 16, 2011 at 11:49 AM, Rahul Mehta rahul23134...@gmail.com
 wrote:
 using neo4j:
 
 when m doing :
 
 g.E
 == e[1][1-follow-6]
 == e[4][5-follow-6]
 == e[3][7-follow-6]
 == e[5][8-follow-6]
 
 g.V
 == v[0]
 == v[1]
 == v[5]
 == v[6]
 == v[7]
 == v[8]
 but when m doing g.V[6].both is returning nothing please tell why ?
 
 also when m doing g.V[6].map it is not returning anything but when i
 see from admin and it shows and while g.V.map then also it shows
 
 --
 You received this message because you are subscribed to the Google
 Groups neo4jrb group.
 To post to this group, send email to neo4...@googlegroups.com.
 To unsubscribe from this group, send email to
 neo4jrb+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/neo4jrb?hl=en.
 
 
 
 --
 You received this message because you are subscribed to the Google Groups
 neo4jrb group.
 To post to this group, send email to neo4...@googlegroups.com.
 To unsubscribe from this group, send email to
 neo4jrb+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/neo4jrb?hl=en.
 
 
 
 
 --
 Thanks  Regards
 
 Rahul Mehta
 
 
 
 --
 You received this message because you are subscribed to the Google Groups
 neo4jrb group.
 To post to this group, send email to neo4...@googlegroups.com.
 To unsubscribe from this group, send email to
 neo4jrb+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/neo4jrb?hl=en.
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] Simple paging question - Gremlin

2011-11-14 Thread Marko Rodriguez
Hey Kevin,

 g.v(293).in.drop(5).take(5)
 
 and
 
 g.v(293).in[5..9]
 
 (Both return the same, correct result set)
 I will be doing some performance tests today on the two, but last week when
 I tried them both on fairly heavy queries, the second method seemed faster
 (I only say seemed, because I'm hesitant to draw conclusions before I've
 properly measured the times)

I've never seen drop() and take() until I saw Peter do it in the Gremlin 
documentation. I do not recommend using any of Groovy's collection methods 
because they tend to NOT be lazy. The range filter [5..9] is native Gremlin and 
lazy/stream-based without intermediate collection construction.

In general, do not use:
collect{}
each{}
drop()/take()
...

Gremlin will have its own lazy version of such constructs and those should be 
used.

Enjoy,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Neo4J for semantic graphs + algorithms

2011-11-14 Thread Marko Rodriguez
Hello,

 Any information to load OWL specifications into Neo4J or guidance to design
 algorithms (managment of temporary data is the blocking point)?

When you use the OpenRDF SAIL bindings provided by TinkerPop, you will be able 
to use OpenRDF's OWL reasoners and other tools. Basically, the stack looks like 
this:

OpenRDF Sail  TinkerPop GraphSail --- Neo4j

1. OpenRDF Sail is a tool set for working with various aspects of RDF. It is 
large, heavily developed on, and a standard in the RDF community.
2. TinkerPop GraphSail provides a way to turn any graph database (e.g. Neo4j) 
into an RDF triple/quad store.
3. Neo4j is a graph database.

Hope that helps,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Gremlin - how to flatten a tree, and sort

2011-11-10 Thread Marko Rodriguez
Hi,

 I've been trying that query out (slightly modified now to return all nodes
 of a different kind, but attached to a node in the first set), on a data set
 of around 100K, and I'm getting an OutOfMemoryError:
 {
  message : GC overhead limit exceeded,
  exception : java.lang.OutOfMemoryError: GC overhead limit exceeded,
  stacktrace : [ ]
 }
 
 My request (for gremlin over REST) is:
 script: m = [:]; g.v(id).in('R_PartOf').loop(1){m.put(it.object,
 it.loops); true}  -1; m.sort{a,b - a.value =
 b.value}.keySet()._().in('R_OtherEdge'),
  params: 
  {
id: 284
  }

You have the following data structures consuming memory:
1. m
2. m sorted
3. the keyset of m

Perhaps those are sufficiently large to blow our your memory. Perhaps test by, 
for example, not getting keySet or not sorting.

When I do large Map-based computations in Gremlin, I use JDBM2 as my map data 
structure as its persistent and when it overflows memory, its written to disk.

http://code.google.com/p/jdbm2/

HTH,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Wrong Gremlin results through REST interface

2011-11-08 Thread Marko Rodriguez
Hey,

To expand on Peter's point. I suspect people are mixing versions of Gremlin. 
Gremlin is generally (not usually) backwards compatible from version to 
version. If you are using Gremlin REPL, GremlinPlugin, and Gremlin from Neo4j 
WebAdmin, its good to make sure you have the same version of Gremlin in 
instances. Here is how you check:

GremlinTokens.VERSION 
(for old skool Gremlin)
Gremlin.version()   
(for new skool Gremlin)

If your versions are not consistent then this may be the reason why you're 
traversals in Gremlin REPL are working, but not in Gremlin Plugin (for example).

HTH,
Marko.

http://markorodriguez.com

On Nov 8, 2011, at 8:52 AM, Peter Neubauer wrote:

 Hi all (and Romiko),
 it might be that this issue, as Romikos, is confusion about the use of
 the {}. In Gremlin 1.3, you have to explicitly use filter{} in order
 to do this, see https://github.com/neo4j/gremlin-plugin/issues/3 for
 an example.
 
 I have locally comitted a documentation example for this, but I am
 waiting for the release to finish before pushing it. Could you try
 this?
 
 Cheers,
 
 /peter neubauer
 
 GTalk:  neubauer.peter
 Skype   peter.neubauer
 Phone   +46 704 106975
 LinkedIn   http://www.linkedin.com/in/neubauer
 Twitter  http://twitter.com/peterneubauer
 
 http://www.neo4j.org  - NOSQL for the Enterprise.
 http://startupbootcamp.org/- Öresund - Innovation happens HERE.
 
 
 
 On Tue, Nov 8, 2011 at 11:43 AM, Peter Neubauer
 peter.neuba...@neotechnology.com wrote:
 Yup,
 I have at least Tathams issue to start with. Will report back and see if it
 solves this one too. Feel free to add this example to the issue on the
 Gremlin plugin.
 
 On Nov 8, 2011 12:32 PM, Michael Hunger michael.hun...@neotechnology.com
 wrote:
 
 There are some weird things going on. Probably have to do with
 javax.script.ScriptEngine.eval()
 
 We should investigate this thoroughly.
 
 Perhaps Peter and Marko can spend some cycles on it.
 
 Michael
 
 1) behaviour native gremlin vs
 2) Neo4j web console vs.
 3) REST-calls
 
 Am 08.11.2011 um 12:02 schrieb Jeroen van Dijk:
 
 HI Michael,
 
 Thanks for this solution. The webconsole now gives me the right results
 also for recommendation query. There is however still something weird
 when
 I use this recommendation query in the gremlin console:
 
 gremlin node = g.v(14260); m = [:].withDefault{0.0}; a_total =
 node.inE().count(); node.in().out('owns').sideEffect{union = a_total +
 it.inE().count()}.groupCount(m) { it : it += (1.0/(union)) }  -1;
 m.sort{a,b - b.value = a.value}[0..9]
 No signature of method:
 com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jVertex.plus() is
 applicable
 for argument types: (java.math.BigDecimal) values: [0.0303030303]
 Possible solutions: values(), keys(), use([Ljava.lang.Object;),
 values(java.lang.Object), is(java.lang.Object),
 split(groovy.lang.Closure)
 
 The weird thing is that exact same query does work in the webconsole..
 
 Consider my issue solved though. Thanks a lot.
 
 Jeroen
 
 On Mon, Nov 7, 2011 at 1:25 PM, Michael Hunger 
 michael.hun...@neotechnology.com wrote:
 
 Jeroen,
 
 could you try to use the alternative syntax:
 
 ... groupCount(m) { it : it += 0.1 } ...
 
 It seems to be a problem with evaluation of the string in the
 javax.ScriptEngine for Groovy
 
 Here is the output from my web-console:
   • gremlin m = [:];g.v(33).bothE().label.groupCount(m) { it }{ it
 += 0.1 }  -1;m
   • == follows=11
   • == owns=48
   • gremlin m = [:];g.v(33).bothE().label.groupCount(m) { it : it
 +=
 0.1 }  -1;m
   • == follows=1.1
   • == owns=4.8
 
 Michael
 
 Am 07.11.2011 um 12:55 schrieb Jeroen van Dijk:
 
 Ok i think I found an example that is independent of my data (adapted
 from
 http://docs.neo4j.org/chunked/snapshot/gremlin-plugin.html)
 
 Locally:
 gremlin m = [:];g.v(33).bothE().label.groupCount(m)  -1;m
 
 ==follows=11
 ==owns=48
 gremlin m = [:];g.v(33).bothE().label.groupCount(m) { it }{ it += 0.1
 }
 
 -1;m
 ==follows=1.1
 ==owns=4.8
 
 REST/webadmin console:
 gremlin m = [:];g.v(33).bothE().label.groupCount(m) { it }{ it += 0.1
 }
 
 -1;m
 == follows=11
 == owns=48
 gremlin m = [:];g.v(33).bothE().label.groupCount(m) { it }{ it += 10
 }
 
 -1;m
 == follows=11
 == owns=48
 gremlin
 
 It seems like the closure block is not evaluated (to me as a
 Groovy/Gremlin/Neo4j noob)
 
 Michael, I will send you a link to my database in private.
 
 Thanks,
 Jeroen
 
 
 
 On Mon, Nov 7, 2011 at 12:41 PM, Michael Hunger 
 michael.hun...@neotechnology.com wrote:
 
 Jeroen,
 
 that would indeed help a lot.
 I'll find it.
 
 Michael
 
 Am 07.11.2011 um 12:34 schrieb Jeroen van Dijk:
 
 Hi Michael,
 
 I would like to provide a better example, but my Groovy is quite
 poor
 so
 it
 I'll take me some time. However I think the problem isn't in the
 JSON
 conversion. Because that would mean the results I get would be the
 same,
 but with a different score 

Re: [Neo4j] Ontology in Neo4J REST db

2011-11-08 Thread Marko Rodriguez
Hi,

 Anybody knows how to use OWLAPI or any API that can parse and handle these 
 information of a class definition and store them into the Neo4J db?

I am not familiar with OWLAPI, but for RDF/RDFS/OWL work, I use GraphSail over 
Neo4j.
https://github.com/tinkerpop/blueprints/wiki/Sail-Ouplementation

With a Sail representation of your Neo4j graph, you can then make use of all 
the tools that work over Sail. See http://openrdf.org ...

Good luck,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Gremlin - how to flatten a tree, and sort

2011-11-07 Thread Marko Rodriguez
Hey,

 I've played around a bit more, and this is the query that currently works
 best for me... would anyone mind reviewing it for me please? Feels a
 little like I'm getting the right answer, but the wrong way
 gremlin m = [:];
 gremlin g.v(162).in('R_PartOf').loop(1){m.put(it.object, it.loops); true}
 gremlin m.sort{a - a.value}._()
 
 And, that sort tripped me up a few times :)

Everything looks good except your m.sort{}, which should be something like this:

m.sort{a,b - a.value = b.value}

The provided closure is a comparator. For a java.util.Map, the comparison is 
happening between two Map.Entry objects. Thus, your sort needs two inputs (a,b) 
and then the value of those Entry objects is a.value and b.value, respectively.

Hope that is clear.

*** Also, note that if you don't want to see output from your g.v(162)... 
expression, simply do  -1 as it will while(expr.hasNext()) and thus, fill the 
map without burdensome System.out.println()s. ***

Enjoy,
Marko.

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


Re: [Neo4j] Gremlig Plugin - Paramerterised Queries + Enumeration - Neo4j 1.5M02

2011-11-07 Thread Marko Rodriguez
Hey,

 I can confirm that the gremlin query works in the Console but not in the REST 
 API.
 Console Working:
 gremlin g.v(0).outE[[label:'HOSTS']].inV{ it['UniqueId'] == 11761 
 }.drop(0).take(100)._()
 == v[756]
 
 I will log a bug issue on this: 
 https://github.com/neo4j/gremlin-plugin/issues/3


I notice you are using an old version of Gremlin. I believe you are using 1.1 
or less?

If you move to 1.2+, the faster representation of your query is:

g.v(0).out('HOSTS').filter{it.getProperty('UniqueId') == 11761}

Enjoy,
Marko.
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Gremlin - how to flatten a tree, and sort

2011-11-04 Thread Marko Rodriguez
Hi,

I would do it like this:

m = [:]
g.v(162).in('R_PartOf').loop(1){m.put(it.object, it.loops); true}  -1
m.sort{a, b - a.value = b.value}.keySet as List

In short, fill up a Map (m) with key being the vertex and value being the 
number of hops (or times through the loop). Then sort the map by the number 
of times through the loop and return the keySet. Since you wanted a List (not a 
Set), then as List the Set result.

HTH,
Marko.

http://markorodriguez.com

On Nov 4, 2011, at 10:25 AM, baldric wrote:

 I'm very new to much of this, and have a particularly ingrained relational
 slant to my career, unfortunately.
 I'm in the process of doing a proof of concept for a product, using neo4j,
 and gremlin over REST (we're developing in c#) What I'm trying to do at the
 moment is load a graph (representing a sort of flexible taxonomy), into a
 flattened list. So, given a starting node, find all associated nodes across
 a particular relationship type, no matter how far away. I will ultimately
 need this in a list, and I want the list sorted by how far away each node is
 (am I correct in referring to this as hops?)
 Anyway, my best attempt at the unsorted query so far looks something like
 this: (by the way, the unique part worries me a little)
 
 x = []; g.v(162).in('R_PartOf').aggregate(x).loop(2){true}  -1; x.unique()
 
 (Please try not to laugh too much! :) )
 
 How would I alter this to ensure it is sorted by distance from starting
 node?
 
 Thanks in advance!
 
 --
 View this message in context: 
 http://neo4j-community-discussions.438527.n3.nabble.com/Gremlin-how-to-flatten-a-tree-and-sort-tp3480586p3480586.html
 Sent from the Neo4j Community Discussions mailing list archive at Nabble.com.
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] Gremlin - how to flatten a tree, and sort

2011-11-04 Thread Marko Rodriguez
Sure:

m = [:]; g.v(162).in('R_PartOf').loop(1){m.put(it.object, it.loops); 
true}.cap.next().sort{a, b - a.value = b.value}.keySet  []

Marko.

http://markorodriguez.com

On Nov 4, 2011, at 12:17 PM, Peter Neubauer wrote:

 Can you do it on one line? ;)
 
 Great stuff.
 
 Cheers,
 
 /peter neubauer
 
 GTalk:  neubauer.peter
 Skype   peter.neubauer
 Phone   +46 704 106975
 LinkedIn   http://www.linkedin.com/in/neubauer
 Twitter  http://twitter.com/peterneubauer
 
 http://www.neo4j.org  - NOSQL for the Enterprise.
 http://startupbootcamp.org/- Öresund - Innovation happens HERE.
 
 
 
 On Fri, Nov 4, 2011 at 11:12 AM, Marko Rodriguez okramma...@gmail.com wrote:
 Hi,
 
 I would do it like this:
 
 m = [:]
 g.v(162).in('R_PartOf').loop(1){m.put(it.object, it.loops); true}  -1
 m.sort{a, b - a.value = b.value}.keySet as List
 
 In short, fill up a Map (m) with key being the vertex and value being the 
 number of hops (or times through the loop). Then sort the map by the 
 number of times through the loop and return the keySet. Since you wanted a 
 List (not a Set), then as List the Set result.
 
 HTH,
 Marko.
 
 http://markorodriguez.com
 
 On Nov 4, 2011, at 10:25 AM, baldric wrote:
 
 I'm very new to much of this, and have a particularly ingrained relational
 slant to my career, unfortunately.
 I'm in the process of doing a proof of concept for a product, using neo4j,
 and gremlin over REST (we're developing in c#) What I'm trying to do at the
 moment is load a graph (representing a sort of flexible taxonomy), into a
 flattened list. So, given a starting node, find all associated nodes across
 a particular relationship type, no matter how far away. I will ultimately
 need this in a list, and I want the list sorted by how far away each node is
 (am I correct in referring to this as hops?)
 Anyway, my best attempt at the unsorted query so far looks something like
 this: (by the way, the unique part worries me a little)
 
 x = []; g.v(162).in('R_PartOf').aggregate(x).loop(2){true}  -1; x.unique()
 
 (Please try not to laugh too much! :) )
 
 How would I alter this to ensure it is sorted by distance from starting
 node?
 
 Thanks in advance!
 
 --
 View this message in context: 
 http://neo4j-community-discussions.438527.n3.nabble.com/Gremlin-how-to-flatten-a-tree-and-sort-tp3480586p3480586.html
 Sent from the Neo4j Community Discussions mailing list archive at 
 Nabble.com.
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] Gremlin - how to flatten a tree, and sort

2011-11-04 Thread Marko Rodriguez
Hi,

 Thanks! I will still need to try this out, but the idea (in your first
 response) kind of feels more or less like what I knew I needed. I have so
 many questions now based on the responses so far - it feels like I'm just
 scratching the surface!

Once you get it, you can get nasty with Gremlin. And I'm saying nasty with 
a South African accent so you know its dirty.

 Firstly, could you explain the differences between map, list, and set?

Map = java.util.Map
List = java.util.List
Set = java.util.Set 

Google them.

 Secondly, when you reduced it to a single line, you implemented cap and
 next I've seen these mentioned before, but don't really get it...

'cap' is a bit advanced and requires some knowledge of the theory of 
Gremlin/Pipes. Here is an explanation. Some steps in Gremlin are called 
sideEffects because they have an internal data structure that they are 
manipulating. groupCount is one such sideEffect step. Internal to groupCount is 
a map (m) -- updating that map is the side-effect of groupCount. If you cap a 
sideEffect pipe you are saying:

Don't output what the input is, while(next) the input and when that is 
drained, output the internal side-effect data structure.

http://tinkerpop.com/maven2/com/tinkerpop/pipes/0.8/api/com/tinkerpop/pipes/transform/SideEffectCapPipe.html

Thus, with ...step.step.groupCount(m).cap you are yielding the internal map of 
groupCount (m), not the output from the previous step. It is a useful technique 
when you want to insert the side-effect of groupCount (its map) into the data 
stream. Finally, all Gremlin expressions are Iterators, so next() just returns 
the next thing in the stream which is the map we just got from cap.

Generally, if you are new to Gremlin, don't try and do massive one-liners. I 
was just trying to show off cause Peter egged me on.

HTH,
Marko.

http://markorodriguez.com 
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] some questions

2011-10-28 Thread Marko Rodriguez
Hi,

 2. Assume I have a big graph in the REST server, what is the best way to 
 remove the whole graph? Of course deleting each node and its relationships 
 and its index is not convenient.


Via Gremlin Plugin, you can call g.clear().

HTH,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Gremlin help

2011-10-25 Thread Marko Rodriguez
Hi,

Note that with Blueprints 1.0, you do not have to deal with a commit manager. 
You can do:

graph.setTransactionBufferSize(50);

...and then simply do your traversal. No manager.incrCount() needed. I believe 
the latest Neo4j release uses Gremlin 1.3 and Blueprints 1.0. ?? Peter?

Take care,
Marko.

http://markorodriguez.com

On Oct 25, 2011, at 12:43 PM, Nuo Yan wrote:

 For the record, in case someone else has similar need, I came up with the
 following query that does what I described in the last email below (still on
 gremlin 1.2 so still using Commit Manager):
 
 manager = TransactionalGraphHelper.createCommitManager(g, 50);
 g.v(1).out('foo').transform{[it, it.name,
 it.outE('bar').count()]}.aggregate().cap.next().groupBy{it[1]}.each{key,value
 - value.sort{a,b - b[2] = a[2]}.eachWithIndex{a,i - if(i  0)
 {g.removeVertex(a[0]); manager.incrCounter()}}}
 manager.close();
 
 After going through this I got a lot better understanding in Gremlin. Thanks
 Peter and Marko.
 
 
 On Sat, Oct 22, 2011 at 6:04 PM, Nuo Yan yan@gmail.com wrote:
 
 Thanks very much Marko. I researched the query one step at a time and
 gained much more knowledge about gremlin.
 
 However, I wanted to do something a little bit different, instead of
 comparing the name property of the children nodes to the source node, I
 wanted to compare among the siblings of the children nodes (only first level
 under the source node) and if there are duplicates, only keep the one with
 the biggest degree of bar relationship. (The source node doesn't have a
 name property).
 
 For example,
 
 v(1) --foo-- v(2) name: abc --bar-- (15 nodes)
 v(1) --foo-- v(3) name: abc --bar -- (20 nodes)
 v(1) --foo-- v(4) name xyz --bar-- (15 nodes)
 v(1) --foo-- v(5) name xyz --bar-- (25 nodes)
 
 would become:
 
 v(1) --foo-- v(3) name: abc --bar -- (20 nodes)
 v(1) --foo-- v(5) name xyz --bar-- (25 nodes)
 
 So instead of doing
 
 
 g.v(1).sideEffect{x =
 it.getProperty('name')}.out('foo').filter{it.getProperty('name').equals(x)}
 
 I proposed doing:
 
 g.v(1).out(foo).transform{[it, it.name,
 it.out(bar).count]}.aggregate.cap
 
 to get an array of first level children nodes, their names, and degree of
 bar edges like [v(2), abc, 15], [v(3), abc, 20], [v(4), xyz, 15],
 [v(5), xyz, 20]
 
 And then I can sort the array by the name property, and iterate through
 that array to delete nodes that have a smaller count based on the count
 value specified in each sub array.
 
 But since my gremlin knowledge is still very limited, before digging too
 much into this proposed solution I want to verify with you that it would
 work and see if you have better or easier approach to do it (i.e. maybe one
 simple method that I can make use that I'm not aware of).  Thanks very much
 again.
 
 
 On Sat, Oct 22, 2011 at 9:40 AM, Marko Rodriguez okramma...@gmail.comwrote:
 
 Hi,
 
 Currently I'm doing the following in my own code with multiple requests
 to the standalone neo4j server. I wonder if it's possible to achieve in one
 gremlin query/script so that I can post the gremlin query to the server as 1
 request and done. What I'm trying to achieve is:
 
 Start from one given node (e.g. v1), get all of the nodes connected
 through a given type of relationship (e.g. relationship foo), within all
 of these nodes, see if their name property has the same value, and if so,
 delete the node (and the foo relationship connected to it) with smaller
 outgoing degree (on a specific type of relationship, say, bar). If there
 are more than two nodes with the same name property, only keep the one
 with biggest outgoing degree (on type bar).
 
 
 The query below is to warm you up. It will delete all vertices with same
 property value as source vertex that are 'foo' related to source vertex.
 Given that you are mutating the graph, you will want to deal with
 transaction buffers so you don't do one transaction per mutations:
   https://github.com/tinkerpop/blueprints/wiki/Graph-Transactions
 
 g.v(1).sideEffect{x =
 it.getProperty('name')}.out('foo').filter{it.getProperty('name').equals(x)}.sideEffect{g.removeVertex(it)}
 
 -
 
 To do the stuff with the smaller counts, etc. You can do:
 
 g.v(1).sideEffect{x =
 it.getProperty('name')}.out('foo').filter{it.getProperty('name').equals(x)}.transform{[it,
 it.outE('bar').count()]}.filter{it[1]  0}.aggregate.cap.next().sort{a,b -
 b[1] = a[1]}.eachWithIndex{a,i - if(i  0) g.removeVertex(a[0])}
 
 There you go! One big fatty Gremlin query to solve your problem.
 
 I would recommend going through each step and seeing what it returns so
 you understand what is going on Again, given that you are mutating the
 graph, be sure to be wise about transactions.
 
 Enjoy!,
 Marko.
 
 http://markorodriguez.com
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

Re: [Neo4j] Gremlin help

2011-10-22 Thread Marko Rodriguez
Hi,

 Currently I'm doing the following in my own code with multiple requests to 
 the standalone neo4j server. I wonder if it's possible to achieve in one 
 gremlin query/script so that I can post the gremlin query to the server as 1 
 request and done. What I'm trying to achieve is:
 
 Start from one given node (e.g. v1), get all of the nodes connected through a 
 given type of relationship (e.g. relationship foo), within all of these 
 nodes, see if their name property has the same value, and if so, delete the 
 node (and the foo relationship connected to it) with smaller outgoing 
 degree (on a specific type of relationship, say, bar). If there are more 
 than two nodes with the same name property, only keep the one with biggest 
 outgoing degree (on type bar).


The query below is to warm you up. It will delete all vertices with same 
property value as source vertex that are 'foo' related to source vertex. Given 
that you are mutating the graph, you will want to deal with transaction buffers 
so you don't do one transaction per mutations:
https://github.com/tinkerpop/blueprints/wiki/Graph-Transactions

g.v(1).sideEffect{x = 
it.getProperty('name')}.out('foo').filter{it.getProperty('name').equals(x)}.sideEffect{g.removeVertex(it)}

-

To do the stuff with the smaller counts, etc. You can do:

g.v(1).sideEffect{x = 
it.getProperty('name')}.out('foo').filter{it.getProperty('name').equals(x)}.transform{[it,
 it.outE('bar').count()]}.filter{it[1]  0}.aggregate.cap.next().sort{a,b - 
b[1] = a[1]}.eachWithIndex{a,i - if(i  0) g.removeVertex(a[0])}

There you go! One big fatty Gremlin query to solve your problem. 

I would recommend going through each step and seeing what it returns so you 
understand what is going on Again, given that you are mutating the graph, 
be sure to be wise about transactions.

Enjoy!,
Marko.

http://markorodriguez.com

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


Re: [Neo4j] Neo4j, Gremlin and Campaign data

2011-10-18 Thread Marko Rodriguez
Digging it up was the easy part :D. Writing it was the hard part. This is the 
fellow who wrote it:

http://twitter.com/#!/davefauth

Marko.

http://markorodriguez.com

On Oct 18, 2011, at 7:33 AM, Peter Neubauer wrote:

 Hi all,
 the other day Marko dug this up - using Neo4j with Campaign data. Pretty cool!
 
 http://s113319.gridserver.com/?p=48
 
 Cheers,
 
 /peter neubauer
 
 GTalk:  neubauer.peter
 Skype   peter.neubauer
 Phone   +46 704 106975
 LinkedIn   http://www.linkedin.com/in/neubauer
 Twitter  http://twitter.com/peterneubauer
 
 http://www.neo4j.org   - Your high performance graph database.
 http://startupbootcamp.org/- Öresund - Innovation happens HERE.
 http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party.
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] Article: The Coming SQL Collapse

2011-10-14 Thread Marko Rodriguez
Hello,

The type system provided by Spring Data Neo4j has a nearly identical semantics 
to Java (and most object oriented languages). The type system employed by 
FreeBase is more aligned with description logics --- RDFS/OWL.

For many who live in the world of object oriented programming, being able to do 
Graph-Object mapping (like ORM) is nice and that is what Spring Data Neo4j 
provides. However, what would be enticing is a general reasoning engine for 
which Spring Data Neo4j would be based on --- and various logics being able to 
be loaded. In this way, other data semantics can be expressed to allow the 
types of things that (for example) the author of The Coming SQL Collapse 
wrote  --- Baysian inference. With Spring Data Neo4j you get SUBLCASS 
inheritance, CAN_HAVE properties, and close world reasoning. This is not 
conducive to Baysian-based reasoning, evidential reasoning, other forms of 
logics (classical and non-classical)  

For many, it doesn't matter---the world is composed objects and explicit 
relations between objects. However, I believe there is a larger space wherein 
which graph databases can shine -- and shine brighter than other database 
technologies. In this space, the world isn't necessarily object oriented.

If I gave them what they wanted, I would have bred a faster horse.
- Henry Ford

Take care,
Marko.

http://markorodriguez.com

On Oct 14, 2011, at 10:32 AM, Thad Guidry wrote:

 I should further say after looking more at Spring Data Neo4j ... that it
 allows an easy Type system layer on top of Neo4j.  Is that correct ?  The
 same kind of Type system that Freebase.com has had always.
 
 In fact, Micheal, I would say even say that with Spring Data Neo4j
 installed, you could almost point users to the Freebase Data modeling style
 guide as a good reference :
 http://wiki.freebase.com/wiki/Data_modeling_style_guide
 
 On Fri, Oct 14, 2011 at 11:26 AM, Thad Guidry thadgui...@gmail.com wrote:
 
 From your quick example, it looks like Spring Data Neo4j is what most folks
 really expect out of the box with Neo4j.  I know I certainly did when I
 installed Neo4j for the first time, last year.  Spring Data seems to meet
 with my expectation (based on my bottom-up Schema-evolving work on
 Freebase.com)
 
 
 On Fri, Oct 14, 2011 at 11:15 AM, Michael Hunger 
 michael.hun...@neotechnology.com wrote:
 
 With spring data neo4j you are able to use any domain entity with any
 node, so it is for instance
 possible to project an entity to another when used in a different context.
 
 Otherwise the Spring Data Neo4j config less invasive and more concise than
 the existing model
 but uses the same approach behind the scenes (fields are mapped to
 properties and relationships - 1:1 or 1:n are mapped to relationships).
 
 @NodeEntity
 class Movie {
  String title;
  SetActor actors;
 }
 
 a more elaborate example.
 @NodeEntity
 class Movie {
  @GraphId Long id;
  @Indexed(fulltext=true, indexName=movies) String title;
  @RelatedToVia(type=ACTS_IN, direction=Direction.INCOMING)
  IterableRole roles;
  Person director;
 }
 
 @RelationshipEntity
 class Role {
 @Indexed String title;
 @StartNode Actor actor;
 @EndNode Movie movie;
 }
 
 @NodeEntity
 class Actor {
  String name;
  Gender gender;
  Date birthday;
  public Role actsIn(Movie movie, String role) {
 return relateTo(movie,ACTS_IN,Role.class).withTitle(role);
  }
  @RelatedTo(type=ACTS_IN)
  SetMovie movies;
 }
 
 
 Am 14.10.2011 um 16:14 schrieb Thad Guidry:
 
 I would suggest breaking down his statement further and fill in the
 blanks
 to gain even better insight into his conjecture.
 
 it‘s basically a bunch of nodes where you just blob your attributes.‘
 Worse than that, to wrap objects around it, you have to have them
 explicitly
 incorporate their node class, which is ugly, smelly, violates every law
 of
 separation of concerns and logical vs. physical models.
 
 
 it's - Neo4j
 
 to wrap objects around IT - what is the IT that he is referring to ?
 
 you have to have THEM explicitly incorporate THEIR node class - what
 is
 THEM / THEIR really mean for Neo4j here ?
 
 law of separation of concerns - what and where are we JOINING that
 should
 be SEPARATING , is it only the Domain objects ?
 
 
 From outside looking in, I have seen others not complete their Domain
 Model
 as needed with Neo4j, and also make it entirely TOO SIMPLE.  Why ?
 Because
 they might be new to graph databases, or their Domain Model really IS
 NOT
 complete yet and they need help from others to assist with putting
 together
 an elegant Domain Model to begin with.  Being able to easily wire up a
 Domain Model is the primary reason they were attracted to graph
 databases in
 the first place !... to build it out without resorting to defining a
 rigid
 schema (a SQL table mantra).  But many need help in contorting their
 Domain
 Model over time.  To me, Neo4j is already wide open enough to handle
 that
 contortion and the beauty of Neo4j  graph databases 

Re: [Neo4j] Article: The Coming SQL Collapse

2011-10-14 Thread Marko Rodriguez
Hi,

 This is not conducive to Baysian-based reasoning, evidential reasoning, 
 other forms of logics (classical and non-classical)  
 
 How would you model those to a suitable domain model?
 Can you give a good example?
 Michael

Here is an article that argues for support of other data semantics in the Web 
of Data (RDF world) beyond description logics. In here, you will find examples 
of other forms of reasoning.

http://arxiv.org/abs/0905.3378

Unlike the triple/quad-store world, graph databases provide a very generic data 
model with limited constraints on meaning. Unfortunately (in my opinion), graph 
databases like OrientDB and DEX employ typing at the graph database level. 
Neo4j provides it at the Spring Data Graph level -- a level above. This is good 
in that Neo4j is not pushing a world view to low into the stack. The world of 
RDF, on the other hand, and its strong bent towards OWL (description logic) 
makes it such that the entire technology stack is mixed up with this logic. 
And, while this logic is very cool, its not the only way to do things -- the 
only way to view the world.

 however, at some point, there is always an assumption, and the 
foundational assumption of graph databases is all reasoning is best with a 
linked list data structure.

See ya,
Marko.

http://markorodriguez.com

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


Re: [Neo4j] Mahout, and Migrating from JPA/Hibernate/MySQL to Neo4j?

2011-10-12 Thread Marko Rodriguez
Hi Deejay,

 1. We're using Mahout as a recommendation system. Has anyone had any success
 plugging Neo4j into this?

I work with various companies using graph databases to do recommendation. 
Moreover, a couple of them are also experimenting with Mahout over MySQL and 
Hadoop. I have never thought to think about backing Mahout by a graph database. 
That is an interesting idea... Here are three thoughts that are related (though 
do not directly address your question):

1. With Mahout (as I understand it since a few versions back), only 
single relational data can be processed. That is, it only supports data of the 
form: X likes[weight] Y, where weight can be binary or rational. When a 
domain model is sufficiently complex: people liking things, people knowing each 
other, people working in the same, similar, etc. places, and products having 
features, designers, etc.  there is more information in the domain that can 
be capitalized on for recommendation.

2. With pure graph-based recommendation, no recommendation model is 
generated (intermediate data structure) as recommendations are calculated on 
the fly over the raw graph using traversal techniques. Traversals can propagate 
over more complex relations and are not limited to X likes[weight] Y or, 
better yet, such basic relations can be derived through implicit relations 
(i.e. paths) [ http://markorodriguez.com/2011/02/08/property-graph-algorithms/ 
]. Along this line of thought, the raw graph representation of your domain can 
be used for more than just recommendation --- e.g. path analysis, global 
ranking, searching, reasoning, abstraction, etc. [ 
http://markorodriguez.com/2011/07/14/graphs-brains-and-gremlin/ ]

3. With various forms of graph sampling/weighting, it is possible to 
put as many clock cycles (thus, compute time) as desired into the determination 
of a recommendation -- generally, more clock cycles yields greater accuracy. 
However, with accumulative methods, it is possible to reach an ergodic state [ 
http://en.wikipedia.org/wiki/Ergodicity ] whereby the contribution of more 
clock cycles does not yield more information (i.e. does not alter the order of 
the resultant recommendation ranking).

While your question was about overlaying Mahout on top of Neo4j, I argue that 
by using Neo4j in its native form (through its API and its approach to data 
analysis), there is much more beyond recommendation that you can exploit from 
your domain model.

To conclude, I recently wrote up a post on graph-based recommendation that may 
be of interest to you:

http://markorodriguez.com/2011/09/22/a-graph-based-movie-recommender-engine/

Good luck with your explorations,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Neo4J + ThingWorx Presentation from QCon...

2011-10-11 Thread Marko Rodriguez
I thoroughly enjoyed the presentation. Well done.

Marko.

http://markorodriguez.com

On Oct 11, 2011, at 2:01 PM, Rick Bullotta wrote:

 ...is now online.
 
 http://www.infoq.com/presentations/Graph-Database-Power-Web-of-Things
 
 Enjoy.
 
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] Gremlin syntax for multiple paths in one call

2011-10-04 Thread Marko Rodriguez
Hey,

 If I want to get the following 
 
 g.V(0).out('Friends')
 
 and 
 
 g.V(0).in('Likes') 


This is the world of split and merge. The syntax for this is not the sexiest, 
but as it stands:

g.v(0)._.copySplit(_().out('Friends'), _().in('Likes')).fairMerge

copySplit will take what comes into it and copy it to its internal pipes (in 
this case, 2 internal pipes). Then fairMerge will, in a round robin fashion, 
merge the output of the two internal pipes into a single pipe. Thus, split the 
pipeline, then merge it back into a single pipeline.

For example, over the play TinkerPop graph:

gremlin g = TinkerGraphFactory.createTinkerGraph()
==tinkergraph[vertices:6 edges:6]
gremlin g.v(1)._.copySplit(_().out('created'),_().out('knows')).fairMerge
==v[3]
==v[2]
==v[4]

We haven't developed split/merge much. If you have any ideas for syntax, that'd 
be great.

NOTE: If they were both out, then you can simply do:  
g.v(0).out('friends','likes')

Good luck,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Gremlin syntax for multiple paths in one call

2011-10-04 Thread Marko Rodriguez
Hey,

Your answer is correct too, though its not lazy. However, I suspect its more
understandable.

Marko.

On Oct 4, 2011 8:31 AM, Peter Neubauer peter.neuba...@neotechnology.com
wrote:

Nice one, will change the docs.

/peter

Sent from my phone.

On Oct 4, 2011 5:20 PM, Marko Rodriguez okramma...@gmail.com wrote:
 Hey,

 If I want to get...

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


Re: [Neo4j] C# REST binding / wrapper

2011-10-03 Thread Marko Rodriguez
Hey Romiko,

 http://romikoderbynew.com/2011/07/30/neo4jclient-primer/

That is really cool how you build a Gremlin expression in C# using a fluent 
pattern and then, I suspect, transform it to the appropriate Gremlin string 
representation for transport over the wire to Neo4j REST Server. Is that what 
you are doing? If so, that is a neat way to build language bindings that are 
not just server.eval(some.big.fat.string.all.old.skool.rdbms.style)?

Finally, in a similar note, TinkerPop is generalizing Gremlin away from a 
particular language implementation. We want to provide the Gremlin-style to 
any JVM language, not just Groovy. We plan to have Gremlin_scala out in the 
next release... E.g.:

gremlin-groovy: g.v(1).out('knows').name.filter{it == 'josh'} 
gremlin-scala: g.v(1).out(knows).property(name).filter{_ == josh} 

There is an strong conceptual overlap to how you are doing your C# binding and 
how Gremlin is becoming JVM language agnostic makes me think. :/

Anywho, I like the work you did. Thank you for sharing,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Some questions about design when using neo4j

2011-09-28 Thread Marko Rodriguez
Hey,

If you want to play with JUNG over Neo4j, you can do it via TinkerPop.

Graph g = new Neo4jGraph(/tmp/neo4j);
GraphJung jung = new GraphJung(g);

That GraphJung object is a implementation of the JUNG Interfaces and can be 
processed by the JUNG algorithms package.

https://github.com/tinkerpop/blueprints/wiki/JUNG-Ouplementation

HTH,
Marko.

http://markorodriguez.com

On Sep 28, 2011, at 1:06 AM, Peter Neubauer wrote:

 Gen,
 I guess there is nothing out of the box right now, but you could get
 inspiration from http://jung.sourceforge.net/doc/api/index.html,
 especially 
 http://jung.sourceforge.net/doc/api/edu/uci/ics/jung/algorithms/flows/EdmondsKarpMaxFlow.html
 and implement one or just use it on a toy graph to test it out?
 
 Cheers,
 
 /peter neubauer
 
 GTalk:  neubauer.peter
 Skype   peter.neubauer
 Phone   +46 704 106975
 LinkedIn   http://www.linkedin.com/in/neubauer
 Twitter  http://twitter.com/peterneubauer
 
 http://www.neo4j.org   - Your high performance graph database.
 http://startupbootcamp.org/- Öresund - Innovation happens HERE.
 http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party.
 
 
 
 On Sat, Sep 3, 2011 at 12:33 AM, Benjamin Gustafsson
 benjamingustafs...@gmail.com wrote:
 Just in case there are any graph experts out there that want to exercise
 their brains. (Its quite a while since I studied algorithms and optimization
 regarding graphs. :-)
 
 I'm able to implement a algorithm described in pseudocode (if anyone knows a
 good algorithm for my special case below).
 
 I have the transportation problem and need to find a preferably small (not
 necessarily smallest) set of nodes that transports a certain amount of
 credit/commodity from source node S to sink node T. All edges have a
 capacity stated as a attribute for the edge, this can be read while
 traversing the graph. Transportation cost for commodity/credit in the graph
 is zero. The only cost in this graph problem is computation time to *find a
 set of paths delivering all the commodity*(in my case credit). The path
 lengths chosen are not important.
 
 (This is the standard ripplepay problem, but I didn't like the algorithms
 used by the original ripplepay implementation. It does not scale up to
 millions of users. It is not fast enough.)
 
 http://en.wikipedia.org/wiki/Transportation_network_%28graph_theory%29
 
 And I also need a quick way of analysing if it is possible to send all
 commodity across the network. If the amount commodity to be sent is lower
 than max flow. (lower than min cut). There will initially be clusters with
 very few edges connecting the clusters. If the nodes are in different
 clusters the min cut can be really easy/*quick* to find (if we do it the
 right way).
 
 http://en.wikipedia.org/wiki/Max-flow_min-cut_theorem
 
 Any implementations for neo4j already available regarding my special case?
 
 --
 //Benjamin Gustafsson
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] Neo4J Rest server support SPARQL??

2011-09-28 Thread Marko Rodriguez
Hey,

 After adding nodes and relationships into Neo4J REST server using REST API. 
 How do I read data from the database using SPARQL? Does the database support 
 SPARQL?

Neo4j is not an RDF database in its raw form. Its data model is a bit more 
complicated than RDF and as such, is not amenable to SPARQL which assumes only 
an edge-labeled graph. However, with that said, the pattern matching 
functionality of Cypher is somewhat analogous to SPARQL so you might find 
solace in that. Moreover, you can also use Gremlin for pattern matching, though 
it doesn't have the same look-and-feel as SPARQL (see 
https://github.com/tinkerpop/gremlin/wiki/SPARQL-vs.-Gremlin ).

Next. If you actually have used GraphSail (via Blueprints) to model your data 
as an RDF graph in Neo4j, then you can access it via Sesame SPARQL engine --- 
however, as it stands, not via the Neo4j REST server without rolling your own 
extension. If you are so inclined, you can either use Rexster 
(http://rexster.tinkerpop.com) and its SPARQL kibble or steal the code in 
Rexster's SPARQL kibble and make it work for Neo4j Server (shouldn't be more 
than an a few hours work).

see http://rexster-kibbles.tinkerpop.com/

https://github.com/tinkerpop/rexster-kibbles/tree/master/sparql-kibble

Hope that is clear,
Marko.

http://markorodriguez.com

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


Re: [Neo4j] how to get the User who has been B Followed who has Followed Back.

2011-09-20 Thread Marko Rodriguez
Hi,
  I have some relation like this:
 http://neo4j-community-discussions.438527.n3.nabble.com/file/n3352328/follow.jpg
 
 what should I do to get the users who has been B Followed and has Followed
 back to B.
 In the image the result should be (A).


 
 In Gremlin (http://docs.neo4j.org/chunked/snapshot/gremlin-plugin.html)
 Marko will provide, have no time to test it to be exact :)

If I understand your query correctly, then its:

g.v(1).out.filter{it.out[[id:1]].hasNext()}

Start from vertex 1(B), go to its outgoing adjacent neighbors. For each of 
those neighbors, make sure there is at least one link back to vertex 1.

HTH,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Neo4j low-level data storage

2011-09-14 Thread Marko Rodriguez
 shameless plug explanation=my blog

There is no shame in producing good work and sharing it with others.

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


Re: [Neo4j] Gremlin Sort Syntax Help

2011-09-12 Thread Marko Rodriguez
Hey,

 Using the REST API 
 
 g.v(0).out.unique().sort{it.Name}.toList()

Cool.

 works but i can't get 
 
 t = new Table(); 
 g.v(0).out.as('friend').table(t).sort{it.Name}  -1; 
 t;
 
 to sort correctly.  

Table will simply pass the object through itself (it is a side-effect step). 
Thus, you are sorting on 'out name' in the stream, not on the table.

t = new Table();
g.v(0).out.as('friend').table(t){it.Name}  -1
t.sort();

OR 

t = new Table();
g.v(0).out.as('friend').table(t)  -1
t.sort{it.Name};

---depends on what you want stored in the table. the first stores the Name, not 
the vertex.

*ANALOGOUS TO THE LAST, BUT MORE CONCISE
g.v(0).out.as('friend').table.cap.next().sort{it.Name}
**

 and how would i sort 
 
 g.v(0).out.as('friend').out.as('moreFriend').sort( on friend.Name ) 
 
 Also, can you point me to some documentation on this and other commends that 
 can be preformed on this pipe.  I have been searching and have not found 
 anything straight forward (could be me...)  

t = new Table();
g.v(0).out.as('friend').out.as('moreFriends').table(t)  -1
t.sort{it[0].Name}

--- or if you want to use column names as opposed to column indices:

t.sort{it.getColumn('friend').Name}

I just added some of this to the Gremlin Wiki.
https://github.com/tinkerpop/gremlin/wiki/Pattern-Match-Pattern (at 
bottom)

Thanks for the question,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


[Neo4j] A Note on Writing Performant Gremlin

2011-09-12 Thread Marko Rodriguez
Hi Gremlin+Neo4j+OrientDB people,

I apologize for the cross list posting, but this is an important piece of 
information for those using Gremlin with their respective graph databases. I've 
noticed lots of people use the very friendly notation of Element.key to get the 
property value of an Element. Note that in Gremlin, this mapping from 
Element.key to Element.getProperty(key) requires Java reflection and is a 
costly operation. The cost of a pretty traversal expression is time. Please 
read over this Wiki page for notes on optimizing your Gremlin queries:

https://github.com/tinkerpop/gremlin/wiki/Path-Optimizations

..especially the first section: Avoid Element Property Selection using Key

Finally, note that these times are with respect to Gremlin 1.3-SNAPSHOT which 
will have a stable release September 21st.

Thanks so much and again, apologies for the cross post.
Marko.

http://markorodriguez.com

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


Re: [Neo4j] A Note on Writing Performant Gremlin

2011-09-12 Thread Marko Rodriguez
Hey,

 just to be clear, Would it be  safe to say that the compile time for 
 
 g.v(0).out.out  -1 
 
 would be slower than
 
 g.v(0).out().out()  -1 
 
 and slower than
 
 g.v(0).outE().inV().outE().inV()  -1


The fastest would be g.v(0).out().out().


 It is also surprising that the compile times that you have are an order of
 magnitude greater for the the condensed notation.  thanks for the info. 


The reason why there is a difference in speed is because Groovy's dynamic 
programming is based on Java reflection which is slow. However, compiling a 
pipeline is the least of your time relative to evaluating your traversal.

We are currently working on Gremlin_scala and Gremlin_jython. Gremlin_scala 
provides a nearly identical syntax with anonymous functions (e.g. 
filter(_.getProperty(age)  10)) and so, for many, this might be the way to 
go as its much faster with static typing and none of the runtime dynamic 
programming techniques used by Groovy. In essence, we plan for the future of 
Gremlin to be a graph traversal specification with implementations in multiple 
JVM languages so developers can pick which ever host language (JRuby, Groovy, 
Scala, Jython, Clojure, etc.) makes them happiest when traversing graphs in the 
Gremlin-esque style.

Hope that is clear,
Marko.

http://markorodriguez.com

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


Re: [Neo4j] Returning arbitrary data from gremlin

2011-09-11 Thread Marko Rodriguez
Hi,

Also, there table-step documentation for Gremlin is in Pattern Match Pattern:
https://github.com/tinkerpop/gremlin/wiki/Pattern-Match-Pattern

Side note:

 t = t.collect {
   outN = it.outV.toList().get(0);
   inN  = it.inV.toList().get(0);
   [outN.type, outN.key, inN.type, inN.key].join(,);
 };

..it is more efficient to do:

 t = t.collect {
   outN = it.outV.next();
   inN  = it.inV.next();
   [outN.type, outN.key, inN.type, inN.key].join(,);
 };


Though, as you say, probably best to use 'table' with column closures.

If you can frame you questions in terms of the graph diagrammed here 
https://github.com/tinkerpop/gremlin/wiki/Defining-a-Property-Graph , it will 
be much easier for us to tell you the answer than to parse your code which 
don't understand the underlying data model.

Good luck,
Marko.

http://markorodriguez.com

On Sep 11, 2011, at 10:29 AM, Peter Neubauer wrote:

 Xavier,
 also, for the table construction, have a look at the example at
 http://docs.neo4j.org/chunked/snapshot/gremlin-plugin.html#rest-api-send-a-gremlin-script---json-encoded-with-table-results,
 if that helps?
 
 Cheers,
 
 /peter neubauer
 
 GTalk:  neubauer.peter
 Skype   peter.neubauer
 Phone   +46 704 106975
 LinkedIn   http://www.linkedin.com/in/neubauer
 Twitter  http://twitter.com/peterneubauer
 
 http://www.neo4j.org   - Your high performance graph database.
 http://startupbootcamp.org/- Öresund - Innovation happens HERE.
 http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party.
 
 
 
 On Sun, Sep 11, 2011 at 5:35 PM, Xavier Shay xavier+ne...@squareup.com 
 wrote:
 I feel I should be able to use the Table object, but couldn't figure it out
 (is there explicit API documentation for it anywhere?)
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] Aggregate queries

2011-09-10 Thread Marko Rodriguez
Hey,

 m = [:];
 g.idx(user).get(key, %query%*)._()[0..5].sideEffect { x = it.key
 }.out.in.uniqueObject.loop(3) { it.loops  2 }.sideEffect {
  if (!m[x]) { m[x] = 0; };
  m[x]++
 }  -1;
 m;

Tips:

1. do g.idx(user).get(key, %query%*)[0..5] 
- _() is not needed.
2. use can use single quotes g.idx('user').get('key','%query%*')
3. use groupCount(m) instead of that last sideEffect.

 * The [0..5] allows me to page through the index to avoid one massive query.
 * I'm thinking perhaps the aggregate step would be useful, but I haven't
 figured out how to use it yet.

aggregate is just a way to collect everything up at a single step before moving 
to the next step. Typical use case:
g.v(1).out('friend').aggregate(x).out('friend').except(x) 
- my friends' friends who are not my friends.

 * I will unroll the loop as Marko suggested when I get to optimizing it

Cool. Realize that Gremlin 1.3 (coming out in a couple of weeks) is nearly 2-3x 
faster on most traversals as we have done many many performance optimizations. 
However, still unrolling loops will be faster than not doing so.

Good luck with your project.

Keep the questions/thoughts coming,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] chain TraversalDescription?

2011-09-09 Thread Marko Rodriguez
Hi,

I would do this using Gremlin as such:

g.v(1).out('read').in('wrote').uniqueObject.out('pet').name

If you are vertex 1 (g.v(1)), 
then you will go to the books you read, 
then to the authors of those books,
then because you might have read two Stephen King books, you will 
remove duplicates,
then to their pets,
and then to the names of those pets.

This assumes a graph of the form:

person ---read-- book ---wrote--- person ---pet--- 
animal[string:name]

Take care,
Marko.

http://markorodriguez.com

On Sep 9, 2011, at 8:48 AM, Linan Wang wrote:

 Hi,
 
 say people read books, books are written by authors, authors has dogs,
 then how to reach the dogs of authors of books i've read? when i'm
 also a writer, also have dogs, the TraversalDescription seems
 inefficient since it'll also traverse my own books and dogs first,
 before my customised StopEvaluator stops the expansion process.
 
 my feeling is RelationshipExpander is the way to go but stucked at the
 problem to get the depth info. my goal is to have the designated
 RelationshipExpander to tell traverser that at depth 1 only looking
 for OUTGOING read relationship, depth 2 for INCOMING wrote
 relationship and depth 3 for OUTGOING has relationship. any comment is
 appreciated! thanks.
 
 -- 
 Best regards
 
 Linan Wang
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] Gremlin pipes broken in 1.5

2011-09-09 Thread Marko Rodriguez
Hi,

This error seems to be an issue with depedencies. Are you using an TinkerPop 
dependency/s in your project. I believe Neo4j 1.5.M01 is depending on 
Blueprints 0.9 which does have the getInEdges(String...) method (similarly for 
getOutEdges(). Perhaps you are depending on Blueprints 0.8 somewhere in your 
project and the class loader is getting confused?

Also, you don't need an identity pipe. You can do: 
g.v(1).both

Marko.

http://markorodriguez.com

On Sep 9, 2011, at 1:29 PM, Xavier Shay wrote:

 Hello,
 I have just upgraded to neo4j 1.5 (brew install neo4j --HEAD) and am getting
 the following exception whenever I try to use a pipe:
 
 curl -H Accept:application/json -X POST -d '{script:g.v(1)._().both;}'
 -H Content-Type:application/json 
 http://localhost:7474/db/data/ext/GremlinPlugin/graphdb/execute_script;
 {
  message :
 com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jVertex.getInEdges([Ljava/lang/String;)Ljava/lang/Iterable;,
  exception : java.lang.AbstractMethodError:
 com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jVertex.getInEdges([Ljava/lang/String;)Ljava/lang/Iterable;,
  stacktrace : [... trim, see
 https://gist.github.com/1d6df2b03fa4d402ade3... ]
 }
 
 The same command without .both works as expected. Other pipe methods such
 as outE all cause the same exception. This was working with 1.4, and I
 couldn't find any mention of backwards incompatibility in the Gremlin
 changelog.
 
 I'm not sure how to debug this further. Any suggestions?
 
 Cheers,
 Xavier
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] Aggregate queries

2011-09-08 Thread Marko Rodriguez
Hi,

Thanks James. Here is how I would do it -- groupCount is not needed.

g.idx(index_name)[[key:value]].both.loop(1){it.loops  depth}.count()

Note: Be wary of this query. Make sure the branch factor of your graph is 
sufficiently small or the depth to which you are exploring is sufficiently 
small. With a large branch and depth, you can easily touch everything in your 
graph if your graph has natural statistics. ( 
http://en.wikipedia.org/wiki/Scale-free_network )

Also, if you want to get fancy, what I like to do, is unroll my loops to 
increase performance. Given that the while construct of your loop step is 
simply  depth, you can append an appropriate number of .both steps.

traversal = g.idx(index_name)[[key:value]];
for(i in 0..depth) { 
traversal = traversal.both; 
}
traversal.count();

Finally, 'both' is for undirected traversals. Use 'out' for outgoing traversals 
(follow the direction of the arrows) and 'in' for incoming traversals.
https://github.com/tinkerpop/gremlin/wiki/Gremlin-Steps

HTH,
Marko.

http://markorodriguez.com

 
 Xavier Shay wrote:
 
 For all nodes in a particular index, how many other nodes are they
 connected to at depth X?
 
 
 Marko will be able to improve upon this, but try something like this (this
 is untested)...
 
 m = [:]
 depth = 10
 index_name = vertices
 index_key = name
 index_nodes = g.idx(index_name).get(index_key,Neo4jTokens.QUERY_HEADER +
 *).
 index_nodes._().both.groupCount(m).loop(2){it.loops  depth}
 m.size()
 
 - James
 
 
 --
 View this message in context: 
 http://neo4j-community-discussions.438527.n3.nabble.com/Neo4j-Aggregate-queries-tp3317720p3317876.html
 Sent from the Neo4j Community Discussions mailing list archive at Nabble.com.
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] Aggregate queries

2011-09-08 Thread Marko Rodriguez
Hey,

 Won't this count dupes more than once? 
 
 Xavier's requirements of how many other nodes are they connected sounds
 like you should only count uniques, and that's why I am checking the size of
 groupCount map instead of using count(). Instead of a map you could use a
 Set with aggregate(), but I wasn't sure if they'd have the aggregate-loop
 fix yet. 

Then add a uniqueObject to the pipeline.

g.idx(index_name)[[key:value]].both.loop(1){it.loops  
depth}.uniqueObject.count()

 Also Xavier said, For all nodes in a particular index. I took that to mean
 all nodes in an index, not all nodes for a particular value in an index,
 hence the wildcard query:
 
 index_nodes = g.idx(index_name).get(index_key,Neo4jTokens.QUERY_HEADER +
 *)
 
 However, I am not sure/can't remember if you can do a wildcard query without
 at least one leading character.


Oh then yea, the %query% header can be used. 

Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Spring Data Neo4J vs. Tinker Pop's Frames/BluePrints?

2011-09-02 Thread Marko Rodriguez
Hi,

My thoughts on the matter.

Frames is bare-bones simple and the library is tiny. If you simply want to do 
the following, then Frames is cool:
1. Use annotated interfaces to define a Graph-to-Object mapping. (at 
the cost of Java reflection)
2. Use your objects as a way to schemify (constrain) your graph.
3. Put and get objects out of your graph and abandon the vertex/edge 
mental model. You can simply think in terms of Java objects.
- this is optional as I tend to use Frames only for data ingest.
4. (NEXT RELEASE) use Pipes or Gremlin to define 
abstract/inferred/virtual relationships between your domain objects.

Frames does not fit into a larger framework (outside of TinkerPop). 
Unfortunately, I don't know Spring, but from what I can tell, its a heavily 
used ?web application? framework and has lots of bells and whistles so it will 
definitely be more feature rich.

As Alfredas Chmeiliauskas (wow thats a crazy last name) says, there are lots of 
ways to mix and match things so don't feel that you will be trapped by a 
technology. Its easy to move between raw Neo4j/Blueprints, Cypher/Gremlin, etc. 
The only big choice I believe you make is whether you go Neo4j Server or 
Rexster as you can't really mix and match those two. In many of my projects I 
use Neo4j Server with parsers written in Frames and custom extensions using 
Gremlin. I also, in another, use Rexster with a Neo4j batch inserter (no 
Frames) and only the Neo4j algos package. Sorta depends on what the project 
demands...

HTH,
Marko.

http://markorodriguez.com

On Sep 2, 2011, at 3:33 AM, Michel Domenjoud wrote:

 Thanks for your answers!
 
 @Anders: Thanks, I noticed it, but I was more precisely wondering about
 Frames API, which brings similar functionalities to Spring Data.
 
 2011/9/2 Anders Nawroth and...@neotechnology.com
 
 Note that Gremlin is supported by Spring Data Graph, it's mentioned
 here: http://www.springsource.org/node/3208
 
 /anders
 
 2011-09-02 11:05, Peter Neubauer skrev:
 Michel,
 IMHO the Spring Data Graph is a much broader approach to the problem,
 although it brings with it more dependencies. I guess it is a matter of
 choice. I would go for Spring Data Graph personally.
 
 Cheers,
 
 /peter neubauer
 
 GTalk:  neubauer.peter
 Skype   peter.neubauer
 Phone   +46 704 106975
 LinkedIn   http://www.linkedin.com/in/neubauer
 Twitter  http://twitter.com/peterneubauer
 
 http://www.neo4j.org   - Your high performance graph
 database.
 http://startupbootcamp.org/- Öresund - Innovation happens HERE.
 http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party.
 
 
 On Fri, Sep 2, 2011 at 10:38 AM, Michel Domenjoudmdomenj...@octo.com
 wrote:
 
 Hi everybody,
 
 What are Neo4J forecasts about Tinker Pop's Frames and Blueprints
 frameworks, now there is Spring Data Graph framework?
 
 I saw that Neo4J guys are working on both projects, so do you have any
 preference for using one framework rather than the other?
 
 Michel.
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] 10 questions

2011-09-02 Thread Marko Rodriguez
Oh, I didn't see this:

(use twitter example: my followees' followers)

Then the query I provided in the previous email:

g.v(1).out('livesIn').sideEffect{city = 
it}.back(2).out.out.filter{it.out('livesIn').next().equals(city)}.groupCount(age){it.age}.groupCount(gender){it.gender}

would now be:

g.v(1).out('livesIn').sideEffect{city = 
it}.back(2).in('follows').in('follows').filter{it.out('livesIn').next().equals(city)}.groupCount(age){it.age}.groupCount(gender){it.gender}

as in('follows') is someone's followees (i.e. the people that follow me).

Enjoy,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Hyperedges in Neo4j

2011-09-01 Thread Marko Rodriguez
Hey,

 I think a traversal should in principal be performed with a query language 
 that is not turing complete so we can guarantee termination.

Turning completeness is not the lower bound for non-guaranteed termination. You 
can't guarantee completion in a regular language when your String (data 
structure) is a graph. E.g.

a*

The only languages guaranteed to complete are Star-free languages. That is, 
those that don't allow for recursion.

See ya,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] problem in SPARQL querying

2011-09-01 Thread Marko Rodriguez
Hey,

 Even on closing the manager, I did not see any change.. any further ideas??
 Thanks!

The best thing to do is not dive straight into a complex SPARQL query, but look 
to see if the particular triples you think are lost are actually there. You can 
do this with simple SPARQL queries or drop into Gremlin and search around.

The SPARQL query engine you are using was developed by Aduna and has been in 
use for many many years so I doubt there is a problem with their engine. I 
suspect there is some missing data. ?? .. Or perhaps your query is wrong. ?.

Good luck,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


[Neo4j] FluentPipeline with Pipes

2011-09-01 Thread Marko Rodriguez
Hi everyone,

For those on the Gremlin-users mailing list, this is not new. However, for 
others, I thought you would like to see some work over at TinkerPop that I'm 
really diggin'.

In Pipes 0.8-SNAPSHOT, we have made it so that its much easier to construct 
Gremlin-esque traversals in native Java. The new killer pipe is called 
FluentPipeline.

It works as such:

Graph g = new Neo4jGraph('/tmp/mygraph');
ListString friendsProjectNames  = new 
FluentPipeline(g.getVertex(1)).out(knows).out(created).property(name).toList()

In short, every Pipe in Pipes has an associated (in many cases, many 
associated) methods in FluentPipeline that to allow for this style of traversal 
construction. As you may realize, the only reason Gremlin still exists is 
because of the ease by which closures (~anonymous functions) can be defined in 
Groovy (as well as some other random meta-programming stuff). With 
FluentPipeline, inner-classes are required which are very verbose.

See the last two code blobs of 
https://github.com/tinkerpop/pipes/wiki/FluentPipeline that compare pure Java 
and Groovy.

This work along with some vast speed improvements to Gremlin will be seen in 
Gremlin 1.3 which will probably trickle up to Neo4j at version 1.4.3.

Enjoy,
Marko.

http://markorodriguez.com

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


Re: [Neo4j] problem in SPARQL querying

2011-08-31 Thread Marko Rodriguez
Hi Shri,

Question: Why do you have a TransactionalGraphManager as, in your code, you are 
not writing anything to disk? This makes me believe that you have another 
snippet of code that is writing data to the graph. Are you sure all your data 
is in the graph? -- How did you construct dataset (from new 
Neo4jGraph(dataset)).

Thanks,
Marko.

http://markorodriguez.com

On Aug 31, 2011, at 6:37 AM, shri wrote:

 Hi all,
 
 
 
  I am working with Neo4j system and Sparql queries as a part of my thesis
 and I am very very new these concepts. I have loaded the RDF dataset into
 Neo4j and now trying to query the results. My problem is, only half of my
 query is working and giving results but the query as a whole is not
 returning any result. this is leaving me clueless and I have no idea why
 this is happening..Kindly help me out with a solution.Thanks in advance!!
 
 I have used the Sail interface for query parsing and evaluating
 
 Here is the snippet:
 
 
 Neo4jGraph neo = new Neo4jGraph(dataset);
 Sail sail = new GraphSail(neo);
 sail.initialize();
 CommitManager manager =
 TransactionalGraphHelper.createCommitManager(neo, 1);
   SailConnection sc= sail.getConnection();
   Query1 ext=new Query1();
   SPARQLParser parser = new SPARQLParser();
 CloseableIteration? extends BindingSet, QueryEvaluationException
 sparqlResults;
 
 String queryString = PREFIX bsbm:
 lt;http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/gt;  +
 PREFIX rdf: lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#gt;  +
 PREFIX rdfs: lt;http://www.w3.org/2000/01/rdf-schema#gt;  +
 SELECT DISTINCT ?product ?label  +
 WHERE {  +
  ?product rdf:type
 lt;http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductType2gt;
 .  +
  ?product rdfs:label ?label . };
 /*?product bsbm:productFeature
 lt;http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature35gt;.;
 + 
 ?product bsbm:productFeature
 lt;http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature36gt;
 .  +
 ?product bsbm:productPropertyNumeric1 ?value1 .  +
 FILTER (?value1  3) }  +
 ORDER BY ?label  +
 LIMIT 10;*/
 try {
 
 ParsedQuery query = parser.parseQuery(queryString,
 http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/;);
 System.out.println(\nSPARQL:  + queryString);
 
 sparqlResults = sc.evaluate(query.getTupleExpr(), query.getDataset(),
 new EmptyBindingSet(), false);
 while (sparqlResults.hasNext()) {
 System.out.println(sparqlResults.next());
 }
 
 
 IS IT ANY THING TO DO WITH INDEXING ??
 
 
 P.S  The commented portion of my query in the snippet is NOT working
 
 
 cheers,
 shri
 
 
 --
 View this message in context: 
 http://neo4j-community-discussions.438527.n3.nabble.com/problem-in-SPARQL-querying-tp3298204p3298204.html
 Sent from the Neo4j Community Discussions mailing list archive at Nabble.com.
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] problem in SPARQL querying

2011-08-31 Thread Marko Rodriguez
Hi,

Where are you defining your RDFHandler (TripleHandler). Can I see that class 
please?

Thanks,
Marko.

http://markorodriguez.com

On Aug 31, 2011, at 7:25 AM, shri wrote:

 Hi Marko,
 
 Yes I have another separate file for loading the data( .NT format). Let me
 know if I should tell anything more clearly, sorry for being slow...
 
 snippet :
  Neo4jGraph neo = new Neo4jGraph(dataset);
  Sail sail = new GraphSail(neo);
  sail.initialize();
  CommitManager manager =
 TransactionalGraphHelper.createCommitManager(neo, 1);
  SailConnection sc= sail.getConnection();
   
   for (String file: args) 
   {
   System.out.println(Loading  + file + : );
   loadFile(file, sail.getConnection(), sail.getValueFactory(), 
 manager);
   System.out.print('\n');
   }
 private static void loadFile(final String file, SailConnection sc,
 ValueFactory vf, CommitManager manager) throws RDFParseException,
 RDFHandlerException, FileNotFoundException, IOException {
   NTriplesParser parser = new NTriplesParser(vf);
   TripleHandler handler = new TripleHandler(sc, manager);
   parser.setRDFHandler(handler);
   parser.setStopAtFirstError(false);
   parser.setParseErrorListener(new ParseErrorListener() {
   
   @Override
   public void warning(String msg, int lineNo, int colNo) {
   System.err.println(warning:  + msg);
   System.err.println(file:  + file +  line:  
 + lineNo +  column: 
 +colNo);
   }
 
   @Override
   public void error(String msg, int lineNo, int colNo) {
   System.err.println(error:  + msg);
   System.err.println(file:  + file +  line:  
 + lineNo +  column: 
 +colNo);
   }
 
   @Override
   public void fatalError(String msg, int lineNo, int 
 colNo) {
   System.err.println(fatal:  + msg);
   System.err.println(file:  + file +  line:  
 + lineNo +  column: 
 +colNo);
   }
   
   });
   parser.parse(new BufferedInputStream(new FileInputStream(new 
 File(file))),
 http://dbpedia.org/;);
   }
 }
 
 
 Cheers,
 Shri
 
 
 
 
 
 
 --
 View this message in context: 
 http://neo4j-community-discussions.438527.n3.nabble.com/problem-in-SPARQL-querying-tp3298204p3298337.html
 Sent from the Neo4j Community Discussions mailing list archive at Nabble.com.
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] problem in SPARQL querying

2011-08-31 Thread Marko Rodriguez
Hi,

When you are done with the file, you should close your manager.

I believe should do the trick:

public void endRDF() throws RDFHandlerException {
manager.close();
}

// NOTE: I don't know the specifics of RDFHandler, but it sounds like endRDF() 
is the method called when the file handler is complete. ?

This way, the last triples inserted, but not committed, are committed.

Perhaps that is your problem? ... you are missing the tail end of your RDF file.

However, if you are simply calling a SPARQL query within the same thread then 
the uncommitted triples should be visible to your code.

What are your thoughts on the matter?,
Marko.

http://markorodriguez.com

On Aug 31, 2011, at 7:45 AM, shri wrote:

 Hello Marko,
 
 here is my TripleHandler class:
 
 
 public class TripleHandler implements RDFHandler {
   private SailConnection sc;
   private CommitManager manager;
   
   public TripleHandler(SailConnection sc, CommitManager manager) { 
   this.sc = sc;
   this.manager = manager;
   }
 
   public void handleComment(String arg0) throws RDFHandlerException {
   }
 
   public void handleNamespace(String arg0, String arg1)
   throws RDFHandlerException {
   }
 
   public void handleStatement(Statement arg0) {
 
   try {
   // avoid self-cycles
   if
 (arg0.getSubject().stringValue().equals(arg0.getObject().stringValue()))
   return;
   
   sc.addStatement(arg0.getSubject(), arg0.getPredicate(),
 arg0.getObject());
   manager.incrCounter();
   if (manager.atCommit())
   System.out.print(.);
   } catch (SailException e) {
   e.printStackTrace();
   } catch (Exception e) {
   e.printStackTrace();
   System.out.println(Subject:  + 
 arg0.getSubject().toString() +
Predicate:  + 
 arg0.getPredicate().toString() +
Object:  + 
 arg0.getObject().toString());
   }
   }
 
   public void startRDF() throws RDFHandlerException {
   }
   
   public void endRDF() throws RDFHandlerException {
   }
 }
 
 
 Cheers,
 Shri
 
 --
 View this message in context: 
 http://neo4j-community-discussions.438527.n3.nabble.com/problem-in-SPARQL-querying-tp3298204p3298387.html
 Sent from the Neo4j Community Discussions mailing list archive at Nabble.com.
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] Update/Move relationships through REST APIs

2011-08-31 Thread Marko Rodriguez
Hi,

I did you example over TinkerGraph as vertex IDs are Strings and thus, easy to 
build your graph with.

~$ gremlin
 \,,,/
 (o o)
-oOOo-(_)-oOOo-
gremlin g = new TinkerGraph() 
==tinkergraph[vertices:0 edges:0]
gremlin g.addVertex('A'); g.addVertex('B'); g.addVertex('C'); 
g.addVertex('D'); g.addVertex('E');
==v[E]
gremlin g.addEdge(g.v('C'),g.v('A'),'foo'); 
g.addEdge(g.v('D'),g.v('A'),'foo'); g.addEdge(g.v('E'),g.v('A'),'bar')  
   
==e[2][E-bar-A]
gremlin g.V
==v[D]
==v[E]
==v[A]
==v[B]
==v[C]
gremlin g.E
==e[2][E-bar-A]
==e[1][D-foo-A]
==e[0][C-foo-A]

So, you have your 5 vertices and 3 edges. Next, here is your mutating traversal:

gremlin g.V.outE('foo').sideEffect{g.addEdge(it.outVertex,g.v('B'),'foo'); 
g.removeEdge(it)}
==e[1][D-foo-A]
==e[0][C-foo-A]

And now your edges are as you wanted them.

gremlin g.E
==e[3][D-foo-B]
==e[2][E-bar-A]
==e[4][C-foo-B]

So again, your traversal is:

g.V.outE('foo').sideEffect{g.addEdge(it.outVertex,g.v('B'),'foo'); 
g.removeEdge(it)}

Here is what the traversal says step-by-step:

g.V : iterate through all vertices
outE('foo') : iterate through their the outgoing 'foo' labeled edges
sideEffect{} : yield a sideEffect (mutate state)
g.addEdge(it.outVertex,g.v('B'),'foo'): add a new edge from the 
vertex (e.g. C,D,E -- it.outVertex) to vertex B with label 'foo'.   
g.removeEdge(it) : remove the current edge (it)


Note that its more optimal to do:

v = g.v('B'); 
g.V.outE('foo').sideEffect{g.addEdge(it.outVertex,v,'foo'); g.removeEdge(it)}

Also, vertex IDs are not Strings in Neo4j, but longs. Hopefully you can do what 
you need from here.

Good luck,
Marko.

http://markorodriguez.com

On Aug 31, 2011, at 6:17 PM, Nuo Yan wrote:

 I want to update the ending node for all relationships that are type :foo
 coming into node A to node B.
 
 For example, for all relationships that are type :foo coming into node A
 (node A as the end node), no matter where their starting node is, I want
 them to set the end node to node B.
 
 Node C --:foo-- Node A
 Node D --:foo-- Node A
 Node E --:bar-- Node A
 
 would become:
 
 Node C --:foo-- Node B
 Node D --:foo - Node B
 Node E --:bar-- Node A
 
 On Wed, Aug 31, 2011 at 5:00 PM, Marko Rodriguez okramma...@gmail.comwrote:
 
 Hi,
 
 If you tell me in English what you want to do, I can give you the Gremlin
 query. With Gremlin, you can traverse and update in a single query so
 perhaps it will meet your needs.
 
 Marko.
 
 http://markorodriguez.com
 
 On Aug 31, 2011, at 5:13 PM, Nuo Yan wrote:
 
 I looked through the REST APIs and didn't see an endpoint to move
 relationships. Is such operation possible? For example, given a set of
 relationships all end in one node, I want to send a bulk request to
 update
 their end nodes to another node.
 
 If there is no REST API for updating/moving relationship, what is the
 best
 way to do this? Can gremlin do it easily? Or do I have to delete all of
 the
 relationships and create new ones to the new end node?
 
 Thanks,
 Nuo
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] Update/Move relationships through REST APIs

2011-08-31 Thread Marko Rodriguez
Hey,

One more thing. 

WARNING: If your transaction mode is AUTOMATIC, then there will be one 
transaction for each mutation !! tx.begin/tx.commit/tx.finish

gremlin g.transactionMode
==AUTOMATIC

You can use a transaction manager if you plan this query to iterate over lots 
of vertices and do lots of mutations:
https://github.com/tinkerpop/blueprints/wiki/Graph-Transactions-Helpers

Thus, your mutating traversal would be:

manager = TransactionalGraphHelper.createCommitManager(g, 1000);
g.V.outE('foo').sideEffect{g.addEdge(it.outVertex,g.v('B'),'foo'); 
g.removeEdge(it); manager.incrCounter()}
manager.close();

Hope that helps -- and doesn't confuse :).

Marko.
http://markorodriguez.com

P.S. Gremlin 1.3 will make it much more natural to do batch transactions. 
TransactionGraphs (like Neo4j) will have a setTransactionBuffer(int 
bufferSize) method so you don't need to create this CommitManager object. 
Anywho. Thats that. See ya.

On Aug 31, 2011, at 7:38 PM, Marko Rodriguez wrote:

 Hi,
 
 I did you example over TinkerGraph as vertex IDs are Strings and thus, easy 
 to build your graph with.
 
 ~$ gremlin
 \,,,/
 (o o)
 -oOOo-(_)-oOOo-
 gremlin g = new TinkerGraph() 
 ==tinkergraph[vertices:0 edges:0]
 gremlin g.addVertex('A'); g.addVertex('B'); g.addVertex('C'); 
 g.addVertex('D'); g.addVertex('E');
 ==v[E]
 gremlin g.addEdge(g.v('C'),g.v('A'),'foo'); 
 g.addEdge(g.v('D'),g.v('A'),'foo'); g.addEdge(g.v('E'),g.v('A'),'bar')
  
 ==e[2][E-bar-A]
 gremlin g.V
 ==v[D]
 ==v[E]
 ==v[A]
 ==v[B]
 ==v[C]
 gremlin g.E
 ==e[2][E-bar-A]
 ==e[1][D-foo-A]
 ==e[0][C-foo-A]
 
 So, you have your 5 vertices and 3 edges. Next, here is your mutating 
 traversal:
 
 gremlin g.V.outE('foo').sideEffect{g.addEdge(it.outVertex,g.v('B'),'foo'); 
 g.removeEdge(it)}
 ==e[1][D-foo-A]
 ==e[0][C-foo-A]
 
 And now your edges are as you wanted them.
 
 gremlin g.E
 ==e[3][D-foo-B]
 ==e[2][E-bar-A]
 ==e[4][C-foo-B]
 
 So again, your traversal is:
   
   g.V.outE('foo').sideEffect{g.addEdge(it.outVertex,g.v('B'),'foo'); 
 g.removeEdge(it)}
 
 Here is what the traversal says step-by-step:
 
   g.V : iterate through all vertices
   outE('foo') : iterate through their the outgoing 'foo' labeled edges
   sideEffect{} : yield a sideEffect (mutate state)
   g.addEdge(it.outVertex,g.v('B'),'foo'): add a new edge from the 
 vertex (e.g. C,D,E -- it.outVertex) to vertex B with label 'foo'. 
   
   g.removeEdge(it) : remove the current edge (it)
   
 
 Note that its more optimal to do:
 
   v = g.v('B'); 
 g.V.outE('foo').sideEffect{g.addEdge(it.outVertex,v,'foo'); g.removeEdge(it)}
 
 Also, vertex IDs are not Strings in Neo4j, but longs. Hopefully you can do 
 what you need from here.
 
 Good luck,
 Marko.
 
 http://markorodriguez.com
 
 On Aug 31, 2011, at 6:17 PM, Nuo Yan wrote:
 
 I want to update the ending node for all relationships that are type :foo
 coming into node A to node B.
 
 For example, for all relationships that are type :foo coming into node A
 (node A as the end node), no matter where their starting node is, I want
 them to set the end node to node B.
 
 Node C --:foo-- Node A
 Node D --:foo-- Node A
 Node E --:bar-- Node A
 
 would become:
 
 Node C --:foo-- Node B
 Node D --:foo - Node B
 Node E --:bar-- Node A
 
 On Wed, Aug 31, 2011 at 5:00 PM, Marko Rodriguez okramma...@gmail.comwrote:
 
 Hi,
 
 If you tell me in English what you want to do, I can give you the Gremlin
 query. With Gremlin, you can traverse and update in a single query so
 perhaps it will meet your needs.
 
 Marko.
 
 http://markorodriguez.com
 
 On Aug 31, 2011, at 5:13 PM, Nuo Yan wrote:
 
 I looked through the REST APIs and didn't see an endpoint to move
 relationships. Is such operation possible? For example, given a set of
 relationships all end in one node, I want to send a bulk request to
 update
 their end nodes to another node.
 
 If there is no REST API for updating/moving relationship, what is the
 best
 way to do this? Can gremlin do it easily? Or do I have to delete all of
 the
 relationships and create new ones to the new end node?
 
 Thanks,
 Nuo
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 

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


Re: [Neo4j] REST API: output respresentation and performance

2011-08-29 Thread Marko Rodriguez
Hi,

 - Data transfer bottleneck. Returning a large set of nodes/relationships
 from a Gremlin query with Json might result in excesive result size. We
 transfer from hundreds to 100.000 entities. In our case, we only need to
 obtain a single property value (or just a few properties) for each
 node/relationship. Is it possible to control/limit data in exported node
 representation? We guess this would solve the problem.

Why return nodes/relationships if you only want a single property:

g.v(1).out.in.myProperty

 - Server-side calculations. We find Gremlin very useful to perform simple
 calculations on server side. However, we were not able to return Map result
 generated by Gremlin's groupCount () call on entity property. The script
 traverses multiple relationships and builds { propertyName, counter }
 histogram. This works fine in Gremlin console, but how to export this result
 back via REST API. We tried tables, but this option seems to be limited only
 to nodes/relationships. Any options?

I don't know enough about the REST API and Gremlin, but have you tried:

m = [:]
g.v(1).my.groupCount(m).based.traversal  -1
m

where you need the 'm' at the end to return the map.

Or are you saying that m can't be converted correctly to something Neo4j 
managed extensions can understand and JSONify for you?

See ya,
Marko.

http://markorodriguez.com


 
 Thanks for help in advance!
 
 Best regards,
 Oleg Morajko
 innoquant.com
 
 
 --
 View this message in context: 
 http://neo4j-community-discussions.438527.n3.nabble.com/REST-API-output-respresentation-and-performance-tp3293338p3293338.html
 Sent from the Neo4j Community Discussions mailing list archive at Nabble.com.
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] RDF querying

2011-08-28 Thread Marko Rodriguez
Hello,

Note that with loadFile(), you are not incrementing your commit manager's 
counter and thus, if your RDF file is large, you may run out of memory. See the 
work of Claudio for a good model for large RDF graphs:
http://blog.acaro.org/entry/dbpedia4neo

https://github.com/claudiomartella/dbpedia4neo/tree/master/src/main/java/org/acaro/dbpedia4neo/inserter

Finally, you do not manager.close() at the end in order to commit your 
transaction.

Good luck,
Marko.

http://markorodriguez.com

On Aug 28, 2011, at 9:09 AM, Shri :) wrote:

 Hello everyone,
 
   I am very very new to Neo4j and OOP, I am working on a project using
 Neo4j system. I have already uploaded my RDF data into Neo4j using the
 following code (snippet)
 
 
 
 Neo4jGraph neo = new Neo4jGraph(dataset);
Sail sail = new GraphSail(neo);
  sail.initialize();
CommitManager manager =
 TransactionalGraphHelper.createCommitManager(neo, 10);
 
SailConnection sc= sail.getConnection();
 
for (String file: args) {
System.out.println(Loading  + file + : );
loadFile(file, sail.getConnection(), sail.getValueFactory(), manager);
System.out.print('\n');
}
 
 
 I now want to write write a separate code to make my connection with the
 already created RDF store using Sail, I am confused about how I can make
 this connection without creating any new store..Kindly throw some light on
 this, I am stuck very badly..Thanks in advance..
 
 
 shri
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] A big graph for test

2011-08-08 Thread Marko Rodriguez
Hi,

First, I analyze the statistics of my real-world graph data set. For example, 
determine the degree distribution -- if you want to get fancy, the degree 
distribution for each edge type/label. Then I plot that on a log/log-scale. Get 
the slope of that plot which gives me the alpha exponent. From there, I use 
iGraph, NetworkX, etc. to generate an artificial graph (at whatever size I 
want) that respects that scaling exponent (that alpha).

Another method, that is easier is simply to do a rich-get-richer, preferential 
attachment algorithm which will give you a natural looking graph at any 
arbitrary size. The algorithm for that is fairly simple---max 50 lines of code.

HTH,
Marko.

http://markorodriguez.com

On Aug 8, 2011, at 9:53 AM, Michael Hunger wrote:

 Normally you just write a generator that creates nodes, relationships and 
 properties that would
 resemble YOUR domain model.
 
 You can create a graph using that generator either with the normal java API 
 or if it is really large (100M+ nodes and rels) then use the 
 Batch-Inserter-API for that.
 
 Then you implement your use-cases on top of your domain model and test and 
 verify them on a small graph and performance test them on the large, 
 generated graph.
 
 Cheers
 
 Michael
 
 Am 08.08.2011 um 17:49 schrieb Reza Ameri:
 
 Hi,
 How can I test my application that uses Neo4j?
 I can not find a huge sample graph to test my app with it. Is there any one
 that can help me???
 Thank you all
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] possible to query spatial indexes from gremlin?

2011-08-08 Thread Marko Rodriguez
Hey,

:).

You can do:

g.idx('test')[['bbox','[15.0, 16.0, 56.0, 61.0]']]

See ya,
Marko.

http://markorodriguez.com

On Aug 8, 2011, at 4:27 PM, Peter Neubauer wrote:

 Boris,
 I extended the functional tests to do what you are asking for,
 https://github.com/neo4j/neo4j-spatial/blob/master/features/start-and-stop.feature
 
 Basically:
 
 Create a Spatial Layer
 Add nodes
 Load the index with provider=spatial configuration
 Query it using Cypher
 Query it using Gremlin
 Query it using the REST index interface
 
 Thus, you can now query the (trivial) point layer index using any of
 your favorite methods. Is that helpful?
 
 Cheers,
 
 /peter neubauer
 
 GTalk:  neubauer.peter
 Skype   peter.neubauer
 Phone   +46 704 106975
 LinkedIn   http://www.linkedin.com/in/neubauer
 Twitter  http://twitter.com/peterneubauer
 
 http://www.neo4j.org   - Your high performance graph database.
 http://startupbootcamp.org/- Öresund - Innovation happens HERE.
 http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party.
 
 
 
 On Mon, Aug 8, 2011 at 3:31 PM, Peter Neubauer
 peter.neuba...@neotechnology.com wrote:
 Ahh ok.
 In that case, I should extend the capabilities of the REST plugins and add a
 test for it. Will see if I can get to it tonight, ok?
 
 /peter
 
 Sent from my phone.
 
 On Aug 8, 2011 2:41 PM, Boris Kizelshteyn boris.kizelsht...@popcha.com
 wrote:
 Can I set this in the server config? I am doing everything via rest right
 now, I am using the spatial plugin for doing the spatial operations.
 
 On Mon, Aug 8, 2011 at 3:05 AM, Peter Neubauer 
 peter.neuba...@neotechnology.com wrote:
 
 Boris, make sure that you have initialized the spatial index before
 you access is. See
 
 
 https://github.com/neo4j/neo4j-spatial/blob/master/src/test/java/org/neo4j/gis/spatial/IndexProviderTest.java#L68
 for loading the index with provider=spatial. The index is loaded
 lazy, and thus not available before explicitly loaded. I guess you
 have to do it in your loading code in Java or Groovy, since you can't
 provide the configuration in Gremlin or Cypher. After the first load,
 the index will be saved in the database and be visible as any other
 index. I haven't tried this out but it should work, as you see in the
 test case.
 
 Does that work?
 
 Cheers,
 
 /peter neubauer
 
 GTalk: neubauer.peter
 Skype peter.neubauer
 Phone +46 704 106975
 LinkedIn http://www.linkedin.com/in/neubauer
 Twitter http://twitter.com/peterneubauer
 
 http://www.neo4j.org - Your high performance graph database.
 http://startupbootcamp.org/ - Öresund - Innovation happens HERE.
 http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party.
 
 
 
 On Sun, Aug 7, 2011 at 11:11 PM, Boris Kizelshteyn bo...@popcha.com
 wrote:
 I'm doing it from the console.
 
 On Sun, Aug 7, 2011 at 5:09 PM, Peter Neubauer
 peter.neuba...@neotechnology.com wrote:
 
 What is the surrounding code before that call? You gave to at least
 once
 get that index as in the test via the index provider parameters before
 this
 works.
 
 /peter
 
 Sent from my phone.
 
 On Aug 7, 2011 10:25 PM, Boris Kizelshteyn bo...@popcha.com wrote:
 
 
 Hi Peter,
 
 I tried this today but I can't seem to get the syntax right in the
 context
 of g.idx, I tried this:
 
 g.idx('spatial')[[start n=(mylayer,'bbox:[myvals]') match (n) -[r]
 -
 (x)
 return n.bbox, r~TYPE, x.layer?, x.bbox?]]
 
 But it does nothing, not even an error. So I am proly doing
 something
 terrible wrong? Also, I don't see the spatial index in the idx list
 in
 the
 webpanel, I know I have one as I am able to query other spatial
 info.
 
 Thanks!
 
 On Wed, Aug 3, 2011 at 12:48 PM, Peter Neubauer 
 peter.neuba...@neotechnology.com wrote:
 
 Boris,
 I was thinking of adding a test with Gremlin onto
 
 
 
 
 https://github.com/neo4j/neo4j-spatial/blob/master/src/test/java/org/neo4j/gis/spatial/IndexProviderTest.java#L90
 ,
 but basically, since recently a trivial point layer is exposed as
 an
 IndexProvider, enabling Neo4j, Cypher and Gremlin to treat this as
 a
 normal index. I have not tested it, but I suspect it works. Give
 it
 a
 try and report back!
 
 
 Cheers,
 
 /peter neubauer
 
 GTalk: neubauer.peter
 Skype peter.neubauer
 Phone +46 704 106975
 LinkedIn http://www.linkedin.com/in/neubauer
 Twitter http://twitter.com/peterneubauer
 
 http://www.neo4j.org - Your high performance graph
 database.
 http://startupbootcamp.org/ - Öresund - Innovation happens HERE.
 http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing
 party.
 
 
 
 On Wed, Aug 3, 2011 at 9:36 AM, Boris Kizelshteyn
 bo...@popcha.com
 
 wrote:
 how would you do a basic find point in layer type query?
 
 Thanks!
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 

[Neo4j] [Blog Post] Mario Brothers! ... and Gremlin/Pipes stuff.

2011-08-04 Thread Marko Rodriguez
Hi,

Before leaving for a 2.5 week vacation, I thought it would be good to drop 
another blog post. This will be my last post before I buckle down on a paper 
for GDM'12 ( http://www.cse.unsw.edu.au/~iwgdm/2012/ ) or die an excruciatingly 
painful death on my vacation.

In this post we learn about Pipes and its fleeting relationship to Gremlin.

http://markorodriguez.com/2011/08/03/on-the-nature-of-pipes/

I hope you find it enjoyable,
Marko.

http://markorodriguez.com

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


Re: [Neo4j] Property graph model vs. classical approach

2011-08-04 Thread Marko Rodriguez
Hey Norbert,

 I'm wondering why Neo4j provides an API based on a property graph model and 
 is not using the classical graph approach GV,E? 
 What are the advantages of this architecture? Any thoughts? Is Neo4j 
 internally really based upon a property graph?
 What are the disadvantages of a property graph?

The ordering of ease of modeling for binary graph data structures is in a 
hierarchy like this:

G = (V,E \subseteq {V \times V}) (undirected graph)
G = (V, E \subseteq (V \times V)) (directed graph)
G = (V, E \subseteq (V \times V), \Omega: E - \Sigma) 
(multi-relational graph)
G = (V, E \subseteq (V \times V), \Omega: E - \Sigma, P : (V \cup E) 
- (\Sigma \times U) (property graph)

RDF is a multi-relational graph. The benefit of the multi-relational graph over 
the property graph is that it more straightforward when it comes to modeling -- 
e.g. In property graph modeling, you tend to be confronted with this question: 
Is this a property or another vertex?) at the expense of verbosity (How do I 
model edge weight with a multi-relational graph?)

However, in theory, what you can express with a property graph, you can express 
with an undirected graph.
http://arxiv.org/abs/0804.0277

Are you talking strictly in terms of expressivity in modeling, or other 
compute physics oriented issues?

See ya,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] RDF Store Research

2011-08-04 Thread Marko Rodriguez
Hey,

 I have some questions for our research of possible RDF Triple Stores
 with fast graph traversal and fast (fulltext) search. As of now we are
 using OpenRDFs Native and Memory Stores and OpenLink Virtuoso as our
 RDF Triple Store.
 How is the performance compared to OpenRDF Native and Memory Store
 when using Tinkerpop Bluprints with there SAIL Ouplementation?
 Area there any experience, any benchmarks?
 We would also like to do have (fulltext) search in the graph data
 built in. Is Neo4J the right store for that?

The beauty of the Sail Ouplementation model is that it is optimized for both 
index-based queries (spgo) and traversal-based queries. If you look at the 
technologies in OpenRDF, they are very index-based (SPARQL, getStatements(), 
etc.). While, with Blueprints GraphSail, you can use this API (implements 
Sail), you can also drop down into native Blueprints or Neo4j and thus, have 
a  quad-RDF graph represented as a linked list structure and thus, do fast 
traversals.  It is a bit of the best of both worlds in that sense...

In terms of performance benchmarks, we don't have any right now as GraphSail is 
a recent addition to Blueprints and is still being heavily developed/optimized. 
Also, I believe AllegroGraph has a disk/memory representation these days that 
makes for fast traversals (used in their SNA package) so you might want to 
check them out. Also, see StarDog which is a full Java-based RDF quadstore ( 
http://stardog.com/ ) which has Gremlin as their distributed path-based 
language.

Finally, most RDF stores provide full text search. Moreover, Neo4j does as well.

See ya,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Property graph model vs. classical approach

2011-08-04 Thread Marko Rodriguez
Yo,

 I'm simply confronted with the question 'why do you use such a graph
 model and not another one based on graph classes'?
 Hence, I'm gathering pros and cons for the 'property graph' model.
 Why is an interface like the one of Neo4j provided this way and not in
 another (e.g. using graph classes). Is there any design or architectural
 decision we don't know, yet?
 The longer I think the more I come to the conclusion that important
 points are: object-oriented representation of a network, and related
 with that, an 'external' representation of the graph structure that is
 not bound to a graph class managing the access to the graph structure
 and the data stored in properties.
 All other points like performance, or representation of the graph
 structure, seem to be equivalent to text-book graphs (directed,
 undirected, etc.), like you already stated out.

Ah. I remember now -- you are interested in vertex typing (classes). I read 
your paper on the topic.

Here are my thoughts on the matter. In the world of RDF (which is has nice 
clear separations), there is the data model (multi-relational graph), the 
schema language (RDF schema), and the ontology language (OWL). Mixing these 
layers into a single framework is deadly because you pigeonhole the 
interpretation of the graph. For example, if you are into classes and type 
hierarchies (and OO-based instantiations), then you are pigeonholing yourself 
into close-world semantics and a taxonomical mind-set. Thats great for you if 
you like that sort of thing---but what about others who wish, lets say to 
explore evidential logics in which such strongly typed models are not desired. 
This is also one of my problems with the RDF stack---while keeping the layers 
separate, RDF/RDFS/OWL is seen as the only layer. And frankly, description 
logics are not the only useful logics ( http://arxiv.org/abs/0905.3378 ). Now 
map that to what you are saying about property graphs and vertex typing.

A property graph is a multi-relational graph data model. You can build logic 
layers atop to implement your worldview as you see fit. It is the job of the 
database to persist the structure and make it fast to traverse/query. It is the 
job of the layers above to model and create meaning.

 Perhaps it is also a problem that the term 'property graph' isn't
 formally declared in some kind of scientific work and therefore widely
 unknown, isn't it?

Science is an industry claiming to be the ruler by which ideas are measured. 
Ideas do not need science. However, science needs ideas. Do not be sucked into 
the trap -- you will end up wearing a dusty suit, unhealthy, in some stodgy 
dinning hall at some conference talking to others who think publications make 
truth. And worst of all, you will be wearing a name tag.

Outz,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Collaborative filtering in Cypher

2011-08-01 Thread Marko Rodriguez
Hi,


 Hi, I'm new to graph databases and have been trying to understand the power
 of Cypher and/or Gremlin as a way to develop suggestion queries. I've
 watched a few webinars and read through some of the documentation but I've
 had a hard time figuring out complex suggestion type queries other than
 stuff like find me the top 3 movies my friends have recommended, or given
 that I rated this movie 5 stars, find me other people who liked this movie.

This is a common query that looks something like this in Gremlin.

m = [:] // create final rankings map
g.v(1).outE('rated'}{it.stars == 5}.inV.inE('rated'}{it.stars == 
5}.outV.outE('rated'){it.stars == 5}.inV.groupCount(m)

The last line says:
v.outE('rated'}{it.stars == 5}.inV // what movies do I like (5 stars) 
assuming you are g.v(1)
.inV.inE('rated'}{it.stars == 5}.outV // who else really likes those 
moves (5 stars)
.outE('rated'){it.stars == 5}.inV.groupCount(m) // what else do they 
really like

You can do some stuff with aggregate() and except() if you want to filter out 
those movies in m that you have already seen.

You can do some wicked stuff like this with Gremlin 1.2 (just released):

m = [:] // create final rankings map
g.v(1).outE('rated'}{it.stars == 5}.inV.inE('rated'}{it.stars == 
5}.outV.outE('rated'){it.stars  
3}.sideEffect{x=it.stars}.inV.groupCount(m){it.name}{it + x}

In the above, you are saying which movies do they like ( 3 -- not necessarily 
love, but just like), and then use that value (the stars) as the value you put 
into the ranking map (see the key/value closures off of groupCount(), where it 
is the previous value of that particular key). With respect to your weighting 
stuff you want to do below in your email, stuff like that comes in handy.

 To give a simplified example of what I'm trying to achieve is something like
 suggesting users based on attributes they weight from 0-1 and those
 attributes can have relationships between each other and I want to find
 something like the Tanimoto coefficient but weights as opposed to strictly
 binary attributes or slope one for a start user to end users and then list
 the top X. I have the O'Reilly book on Collective Intelligence but I've only
 seen examples for set theory, not for graph theory.
 
 I was thinking of Something like:
 
 UserA likes Digital Photography with a weight of 1
 UserA likes Wine with a weight of .8
 UserA likes Rock music with a weight of 1
 UserB likes Film Photography with a weight of 1
 UserB likes Rock music with a weight of .5
 UserB likes Beer with a weight of 1
 Digital Photography is related to Film Photography with a weight of .5
 
 I want to return how alike these two users are. I understand the graph
 theory behind it in that I want to follow all likes relationships and is
 related relationships till I hit another user and then with those paths that
 I have to that user I want to multiply the weights of the relationships
 along that path to get a score and then add those scores to get a final
 score.
 
 So in the above example it would look something like:
 UserA-Digital Photography-Film Photography-UserB = 1 * .5 * 1 = .5
 UserA-Rock-UserB = 1 * .5 = .5
 Final tally = 1.


I didn't read the above. Got lazy.


 And then if there were mere users it would follow the paths to find those
 users as well and find the scores and then sort the users by score. Looking
 at Gremlin and Cypher, I'm not sure where to even start to work on query
 that can do this and if it even is possible.

Just bust a paths() step at the end:

g.v(1).outE('rated'}{it.stars == 5}.inV.inE('rated'}{it.stars == 
5}.outV.outE('rated'){it.stars == 5}.inV.groupCount(m).paths

That is the path from you to the movies that are recommended to you. You can do 
path closures in Gremlin 1.2 so you can yield computations on the path 
elements, but I won't get into that. See the Gremlin documentation and 
examples. http://gremlin.tinkerpop.com


 I know what I described isn't slope one or the Tanimoto coefficient because
 it doesn't take into account the full set of attributes for the second user,
 but I'm just getting used to this and right now my potential solution is
 just have all unrelated attributes have edges of weight 0, but yeah I'm
 probably getting ahead of myself. I'm just looking for a point in the right
 direction for places to research and perhaps if they're available see some
 actual Cypher queries that have done weighted suggestions based on
 attributes.

I didn't read everything you wrote, so if what I provided isn't sufficient, 
please ask a particular question, and preferably not at great length.

WARNING: All Gremlin examples were typed into the email. You may have to fiddle 
as I might have missed a ( { '  and as such, might be bugged.

Thanks,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org

Re: [Neo4j] Brainstorming on my project: neo4john

2011-07-31 Thread Marko Rodriguez

 Marko had a good line about this: graphs are adjacency free indexes (or words 
 to that affect). 

:) -- Index-free Adjacency

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


Re: [Neo4j] Neo4J Gremlin Query for dates

2011-07-29 Thread Marko Rodriguez
Hi,

 I have dates in Neo4j stored as JSON Dates.
 
 e.g.
 DateCreated: /Date(1310360656147+)/
 
 LastLogin: /Date(1311927251851+)/
 
 I use the iterator and lambda way of query data
 
 e.g.
 g.v(0).outE[[label:'HOSTS']].inV{it.'Name'.compareTo('Agency1') == 0}.Name


SIDENOTE: g.v(0).out('HOSTS'){  } is a more concise and speedier 
representation.


 However I want to compare dates, what is the format we can use for this? 
 Currently we have written a .Net client to consume Neo4J and I we have a 
 formatter in the client api that converts c# lambda's to java lambda's, so it 
 would be nice to know the best way to do date comparisons :)
 
 e.g.
 g.v(0).outE[[label:'HOSTS']].inV{it.'LastLogin'.dateCompareTo('/Date(1311927251851+)/')
  == 0}.Name

Huh. I would use Java/Groovy Date object. ? ...

http://www.cafeaulait.org/course/week4/68.html

DateFormat formatter = new SimpleDateFormat(MMdd);
Date rootDate = formatter.parse(dateString);

Thus, something like:

g.v(0).out('HOSTS'){formatter.parse(it.LastLogin).after(rootDate)}.Name

HTH,
Marko.

http://markorodriguez.com

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


Re: [Neo4j] Comparing properties among different nodes in Gremlin

2011-07-26 Thread Marko Rodriguez
Jump out from behind bushes/

Hey hey,

 Thank you again, Marko. Let's try with a query that I'm not able to
 build in Gremlin. Looking at the property graph, I need the final
 vertices of all the paths of length 3, with at least one property
 name equals to josh in some vertex except the first one.


Here is the concise pro-style, where 'both' traverses both incoming and 
outgoing adjacent vertices.

g.V.both.loop(1){it.loops  4}[[name:'josh']]

Here is the less than pro-style (as('x') is a way to name a step so its more 
readable where to loop back to):

g.V.as('x').both.loop('x'){it.loops  4}[[name:'josh']]

This will give you the actual paths with, of course, the last element in the 
path being the vertex with name 'josh' (v[4]).

g.V.both.loop(1){it.loops  4}[[name:'josh']].paths

Finally, realize that you might incur reverberation in your paths. 

gremlin g.V.both.loop(1){it.loops  4}[[name:'josh']].paths
==[v[3], v[1], v[3], v[4]] // reverb
==[v[3], v[4], v[1], v[4]] // reverb
==[v[3], v[4], v[5], v[4]] // reverb
==[v[3], v[4], v[3], v[4]] // reverb
==[v[3], v[6], v[3], v[4]] // reverb
==[v[2], v[1], v[3], v[4]]
==[v[1], v[2], v[1], v[4]] // reverb
==[v[1], v[3], v[1], v[4]] // reverb
==[v[1], v[4], v[1], v[4]] // reverb
==[v[1], v[4], v[5], v[4]] // reverb
==[v[1], v[4], v[3], v[4]] // reverb
==[v[6], v[3], v[1], v[4]]
==[v[5], v[4], v[1], v[4]] // reverb
==[v[5], v[4], v[5], v[4]] // reverb
==[v[5], v[4], v[3], v[4]] // reverb
==[v[4], v[1], v[3], v[4]] // reverb
==[v[4], v[3], v[1], v[4]] // reverb

As such you can use uniquePath to remove reverberant paths:

gremlin g.V.both.loop(1){it.loops  4}[[name:'josh']].uniquePath 
==v[4]
==v[4]
gremlin g.V.both.loop(1){it.loops  4}[[name:'josh']].uniquePath.paths
==[v[2], v[1], v[3], v[4]]
==[v[6], v[3], v[1], v[4]]

Hope that helps,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Comparing properties among different nodes in Gremlin

2011-07-25 Thread Marko Rodriguez
Hi,

 I mean, I need to compare the value of a node property with the value
 in the last node property, and repeat the process on every node to
 check growth rates. But I don't if this is possible without using
 variables external to the query.


I don't know if this is your paricular solution, but I do this all the time:

g = Tinkegremlin g = TinkerGraphFactory.createTinkerGraph()
==tinkergraph[vertices:6 edges:6]
gremlin g.v(1).sideEffect{x = it.name}.out.sideEffect{println x}
marko
==v[2]
marko
==v[3]
marko
==v[4]
gremlin 

In other words, I use a sideEffect to save something to 'x' and then later can 
access that x for something -- in this limp example, simply to 
System.out.println it.

Does that help you? Can you map that motif over to your problem?

Good luck,
Marko.

http://markorodriguez.com

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


Re: [Neo4j] Comparing properties among different nodes in Gremlin

2011-07-25 Thread Marko Rodriguez
Hi,

 Does that help you? Can you map that motif over to your problem?
 
 Thank you, I hope so. Maybe the best way is to get all the properties
 map in each vertex in order to be able to operate with those values in
 the next vertex. Is that possible?

In that case do:

gremlin g.V.sideEffect{x = it.map()}.out.sideEffect{println x}   
[name:marko, age:29]
==v[2]
[name:marko, age:29]
==v[3]
[name:marko, age:29]
==v[4]
[name:peter, age:35]
==v[3]
[name:josh, age:32]
==v[5]
[name:josh, age:32]
==v[3]

In short, every vertex out of V is passed into sideEffect{}. The current 
vertex's properties are saved to x as a HashMap. Then the outgoing related 
vertices of that vertex are retrieved. There is a sideEffect again where you 
can access your map in x from previous.

Perhaps I'm misunderstanding your use case... Finally, you might want to 
consider aggregate as a way to get all before processing the next step. Check 
this:

gremlin x = [] 
   
gremlin g.V.aggregate(x).out.sideEffect{println x*.map()}
[[name:lop, lang:java], [name:vadas, age:27], [name:marko, age:29], 
[name:peter, age:35], [name:ripple, lang:java], [name:josh, age:32]]
==v[2]
[[name:lop, lang:java], [name:vadas, age:27], [name:marko, age:29], 
[name:peter, age:35], [name:ripple, lang:java], [name:josh, age:32]]
==v[3]
[[name:lop, lang:java], [name:vadas, age:27], [name:marko, age:29], 
[name:peter, age:35], [name:ripple, lang:java], [name:josh, age:32]]
==v[4]
[[name:lop, lang:java], [name:vadas, age:27], [name:marko, age:29], 
[name:peter, age:35], [name:ripple, lang:java], [name:josh, age:32]]
==v[3]
[[name:lop, lang:java], [name:vadas, age:27], [name:marko, age:29], 
[name:peter, age:35], [name:ripple, lang:java], [name:josh, age:32]]
==v[5]
[[name:lop, lang:java], [name:vadas, age:27], [name:marko, age:29], 
[name:peter, age:35], [name:ripple, lang:java], [name:josh, age:32]]
==v[3]

In this way, x has ALL the maps of all the vertices coming out of V. x is an 
ArrayListHashMap(). You can then do some sideEffect work on that aggregation 
later in the path expression... Does that help?

 My use case is a little particular. I'm writing a mini language to
 support ITL [1], which can work over Kripke structures [2] stored in a
 graph. So what I'm doing is a lexer and a grammar to translate ITL
 into Gremlin queries.

Ah. You might wish to translate it directly to Pipes perhaps? In one week 
(August 1st -- next round of TinkerPop releases), Pipes++ is coming out which 
will make it very easy for anyone to emulate Gremlin behavior in any language 
of their choosing.

http://groups.google.com/group/gremlin-users/browse_thread/thread/a1a7092762d22e37
Just a thought...

See ya,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Comparing properties among different nodes in Gremlin

2011-07-25 Thread Marko Rodriguez
Hi,

 Pipes++ looks interesting. I have to do more tests but I hope to find
 a way to acomplish my goal.

I will give you any query you ask over the play dataset:
https://github.com/tinkerpop/gremlin/wiki/Defining-a-Property-Graph

Thus, if you say, Marko, tell me how to get all X, where Y, and this, but then 
ensure that, etc. etc., I will provide you the respective Gremlin expression. 
In this way, hopefully, you can then take that and map it to your particular 
problem domain.

Hope all goes well with your project,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] paging

2011-07-24 Thread Marko Rodriguez
Hi,

 For Cypher, there is SKIP and LIMIT, together acting as a kind of
 paging system, but executing the query again (just giving you a
 different chunk of the result), so I am not sure that works for your
 case. http://docs.neo4j.org/chunked/snapshot/cypher-query-lang.html.
 Gremlin supports similar things.

One thing to realize about paging in Gremlin is that due to Pipes/Gremlin's 
lazy nature, there is no notion of  jump to cursor. For example:

g.v(1).out[5..10]

 will iterate/compute/evaluate/traverse the objects 0 through 4.

Just a heads up,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Gremlin performance?

2011-07-23 Thread Marko Rodriguez
Hey,

Groovy is only used to compile a statement like g.v(1).out.in.blah to a Pipes 
which is native Java. As such, once the compilation is complete (milliseconds), 
it is simply native Java (This is not completely true as there are some Gremlin 
specific pipes). Next, for the relationship between Blueprints Neo4jGraph and 
native EmbeddedGraphDatabase, see this from some time ago:

http://groups.google.com/group/gremlin-users/msg/c94dfef8352f68d3

In short, traversing 29.6 million things took:
5.6 seconds via EmbeddedGraphDatabase
6.0 seconds via Neo4jGraph

** As a side, the same experiment was run for OrientDB with a 7.2 (native 
OrientDB) vs. 7.9 (Blueprints OrientGraph).
http://groups.google.com/group/gremlin-users/msg/ff5c03e188efcffe

There is more discussion in that particular thread if you are interested.

Finally, with respect to production, I have many clients that use Gremlin in 
production. Here are the benefits of do so:
1. Traversal descriptions are concise and expressive.
- any arbitrary graph computation can be represented and 
evaluated.
- in language theoretic terms, it can recognize Turing complete 
paths.
2. Traversal descriptions can be expressed as classes in Groovy and 
thus, IDE friendly.
- syntax highlighting, easy to write test cases/debug, etc.
- See slides 234 and 235 from 
http://www.slideshare.net/slidarko/the-pathology-of-graph-databases

Thanks,
Marko.

http://markorodriguez.com

On Jul 23, 2011, at 2:30 AM, Michael Hunger wrote:

 If you look at the comments of the post -
 
 groovy is only that slow if you implement all the algorithm details in groovy 
 !
 
 Gremlin uses blueprints which is written in Java. Gremlin is just a DSL on 
 top of that API so it is just used for the construction of the underlying 
 pipeline.
 
 Anyway, easiest way to see if that holds true is to write a PoC for _your_ 
 domain, I think general 
 statements are difficult.
 
 But probably Marko has some nice performance benchmarks at hand.
 
 Michael
 
 Am 23.07.2011 um 09:51 schrieb Josef Holy:
 
 Hi all,
 
 has someone on this list any practical experience with using Gremlin for 
 traversing the EmbeddedGraphDatabase in a production environment? What 
 interests me is how it performs compared to the traversal algorithms written 
 directly against Neo4j APIs (using Traverser, TraversalDescription, ..etc). 
 
 As Gremlin runs on top of Groovy + Pipes + Blueprints, I would expect it to 
 be much slower than pure Neo4j Java APIs (but really SO much slower? 
 http://stronglytypedblog.blogspot.com/2009/07/java-vs-scala-vs-groovy-performance.html
  ) .
 
 
 Thanks for any comments/experiences!
 
 
 Josef.
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] Gremlin performance?

2011-07-23 Thread Marko Rodriguez
Hi,

Finally, one point to add.

If I only need to do a ShorestPath over a particular edge type or a find all 
paths between two vertices and I'm using Neo4j as the graph backend, then I 
will drop down and use Neo4j's Algo library. This is because their ShorestPath 
implementation is bi-directional (efficient) and I would have to write that in 
Gremlin as Gremlin doesn't provide out of the box textbook algorithm support.

TinkerPop plans an algo library for standard graph algorithms whose paths are 
defined by Pipes/Gremlin, but as of yet, it doesn't exist.
See http://markorodriguez.com/2011/02/08/property-graph-algorithms/

Thanks,
Marko.

http://markorodriguez.com

On Jul 23, 2011, at 9:16 AM, Marko Rodriguez wrote:

 Hey,
 
 Groovy is only used to compile a statement like g.v(1).out.in.blah to a 
 Pipes which is native Java. As such, once the compilation is complete 
 (milliseconds), it is simply native Java (This is not completely true as 
 there are some Gremlin specific pipes). Next, for the relationship between 
 Blueprints Neo4jGraph and native EmbeddedGraphDatabase, see this from some 
 time ago:
 
   http://groups.google.com/group/gremlin-users/msg/c94dfef8352f68d3
 
 In short, traversing 29.6 million things took:
   5.6 seconds via EmbeddedGraphDatabase
   6.0 seconds via Neo4jGraph
 
 ** As a side, the same experiment was run for OrientDB with a 7.2 (native 
 OrientDB) vs. 7.9 (Blueprints OrientGraph).
   http://groups.google.com/group/gremlin-users/msg/ff5c03e188efcffe
 
 There is more discussion in that particular thread if you are interested.
 
 Finally, with respect to production, I have many clients that use Gremlin in 
 production. Here are the benefits of do so:
   1. Traversal descriptions are concise and expressive.
   - any arbitrary graph computation can be represented and 
 evaluated.
   - in language theoretic terms, it can recognize Turing complete 
 paths.
   2. Traversal descriptions can be expressed as classes in Groovy and 
 thus, IDE friendly.
   - syntax highlighting, easy to write test cases/debug, etc.
   - See slides 234 and 235 from 
 http://www.slideshare.net/slidarko/the-pathology-of-graph-databases
   
 Thanks,
 Marko.
 
 http://markorodriguez.com
 
 On Jul 23, 2011, at 2:30 AM, Michael Hunger wrote:
 
 If you look at the comments of the post -
 
 groovy is only that slow if you implement all the algorithm details in 
 groovy !
 
 Gremlin uses blueprints which is written in Java. Gremlin is just a DSL on 
 top of that API so it is just used for the construction of the underlying 
 pipeline.
 
 Anyway, easiest way to see if that holds true is to write a PoC for _your_ 
 domain, I think general 
 statements are difficult.
 
 But probably Marko has some nice performance benchmarks at hand.
 
 Michael
 
 Am 23.07.2011 um 09:51 schrieb Josef Holy:
 
 Hi all,
 
 has someone on this list any practical experience with using Gremlin for 
 traversing the EmbeddedGraphDatabase in a production environment? What 
 interests me is how it performs compared to the traversal algorithms 
 written directly against Neo4j APIs (using Traverser, TraversalDescription, 
 ..etc). 
 
 As Gremlin runs on top of Groovy + Pipes + Blueprints, I would expect it to 
 be much slower than pure Neo4j Java APIs (but really SO much slower? 
 http://stronglytypedblog.blogspot.com/2009/07/java-vs-scala-vs-groovy-performance.html
  ) .
 
 
 Thanks for any comments/experiences!
 
 
 Josef.
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 

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


Re: [Neo4j] Cypher request with where clause on relations count

2011-07-21 Thread Marko Rodriguez
Hey,

 Request is working like a charm and is fast (around 6 objects are checked
 in my 2M node 6M rel DB). I have to check the result with the corresponding
 RDBMS KPI.

Nice.

 Thanks again !

No problem.

 I definitively have to take more time to learn Gremlin !


You are more than welcome to always ask questions on the Gremlin-users mailing 
list.
http://groups.google.com/group/gremlin-users
Or, if you prefer, I'm here too..  and right behind you as well. insert 
scream/

Have fun,
Marko.

http://markorodriguez.com

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


Re: [Neo4j] Cypher request with where clause on relations count

2011-07-20 Thread Marko Rodriguez
Hey guys,

 I have 2 kind of nodes (let's say A and B) which are related using a 
 relation of type 'USES'.
 I want to count all the type A nodes which have only 1 relation to B type 
 node and all the type A nodes which have more than one relation to B type 
 node.
 
 I am using neo4j server and I am currently trying to make a cypher request 
 for that : it would look like that :
 
 start A=(id,object_type,A) match (A)-[r:USES]-(B) where count(r)=1 return 
 count(A)

In Gremlin 1.2-SNAPSHOT, you can do:

m = [:];

g.idx('id')[[object_type,'A']].ifThenElse{it.out('USES'){it.object_type.equals('B')}.count()
 == 1}{_().groupCount(m){count of 1}}{_().groupCount(m){count  1}}

m will have two keys: count of 1 and count  1, with respective counts.



You can also do:

m = [:]

g.idx('id')[[object_type,'A']].groupCount{it.out('USES'){it.object_type.equals('B')}.count()
 == 1}

m will have two keys: true and false (true means count of 1).

or, if you want human readable keys


g.idx('id')[[object_type,'A']].groupCount{it.out('USES'){if(it.object_type.equals('B')}.count()
 == 1) count of 1 else count  1}

See ya,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] retrieve all relationships of a certain type (java)

2011-07-20 Thread Marko Rodriguez
Hey,

 How would I go about retrieving all nodes for a certain relationship Type
 (ie. assuming I don't know any of them nodes) ?


Use an index. I don't know in native Neo4j off the top of my head, but the 
analogous to this in Blueprints:

g.getIndex(edges, Edge.class).get(label,myType)

Indices allow you to group edges of similar label together.

See ya,
Marko.

http://markorodriguez.com

On Jul 20, 2011, at 12:54 PM, cyuczi eekc wrote:

 (in java code, the other
 variants rest/cypher I will probably not need to use)
 ie. rel.getAllNodes(Direction.INCOMING)
 or rel.getAllNodes(Direction.OUTGOING)
 or Direction.BOTH even
 But this is basically equivalent with retrieving all relationships that are
 of the specified relationship-type. So this would be more accurate:
 rel.getAllRelationships(); where rel is the Relationship of the type that we
 want and the getAllRelationships() would return something that would be a
 list of all relationship of that type (in the entire database I guess)
 
 but possibly _*without*_ having to iterate (or traverse?) all nodes(i guess
 starting from the reference node?), in order to find if each has the
 relationship type I'm looking for. (I haven't yet fully looked at traverse
 but I know it needs a starting node, even though this could probably be the
 reference node[?]; this makes me wonder if there's a traverser for
 relationships instead of just nodes - I am unsure where to look [maybe just
 pointing me there would be enough of a reply to this; thanks])
 
 The way I see it, the fact that relationships have a type  is an extra layer
 on top of the relationships (just as indexing is extra(independent) layer on
 top of nodes or relationships). So I see the relationships each being unique
 (especially since I can add the same-type relationship to the same two
 nodes, more than 1 time) and they are somehow coalesced together via the
 relationship-type. It's like the relationship-type is a set which contains a
 bunch of relationships (which are obviously unique ie. unique ID) and this
 set constitutes a relationship-type. So since it's a set (probably stored as
 key-value pairs on the low level) one could potentially just get the
 elements via an iterator or something (but I also want to know how many aka
 size or count, relationships are there, of this type). (what I find a bit
 odd though, is that you can have more than one relationship for the same two
 nodes (1: A-B ; 2: A-B ), although dwins(on irc) implied that this is
 allowed because each relationship can have key-value pairs(properties)
 associated with it, and thus one could use same key for each relationship
 but with different values, but the practicality for this escapes me)
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] Cypher request with where clause on relations count

2011-07-20 Thread Marko Rodriguez
Hey,

 @Marko thanks. I just tried to do it with Gremlin but I have not your
 knowledge of gremlin. I will try to do that.

If you use Neo4j Server 1.4, then you will be in Gremlin 1.1 land. I don't know 
what you are rolling with (embedded, server, etc.), but if you want the query 
in Gremlin 1.1, just ask.

Good luck,
Marko.

http://markorodriguez.com

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


Re: [Neo4j] Cypher request with where clause on relations count

2011-07-20 Thread Marko Rodriguez
 @Marko I am using neo4j 1.4 server so I guess I am running gremlin 1.1. 
 It would be cool if you can send me the compatible query when you have time.

Good, cause time is all I have. 

m = [:]

g.idx('id')[[object_type:'A']].transform{it.out('USES'){it.object_type.equals('B')}.count()
  1}.groupCount(m)  -1
m

Here is what it says section by section:

0. m = [:]: create a hashmap (your results)
1. g
- the graph
2. idx('id')[[object_type:'A']]
- hit the 'id' index for all vertices indexed with object_type 
equal to 'A'
3. transform{it.out('USES'){it.object_type.equals('B')}.count()  1}
- for each of those A-vertices, emit true if the number of 
times it connects to a B object by USES is  than 1, else emit false.
4. groupCount(m)
- count the number of trues and falses and stores the counts in 
the map m.
5.  -1
- while(hasNext()) next() the pipeline expression 
(http://pipes.tinkerpop.com if you are interested by what a pipeline is)
6. m
- return the map of counts.

Further diving into the transform{} step. The transform{} step takes an object 
(in your case, a vertex), does some computation, and emits an object (in your 
case, ...count()  1):
it.out('USES'){it.object_type.equals('B')}.count()
- it is the current vertex.
- get the vertices adjacent to it that are connected by USES 
edges (outgoing connections only -- use both('USES') for both in and out)
- filter to only those objects whose object_type is 'B'
- count the number of B-vertices traversed to.



Or for more human readable keys:

m = [:]

g.idx('id')[[object_type:'A']].transform{if(it.out('USES'){it.object_type.equals('B')}.count()
  1) count = 1 else count  1}.groupCount(m)  -1
m

Also, you can view this like this, if it helps:

m = [:]
g.idx('id')[[object_type:'A']].transform{
if(it.out('USES'){it.object_type.equals('B')}.count()  1) 
count = 1 
else 
count  1
}.groupCount(m)  -1
m

This is all typed out in email so you might need to fiddle if I missed some ( { 
'  etc.

Finally, there is a slight optimization if you want it to run a few 
milliseconds faster at the expense of more verbosity.
it.object_type.equals('B') is slower than 
it.getProperty('object_type').equals('B')

Tell me how it goes:
Marko.
http://markorodriguez.com

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


Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Marko Rodriguez
Hi Pere,

To sort you need to have all your results. 

Thus, in Gremlin (and hopefully you can do the mapping to the core Neo4j 
traverser framework),

results = []
g.v(1).out('friend').out('likes')  results // what my friends like
results.sort{a,b - a.name = b.name} // sort resultant vertices by name

In short, once you have the result of your traversal, you can then apply a 
comparator to the Collection to sort it as you please --- its just Java 
comparators.

See ya,
Marko.

http://markorodriguez.com

On Jul 15, 2011, at 8:06 AM, Pere Urbon Bayes wrote:

 HI!
 I am on the situation of having to traverse neo4j, and then expect the
 resultset returned to be ordered in a certain order. I've been researching a
 bit over the traversal API, but I did not find anything related to that. I
 really will appreciate any tip on that!!
 
 BTW  I expect to be possible right?, as we have in relational the ordering,
 or on redis, etc...
 
 /purbon
 
 -- 
 Pere Urbon-Bayes
 moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
 Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Marko Rodriguez
Hi,

Ah. Then I would recommend using a persistent data structure such as the one 
the Neil discussed in his follow up post.

Marko.

http://markorodriguez.com

On Jul 15, 2011, at 9:04 AM, Pere Urbon Bayes wrote:

 Well, this is great if I want to do all the math in memory, but I expect to
 do the computation by the db.
 
 / purbon
 
 On 15 July 2011 16:10, Marko Rodriguez okramma...@gmail.com wrote:
 
 Hi Pere,
 
 To sort you need to have all your results.
 
 Thus, in Gremlin (and hopefully you can do the mapping to the core Neo4j
 traverser framework),
 
 results = []
 g.v(1).out('friend').out('likes')  results // what my friends like
 results.sort{a,b - a.name = b.name} // sort resultant vertices by name
 
 In short, once you have the result of your traversal, you can then apply a
 comparator to the Collection to sort it as you please --- its just Java
 comparators.
 
 See ya,
 Marko.
 
 http://markorodriguez.com
 
 On Jul 15, 2011, at 8:06 AM, Pere Urbon Bayes wrote:
 
 HI!
 I am on the situation of having to traverse neo4j, and then expect the
 resultset returned to be ordered in a certain order. I've been
 researching a
 bit over the traversal API, but I did not find anything related to that.
 I
 really will appreciate any tip on that!!
 
 BTW  I expect to be possible right?, as we have in relational the
 ordering,
 or on redis, etc...
 
 /purbon
 
 --
 Pere Urbon-Bayes
 moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
 Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 
 
 
 -- 
 Pere Urbon-Bayes
 moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
 Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


Re: [Neo4j] [Blog Post] Graphs, Brains, and Gremlin

2011-07-15 Thread Marko Rodriguez
Hi Rick,

 Added a comment and a book recommendation to your blog.

Thanks. On Intelligence is the first reference in the references section of 
the post --- along with some other goodies.

Thanks for reading and commenting,
Marko.

http://markorodriguez.com

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


Re: [Neo4j] [Blog Post] Graphs, Brains, and Gremlin

2011-07-15 Thread Marko Rodriguez
 Nice.  It's a very though provoking (pun clearly intended) blog post.  I 
 need to read it a couple times to fully grok it.

I put many links to associated reading (primarily on Wikipedia). If you don't 
have experience with elementary cognitive neuroscience, then you can learn all 
you need to know by following the links. I can save you 2-years of tuition: 
read the blog post and the one-step away Wikipedia pages :)...and if you want a 
graduate-level understanding of cognitive neuroscience, go two-steps. If you 
want to understand even more, do a spreading activation through Wikipedia :).

Also, the HMAX diagram...
http://markorodriguez.files.wordpress.com/2011/07/hmax-model.png
...is an accurate diagram and if you can follow what its trying to represent, 
then it will give you a good understanding of the first layers of the visual 
cortex are doing. Part of my postdoctoral work was on this model which is a 
computational model of the visual cortex that is biologically realistic. Its a 
very cool model indeed. I have two references in the references section that 
point to further HMAX information.

Thanks again,
Marko.

http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Marko Rodriguez
Hi,

Pere, my last thought on this is that you might want to use something like 
JDBM2.

http://code.google.com/p/jdbm2/

It has a Maven2 dependency if you do it that way.

JDBM2 provides you some Java collection implementations that are persistent to 
disk...

See ya,
Marko.

http://markorodriguez.com

On Jul 15, 2011, at 12:22 PM, Pere Urbon Bayes wrote:

 Yeah! well to order in memory I can really deal with that task, for this I
 really don't need cypher. Don´t take it personally, I know you really want
 to promote your language, xD!
 
 - purbon
 
 PD: See you next graphdb meetup in Berlin!
 
 On 15 July 2011 19:37, Michael Hunger michael.hun...@neotechnology.comwrote:
 
 You might also try to use cypher for your traversal which is able to order
 (also in memory of course).
 
 See the screencast I did:
 http://neo4j.vidcaster.com/U2Y/introduction-to-cypher/
 
 It's even the same domain.
 
 Cheers
 
 Michael
 
 Am 15.07.2011 um 17:24 schrieb Rick Bullotta:
 
 But you couldn't easy do a complex traversal with an RDBMS. ;-)
 
 I suspect that even if you could write some magic SQL to do so, you'd
 almost certainly lose the benefits any optimized sorting/ordering that
 indices provide, so even the RDBMS would have to post-process the sort.
 
 If the traversal isn't complex or randomly deep, then Neo indexing +
 querying might work for you the same way an RDBMS might handle it.
 
 
 -Original Message-
 From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org]
 On Behalf Of Pere Urbon Bayes
 Sent: Friday, July 15, 2011 11:21 AM
 To: Neo4j user discussions
 Subject: Re: [Neo4j] Getting sorted results from a traversal
 
 Well, the thing is that the database can easy deal with that, as the
 relational system do.
 
 / purbon
 
 On 15 July 2011 17:08, Rick Bullotta rick.bullo...@thingworx.com
 wrote:
 
 The DB would do it in memory too, wouldn't it?  In the case of a complex
 traversal, indexes don't really apply, since the ordering and the
 traversal
 order are unrelated, so you'd generally need to sort in memory anyway.
 Whether you do it as you add elements to the traversed list of stuff
 or
 do it after the fact is another discussion, but I think in either case,
 it
 needs to be done after the fact.
 
 
 -Original Message-
 From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org
 ]
 On Behalf Of Pere Urbon Bayes
 Sent: Friday, July 15, 2011 11:05 AM
 To: Neo4j user discussions
 Subject: Re: [Neo4j] Getting sorted results from a traversal
 
 Well, this is great if I want to do all the math in memory, but I expect
 to
 do the computation by the db.
 
 / purbon
 
 On 15 July 2011 16:10, Marko Rodriguez okramma...@gmail.com wrote:
 
 Hi Pere,
 
 To sort you need to have all your results.
 
 Thus, in Gremlin (and hopefully you can do the mapping to the core
 Neo4j
 traverser framework),
 
 results = []
 g.v(1).out('friend').out('likes')  results // what my friends like
 results.sort{a,b - a.name = b.name} // sort resultant vertices by
 name
 
 In short, once you have the result of your traversal, you can then
 apply
 a
 comparator to the Collection to sort it as you please --- its just Java
 comparators.
 
 See ya,
 Marko.
 
 http://markorodriguez.com
 
 On Jul 15, 2011, at 8:06 AM, Pere Urbon Bayes wrote:
 
 HI!
 I am on the situation of having to traverse neo4j, and then expect the
 resultset returned to be ordered in a certain order. I've been
 researching a
 bit over the traversal API, but I did not find anything related to
 that.
 I
 really will appreciate any tip on that!!
 
 BTW  I expect to be possible right?, as we have in relational the
 ordering,
 or on redis, etc...
 
 /purbon
 
 --
 Pere Urbon-Bayes
 moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
 Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 
 
 
 --
 Pere Urbon-Bayes
 moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
 Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 
 
 
 --
 Pere Urbon-Bayes
 moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
 Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Marko Rodriguez
Hey,

Actually, I was just Googling and found this cool library:
http://code.google.com/p/pcollections/

This way you have Set, Vector, etc. persisted. Perhaps that could help you out 
Pere.

See ya,
Marko.

http://markorodriguez.com

On Jul 15, 2011, at 12:30 PM, Marko Rodriguez wrote:

 Hi,
 
 Pere, my last thought on this is that you might want to use something like 
 JDBM2.
 
   http://code.google.com/p/jdbm2/
 
 It has a Maven2 dependency if you do it that way.
 
 JDBM2 provides you some Java collection implementations that are persistent 
 to disk...
 
 See ya,
 Marko.
 
 http://markorodriguez.com
 
 On Jul 15, 2011, at 12:22 PM, Pere Urbon Bayes wrote:
 
 Yeah! well to order in memory I can really deal with that task, for this I
 really don't need cypher. Don´t take it personally, I know you really want
 to promote your language, xD!
 
 - purbon
 
 PD: See you next graphdb meetup in Berlin!
 
 On 15 July 2011 19:37, Michael Hunger 
 michael.hun...@neotechnology.comwrote:
 
 You might also try to use cypher for your traversal which is able to order
 (also in memory of course).
 
 See the screencast I did:
 http://neo4j.vidcaster.com/U2Y/introduction-to-cypher/
 
 It's even the same domain.
 
 Cheers
 
 Michael
 
 Am 15.07.2011 um 17:24 schrieb Rick Bullotta:
 
 But you couldn't easy do a complex traversal with an RDBMS. ;-)
 
 I suspect that even if you could write some magic SQL to do so, you'd
 almost certainly lose the benefits any optimized sorting/ordering that
 indices provide, so even the RDBMS would have to post-process the sort.
 
 If the traversal isn't complex or randomly deep, then Neo indexing +
 querying might work for you the same way an RDBMS might handle it.
 
 
 -Original Message-
 From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org]
 On Behalf Of Pere Urbon Bayes
 Sent: Friday, July 15, 2011 11:21 AM
 To: Neo4j user discussions
 Subject: Re: [Neo4j] Getting sorted results from a traversal
 
 Well, the thing is that the database can easy deal with that, as the
 relational system do.
 
 / purbon
 
 On 15 July 2011 17:08, Rick Bullotta rick.bullo...@thingworx.com
 wrote:
 
 The DB would do it in memory too, wouldn't it?  In the case of a complex
 traversal, indexes don't really apply, since the ordering and the
 traversal
 order are unrelated, so you'd generally need to sort in memory anyway.
 Whether you do it as you add elements to the traversed list of stuff
 or
 do it after the fact is another discussion, but I think in either case,
 it
 needs to be done after the fact.
 
 
 -Original Message-
 From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org
 ]
 On Behalf Of Pere Urbon Bayes
 Sent: Friday, July 15, 2011 11:05 AM
 To: Neo4j user discussions
 Subject: Re: [Neo4j] Getting sorted results from a traversal
 
 Well, this is great if I want to do all the math in memory, but I expect
 to
 do the computation by the db.
 
 / purbon
 
 On 15 July 2011 16:10, Marko Rodriguez okramma...@gmail.com wrote:
 
 Hi Pere,
 
 To sort you need to have all your results.
 
 Thus, in Gremlin (and hopefully you can do the mapping to the core
 Neo4j
 traverser framework),
 
 results = []
 g.v(1).out('friend').out('likes')  results // what my friends like
 results.sort{a,b - a.name = b.name} // sort resultant vertices by
 name
 
 In short, once you have the result of your traversal, you can then
 apply
 a
 comparator to the Collection to sort it as you please --- its just Java
 comparators.
 
 See ya,
 Marko.
 
 http://markorodriguez.com
 
 On Jul 15, 2011, at 8:06 AM, Pere Urbon Bayes wrote:
 
 HI!
 I am on the situation of having to traverse neo4j, and then expect the
 resultset returned to be ordered in a certain order. I've been
 researching a
 bit over the traversal API, but I did not find anything related to
 that.
 I
 really will appreciate any tip on that!!
 
 BTW  I expect to be possible right?, as we have in relational the
 ordering,
 or on redis, etc...
 
 /purbon
 
 --
 Pere Urbon-Bayes
 moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
 Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 
 
 
 --
 Pere Urbon-Bayes
 moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
 Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user
 
 
 
 
 --
 Pere Urbon-Bayes
 moviepilot GmbH | Mehringdamm 33 | 10961 Berlin | Germany
 Telefon +49 30 616 512 -110 | Fax +49 30 616 512 -133

Re: [Neo4j] Getting sorted results from a traversal

2011-07-15 Thread Marko Rodriguez
Hey,

 Isn't that pretty similar to what
 https://github.com/peterneubauer/graph-collectionshttps://github.com/peterneubauer/graph-collections/tree/master/src/main/java/org/neo4j/collections/sortedtree
 provides
 for Neo4j?

I dunno. I haven't played with Graph Collections. But I assume so if it 
implements Java Collections interfaces ? The reason I brought up JDBM2 is 
because Pere still didn't seem satisfied after Niels recommendation of using 
graph-collections (that was the first email response to Pere).

Just throwing stuff out there -- must...make..Pere...happy...

Marko.
http://markorodriguez.com
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] gremlin tables question

2011-07-15 Thread Marko Rodriguez
Hi,

Do:

t=new Table();v = g.v(2);v.outE.inV.as('node')[0..5].table(t)  -1; t;

Read the first trouble shooting for the reason: 
https://github.com/tinkerpop/gremlin/wiki/Troubleshooting

v.outE.inV.as('node')[0..5].table(t) returns an iterator.
v.outE.inV.as('node')[0..5].table(t)  -1 while(hasNext())s the 
iterator.

The Gremlin console will automagically iterate an iterator/iterable. In code 
mode, you need to iterate it yourself.  -1 does the trick.

Enjoy,
Marko.

http://markorodriguez.com

On Jul 15, 2011, at 8:05 PM, Boris Kizelshteyn wrote:

 this works:
 
   - gremlin t=new Table();v = g.v(2);v.outE.inV.as('node')[0..5].table(t);
   - == v[95]
   - == v[94]
   - == v[93]
   - == v[92]
   - == v[91]
   - == v[90]
   - gremlin t
   - == [node:v[95]]
   - == [node:v[94]]
   - == [node:v[93]]
   - == [node:v[92]]
   - == [node:v[91]]
   - == [node:v[90]]
 
 While this gives no results:
 
 t=new Table();v = g.v(2);v.outE.inV.as('node')[0..5].table(t); t;
 
 Why?
 
 Many thanks!
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

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


  1   2   3   >