neography-down 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.project +12 -0
- data/.rspec +1 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +939 -0
- data/CONTRIBUTORS +18 -0
- data/Gemfile +4 -0
- data/Guardfile +14 -0
- data/LICENSE +19 -0
- data/README.md +281 -0
- data/Rakefile +14 -0
- data/examples/facebook.rb +40 -0
- data/examples/facebook_v2.rb +25 -0
- data/examples/greatest.rb +43 -0
- data/examples/linkedin.rb +39 -0
- data/examples/linkedin_v2.rb +22 -0
- data/examples/traversal_example1.rb +65 -0
- data/examples/traversal_example2.rb +54 -0
- data/lib/neography.rb +45 -0
- data/lib/neography/config.rb +64 -0
- data/lib/neography/connection.rb +263 -0
- data/lib/neography/equal.rb +21 -0
- data/lib/neography/errors.rb +60 -0
- data/lib/neography/index.rb +52 -0
- data/lib/neography/multi_json_parser.rb +28 -0
- data/lib/neography/neography.rb +10 -0
- data/lib/neography/node.rb +63 -0
- data/lib/neography/node_path.rb +29 -0
- data/lib/neography/node_relationship.rb +37 -0
- data/lib/neography/node_traverser.rb +146 -0
- data/lib/neography/path_traverser.rb +100 -0
- data/lib/neography/property.rb +110 -0
- data/lib/neography/property_container.rb +28 -0
- data/lib/neography/railtie.rb +19 -0
- data/lib/neography/relationship.rb +78 -0
- data/lib/neography/relationship_traverser.rb +80 -0
- data/lib/neography/rest.rb +99 -0
- data/lib/neography/rest/batch.rb +414 -0
- data/lib/neography/rest/clean.rb +17 -0
- data/lib/neography/rest/constraints.rb +38 -0
- data/lib/neography/rest/cypher.rb +29 -0
- data/lib/neography/rest/extensions.rb +21 -0
- data/lib/neography/rest/gremlin.rb +20 -0
- data/lib/neography/rest/helpers.rb +96 -0
- data/lib/neography/rest/node_auto_indexes.rb +60 -0
- data/lib/neography/rest/node_indexes.rb +139 -0
- data/lib/neography/rest/node_labels.rb +49 -0
- data/lib/neography/rest/node_paths.rb +49 -0
- data/lib/neography/rest/node_properties.rb +52 -0
- data/lib/neography/rest/node_relationships.rb +33 -0
- data/lib/neography/rest/node_traversal.rb +25 -0
- data/lib/neography/rest/nodes.rb +94 -0
- data/lib/neography/rest/other_node_relationships.rb +38 -0
- data/lib/neography/rest/relationship_auto_indexes.rb +60 -0
- data/lib/neography/rest/relationship_indexes.rb +142 -0
- data/lib/neography/rest/relationship_properties.rb +52 -0
- data/lib/neography/rest/relationship_types.rb +11 -0
- data/lib/neography/rest/relationships.rb +16 -0
- data/lib/neography/rest/schema_indexes.rb +26 -0
- data/lib/neography/rest/spatial.rb +137 -0
- data/lib/neography/rest/transactions.rb +101 -0
- data/lib/neography/tasks.rb +207 -0
- data/lib/neography/version.rb +3 -0
- data/neography.gemspec +39 -0
- data/spec/integration/authorization_spec.rb +40 -0
- data/spec/integration/broken_spatial_spec.rb +28 -0
- data/spec/integration/index_spec.rb +71 -0
- data/spec/integration/neography_spec.rb +10 -0
- data/spec/integration/node_encoding_spec.rb +71 -0
- data/spec/integration/node_path_spec.rb +222 -0
- data/spec/integration/node_relationship_spec.rb +381 -0
- data/spec/integration/node_spec.rb +260 -0
- data/spec/integration/parsing_spec.rb +13 -0
- data/spec/integration/performance_spec.rb +17 -0
- data/spec/integration/relationship_spec.rb +37 -0
- data/spec/integration/rest_batch_no_streaming_spec.rb +41 -0
- data/spec/integration/rest_batch_spec.rb +604 -0
- data/spec/integration/rest_batch_streaming_spec.rb +51 -0
- data/spec/integration/rest_bulk_spec.rb +106 -0
- data/spec/integration/rest_constraints_spec.rb +72 -0
- data/spec/integration/rest_experimental_spec.rb +22 -0
- data/spec/integration/rest_gremlin_fail_spec.rb +46 -0
- data/spec/integration/rest_header_spec.rb +15 -0
- data/spec/integration/rest_index_spec.rb +481 -0
- data/spec/integration/rest_labels_spec.rb +128 -0
- data/spec/integration/rest_node_spec.rb +274 -0
- data/spec/integration/rest_other_node_relationship_spec.rb +137 -0
- data/spec/integration/rest_path_spec.rb +231 -0
- data/spec/integration/rest_plugin_spec.rb +177 -0
- data/spec/integration/rest_relationship_spec.rb +354 -0
- data/spec/integration/rest_relationship_types_spec.rb +18 -0
- data/spec/integration/rest_schema_index_spec.rb +32 -0
- data/spec/integration/rest_spatial_spec.rb +166 -0
- data/spec/integration/rest_transaction_spec.rb +166 -0
- data/spec/integration/rest_traverse_spec.rb +149 -0
- data/spec/integration/unmanaged_spec.rb +27 -0
- data/spec/matchers.rb +33 -0
- data/spec/neography_spec.rb +23 -0
- data/spec/spec_helper.rb +44 -0
- data/spec/unit/config_spec.rb +135 -0
- data/spec/unit/connection_spec.rb +284 -0
- data/spec/unit/node_spec.rb +100 -0
- data/spec/unit/properties_spec.rb +285 -0
- data/spec/unit/relationship_spec.rb +118 -0
- data/spec/unit/rest/batch_spec.rb +262 -0
- data/spec/unit/rest/clean_spec.rb +16 -0
- data/spec/unit/rest/constraints_spec.rb +45 -0
- data/spec/unit/rest/cypher_spec.rb +20 -0
- data/spec/unit/rest/extensions_spec.rb +28 -0
- data/spec/unit/rest/gremlin_spec.rb +25 -0
- data/spec/unit/rest/helpers_spec.rb +124 -0
- data/spec/unit/rest/labels_spec.rb +77 -0
- data/spec/unit/rest/node_auto_indexes_spec.rb +70 -0
- data/spec/unit/rest/node_indexes_spec.rb +140 -0
- data/spec/unit/rest/node_paths_spec.rb +77 -0
- data/spec/unit/rest/node_properties_spec.rb +79 -0
- data/spec/unit/rest/node_relationships_spec.rb +57 -0
- data/spec/unit/rest/node_traversal_spec.rb +35 -0
- data/spec/unit/rest/nodes_spec.rb +187 -0
- data/spec/unit/rest/relationship_auto_indexes_spec.rb +66 -0
- data/spec/unit/rest/relationship_indexes_spec.rb +132 -0
- data/spec/unit/rest/relationship_properties_spec.rb +79 -0
- data/spec/unit/rest/relationship_types_spec.rb +15 -0
- data/spec/unit/rest/relationships_spec.rb +21 -0
- data/spec/unit/rest/schema_index_spec.rb +30 -0
- data/spec/unit/rest/transactions_spec.rb +43 -0
- metadata +372 -0
data/CONTRIBUTORS
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Maintainer:
|
|
2
|
+
Max De Marzi <maxdemarzi at gmail dot com>
|
|
3
|
+
|
|
4
|
+
Contributors:
|
|
5
|
+
* Peter Neubauer
|
|
6
|
+
* Ian Dees
|
|
7
|
+
* Phuong CAO
|
|
8
|
+
* Carlo Alberto Degli Atti
|
|
9
|
+
* Stephen Becker IV
|
|
10
|
+
* Thomas Baum
|
|
11
|
+
* Maximilian Schulz
|
|
12
|
+
* Hesham Amiri
|
|
13
|
+
* Pablo Fernandez
|
|
14
|
+
* Nick Reavill
|
|
15
|
+
* Marcel Sherf
|
|
16
|
+
* David Pitman
|
|
17
|
+
* Garrett Heaver
|
|
18
|
+
* Roel van Dijk
|
data/Gemfile
ADDED
data/Guardfile
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# A sample Guardfile
|
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
|
3
|
+
|
|
4
|
+
guard :rspec do
|
|
5
|
+
# Just rerun the whole suite until the file names are matching
|
|
6
|
+
# in lib/ and spec/
|
|
7
|
+
#
|
|
8
|
+
# watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
|
9
|
+
# watch(%r{^lib/(.+)\.rb$}) { |m| "spec/unit/lib/#{m[1]}_spec.rb" }
|
|
10
|
+
watch(%r{^lib/(.+)\.rb$}) { "spec" }
|
|
11
|
+
|
|
12
|
+
watch(%r{^spec/.+_spec\.rb$})
|
|
13
|
+
watch('spec/spec_helper.rb') { "spec" }
|
|
14
|
+
end
|
data/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2010 Max De Marzi
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
Neography
|
|
2
|
+
=========
|
|
3
|
+
|
|
4
|
+
- [](https://rubygems.org/gems/neography)
|
|
5
|
+
- [](http://travis-ci.org/maxdemarzi/neography)
|
|
6
|
+
- [](https://codeclimate.com/github/maxdemarzi/neography)
|
|
7
|
+
- [](https://coveralls.io/r/maxdemarzi/neography)
|
|
8
|
+
|
|
9
|
+
## Welcome to Neography
|
|
10
|
+
|
|
11
|
+
Neography is a thin Ruby wrapper to the Neo4j Rest API, for more information:
|
|
12
|
+
|
|
13
|
+
* [Getting Started with Neo4j Server](http://neo4j.org/community/)
|
|
14
|
+
* [Neo4j Rest API Reference](http://docs.neo4j.org/chunked/milestone/rest-api.html)
|
|
15
|
+
|
|
16
|
+
If you want to utilize the full power of Neo4j, you will want to use JRuby and the excellent Neo4j.rb gem at https://github.com/andreasronge/neo4j by Andreas Ronge
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
### Gemfile
|
|
22
|
+
|
|
23
|
+
Add `neography` to your Gemfile:
|
|
24
|
+
|
|
25
|
+
```ruby
|
|
26
|
+
gem 'neography'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
And run Bundler:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
$ bundle
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Manually:
|
|
36
|
+
|
|
37
|
+
Or install `neography` manually:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
$ gem install 'neography'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
And require the gem in your Ruby code:
|
|
44
|
+
|
|
45
|
+
```ruby
|
|
46
|
+
require 'rubygems'
|
|
47
|
+
require 'neography'
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Read the wiki for information about [dependencies](https://github.com/maxdemarzi/neography/wiki/Dependencies).
|
|
51
|
+
|
|
52
|
+
[Rake tasks](https://github.com/maxdemarzi/neography/wiki/Rake-tasks) are available for downloading, installing and running Neo4j.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
## Usage
|
|
56
|
+
|
|
57
|
+
### Configuration and initialization
|
|
58
|
+
|
|
59
|
+
Configure Neography as follows:
|
|
60
|
+
|
|
61
|
+
```ruby
|
|
62
|
+
# these are the default values:
|
|
63
|
+
Neography.configure do |config|
|
|
64
|
+
config.protocol = "http://"
|
|
65
|
+
config.server = "localhost"
|
|
66
|
+
config.port = 7474
|
|
67
|
+
config.directory = "" # prefix this path with '/'
|
|
68
|
+
config.cypher_path = "/cypher"
|
|
69
|
+
config.gremlin_path = "/ext/GremlinPlugin/graphdb/execute_script"
|
|
70
|
+
config.log_file = "neography.log"
|
|
71
|
+
config.log_enabled = false
|
|
72
|
+
config.slow_log_threshold = 0 # time in ms for query logging
|
|
73
|
+
config.max_threads = 20
|
|
74
|
+
config.authentication = nil # 'basic' or 'digest'
|
|
75
|
+
config.username = nil
|
|
76
|
+
config.password = nil
|
|
77
|
+
config.parser = MultiJsonParser
|
|
78
|
+
config.http_send_timeout = 1200
|
|
79
|
+
config.http_receive_timeout = 1200
|
|
80
|
+
end
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Then initialize a `Rest` instance:
|
|
84
|
+
|
|
85
|
+
```ruby
|
|
86
|
+
@neo = Neography::Rest.new
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
For overriding these default and other initialization methods, see the
|
|
90
|
+
[configuration and initialization](https://github.com/maxdemarzi/neography/wiki/Configuration-and-initialization) page in the Wiki.
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
### REST API
|
|
94
|
+
|
|
95
|
+
Neography supports the creation and retrieval of nodes and relationships through the Neo4j REST interface.
|
|
96
|
+
It supports indexes, Gremlin scripts, Cypher queries and batch operations.
|
|
97
|
+
|
|
98
|
+
Some of this functionality is shown here, but all of it is explained in the following Wiki pages:
|
|
99
|
+
|
|
100
|
+
2.0 Only features:
|
|
101
|
+
|
|
102
|
+
* [Schema indexes](https://github.com/maxdemarzi/neography/wiki/Schema-indexes) - Create, get and delete schema indexes.
|
|
103
|
+
* [Node labels](https://github.com/maxdemarzi/neography/wiki/Node-labels) - Create, get and delete node labels.
|
|
104
|
+
* [Transactions](https://github.com/maxdemarzi/neography/wiki/Transactions) - Begin, add to, commit, rollback transactions.
|
|
105
|
+
|
|
106
|
+
1.8+ features:
|
|
107
|
+
|
|
108
|
+
* [Nodes](https://github.com/maxdemarzi/neography/wiki/Nodes) - Create, get and delete nodes.
|
|
109
|
+
* [Node properties](https://github.com/maxdemarzi/neography/wiki/Node-properties) - Set, get and remove node properties.
|
|
110
|
+
* [Node relationships](https://github.com/maxdemarzi/neography/wiki/Node-relationships) - Create and get relationships between nodes.
|
|
111
|
+
* [Relationship](https://github.com/maxdemarzi/neography/wiki/Relationships) - Get and delete relationships.
|
|
112
|
+
* [Relationship properties](https://github.com/maxdemarzi/neography/wiki/Relationship-properties) - Create, get and delete relationship properties.
|
|
113
|
+
* [Relationship types](https://github.com/maxdemarzi/neography/wiki/Relationship-types) - List relationship types.
|
|
114
|
+
* [Node indexes](https://github.com/maxdemarzi/neography/wiki/Node-indexes) - List and create node indexes. Add, remove, get and search nodes in indexes.
|
|
115
|
+
* [Relationship indexes](https://github.com/maxdemarzi/neography/wiki/Relationship-indexes) - List and create relationships indexes. Add, remove, get and search relationships in indexes.
|
|
116
|
+
* [Auto indexes](https://github.com/maxdemarzi/neography/wiki/Auto-indexes) - Get, set and remove auto indexes.
|
|
117
|
+
* [Scripts and queries](https://github.com/maxdemarzi/neography/wiki/Scripts-and-queries) - Run Gremlin scripts and Cypher queries.
|
|
118
|
+
* [Paths and traversal](https://github.com/maxdemarzi/neography/wiki/Paths-and-traversal) - Paths between nodes and path traversal.
|
|
119
|
+
* [Batch](https://github.com/maxdemarzi/neography/wiki/Batch) - Execute multiple calls at once.
|
|
120
|
+
* [Errors](https://github.com/maxdemarzi/neography/wiki/Errors) - Errors raised if REST API calls fail.
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
Some example usage:
|
|
124
|
+
|
|
125
|
+
```ruby
|
|
126
|
+
# Node creation:
|
|
127
|
+
node1 = @neo.create_node("age" => 31, "name" => "Max")
|
|
128
|
+
node2 = @neo.create_node("age" => 33, "name" => "Roel")
|
|
129
|
+
|
|
130
|
+
# Node properties:
|
|
131
|
+
@neo.set_node_properties(node1, {"weight" => 200})
|
|
132
|
+
|
|
133
|
+
# Relationships between nodes:
|
|
134
|
+
@neo.create_relationship("coding_buddies", node1, node2)
|
|
135
|
+
|
|
136
|
+
# Get node relationships:
|
|
137
|
+
@neo.get_node_relationships(node2, "in", "coding_buddies")
|
|
138
|
+
|
|
139
|
+
# Use indexes:
|
|
140
|
+
@neo.add_node_to_index("people", "name", "max", node1)
|
|
141
|
+
@neo.get_node_index("people", "name", "max")
|
|
142
|
+
|
|
143
|
+
# Batches:
|
|
144
|
+
@neo.batch [:create_node, {"name" => "Max"}],
|
|
145
|
+
[:create_node, {"name" => "Marc"}]
|
|
146
|
+
|
|
147
|
+
# Cypher queries:
|
|
148
|
+
@neo.execute_query("start n=node(0) return n")
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
You can also use the [cypher gem](https://github.com/andreasronge/neo4j-cypher) instead of writing cypher as text.
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
node(1).outgoing(rel(:friends).where{|r| r[:since] == 1994})
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
would become:
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
START me=node(1)
|
|
163
|
+
MATCH (me)-[friend_rel:`friends`]->(friends)
|
|
164
|
+
WHERE (friend_rel.since = 1994)
|
|
165
|
+
RETURN friends
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
This is just a small sample of the full API, see the [Wiki documentation](https://github.com/maxdemarzi/neography/wiki) for the full API.
|
|
169
|
+
|
|
170
|
+
Neography raises REST API errors as Ruby errors, see the wiki page about [errors](https://github.com/maxdemarzi/neography/wiki/Errors).
|
|
171
|
+
(**Note**: older versions of Neography did not raise any errors!)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
## *Phase 2*
|
|
175
|
+
|
|
176
|
+
Trying to mimic the [Neo4j.rb API](https://github.com/andreasronge/neo4j/wiki/Neo4j%3A%3ACore-Nodes-Properties-Relationships).
|
|
177
|
+
|
|
178
|
+
Now we are returning full objects. The properties of the node or relationship can be accessed directly (`node.name`).
|
|
179
|
+
The Neo4j ID is available by using `node.neo_id`.
|
|
180
|
+
|
|
181
|
+
Some of this functionality is shown here, but all of it is explained in the following Wiki pages:
|
|
182
|
+
|
|
183
|
+
* [Nodes](https://github.com/maxdemarzi/neography/wiki/Phase-2-Nodes) - Create, load and delete nodes.
|
|
184
|
+
* [Node properties](https://github.com/maxdemarzi/neography/wiki/Phase-2-Node-properties) - Add, get and remove node properties.
|
|
185
|
+
* [Node relationships](https://github.com/maxdemarzi/neography/wiki/Phase-2-Node-relationships) - Create and retrieve node relationships.
|
|
186
|
+
* [Node paths](https://github.com/maxdemarzi/neography/wiki/Phase-2-Node-paths) - Gets paths between nodes.
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
```ruby
|
|
190
|
+
# create two nodes:
|
|
191
|
+
n1 = Neography::Node.create("age" => 31, "name" => "Max")
|
|
192
|
+
n2 = Neography::Node.create("age" => 33, "name" => "Roel")
|
|
193
|
+
|
|
194
|
+
n1.exist? # => true
|
|
195
|
+
|
|
196
|
+
# get and change some properties:
|
|
197
|
+
n1[:age] # => 31
|
|
198
|
+
n1.name # => "Max"
|
|
199
|
+
n1[:age] = 32 # change property
|
|
200
|
+
n1.weight = 190 # new property
|
|
201
|
+
n1.age = nil # remove property
|
|
202
|
+
|
|
203
|
+
# add a relationship between nodes:
|
|
204
|
+
new_rel = Neography::Relationship.create(:coding_buddies, n1, n2)
|
|
205
|
+
|
|
206
|
+
# remove a relationship:
|
|
207
|
+
new_rel.del
|
|
208
|
+
|
|
209
|
+
# add a relationship on nodes:
|
|
210
|
+
n1.outgoing(:coding_buddies) << n2
|
|
211
|
+
|
|
212
|
+
# more advanced relationship traversal:
|
|
213
|
+
n1.outgoing(:friends) # Get nodes related by outgoing friends relationship
|
|
214
|
+
n1.outgoing(:friends).depth(2).include_start_node # Get n1 and nodes related by friends and friends of friends
|
|
215
|
+
|
|
216
|
+
n1.rel?(:outgoing, :friends) # Has outgoing friends relationship
|
|
217
|
+
n1.rels(:friends,:work).outgoing # Get outgoing friends and work relationships
|
|
218
|
+
|
|
219
|
+
n1.all_paths_to(n2).incoming(:friends).depth(4) # Gets all paths of a specified type
|
|
220
|
+
n1.shortest_path_to(n2).incoming(:friends).depth(4).nodes # Gets just nodes in path
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
This is just a small sample of the full API, see the [Wiki documentation](https://github.com/maxdemarzi/neography/wiki) for the full API.
|
|
224
|
+
|
|
225
|
+
## More
|
|
226
|
+
|
|
227
|
+
### Examples
|
|
228
|
+
|
|
229
|
+
Some [example code](https://github.com/maxdemarzi/neography/wiki/Examples).
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
### Testing
|
|
233
|
+
|
|
234
|
+
Some [tips about testing](https://github.com/maxdemarzi/neography/wiki/Testing).
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
### Related Neo4j projects
|
|
238
|
+
|
|
239
|
+
Complement to Neography are the:
|
|
240
|
+
|
|
241
|
+
* [Neo4j Active Record Adapter](https://github.com/yournextleap/activerecord-neo4j-adapter) by Nikhil Lanjewar
|
|
242
|
+
* [Neology](https://github.com/lordkada/neology) by Carlo Alberto Degli Atti
|
|
243
|
+
* [Neoid](https://github.com/elado/neoid) by Elad Ossadon
|
|
244
|
+
|
|
245
|
+
An alternative to Neography is [Architect4r](https://github.com/namxam/architect4r) by Maximilian Schulz
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
### Neography in the Wild
|
|
249
|
+
|
|
250
|
+
* [Vouched](http://getvouched.com)
|
|
251
|
+
* [Neovigator](http://neovigator.herokuapp.com) fork it at https://github.com/maxdemarzi/neovigator
|
|
252
|
+
* [Neoflix](http://neoflix.herokuapp.com) fork it at https://github.com/maxdemarzi/neoflix
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
### Getting started with Neography
|
|
256
|
+
|
|
257
|
+
* [Getting Started with Ruby and Neo4j](http://maxdemarzi.com/2012/01/04/getting-started-with-ruby-and-neo4j/)
|
|
258
|
+
* [Graph visualization with Neo4j](http://maxdemarzi.com/2012/01/11/graph-visualization-and-neo4j/)
|
|
259
|
+
* [Neo4j on Heroku](http://maxdemarzi.com/2012/01/13/neo4j-on-heroku-part-one/)
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
## Contributing
|
|
263
|
+
|
|
264
|
+
Please create a [new issue](https://github.com/maxdemarzi/neography/issues) if you run into any bugs.
|
|
265
|
+
|
|
266
|
+
Contribute patches via [pull requests](https://github.com/maxdemarzi/neography/pulls).
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
## Help
|
|
270
|
+
|
|
271
|
+
If you are just starting out, or need help send me an e-mail at maxdemarzi@gmail.com.
|
|
272
|
+
|
|
273
|
+
Check you my blog at http://maxdemarzi.com where I have more Neography examples.
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
## Licenses
|
|
277
|
+
|
|
278
|
+
* Neography - MIT, see the LICENSE file http://github.com/maxdemarzi/neography/tree/master/LICENSE.
|
|
279
|
+
* Lucene - Apache, see http://lucene.apache.org/java/docs/features.html
|
|
280
|
+
* Neo4j - Dual free software/commercial license, see http://neo4j.org
|
|
281
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'bundler'
|
|
2
|
+
Bundler::GemHelper.install_tasks
|
|
3
|
+
|
|
4
|
+
require 'rspec/core/rake_task'
|
|
5
|
+
require 'neography/tasks'
|
|
6
|
+
|
|
7
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
|
8
|
+
t.rspec_opts = "--color"
|
|
9
|
+
t.pattern = "spec/**/*_spec.rb"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
desc "Run Tests"
|
|
13
|
+
task :default => :spec
|
|
14
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'neography'
|
|
3
|
+
|
|
4
|
+
@neo = Neography::Rest.new
|
|
5
|
+
|
|
6
|
+
def create_person(name)
|
|
7
|
+
@neo.create_node("name" => name)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def make_mutual_friends(node1, node2)
|
|
11
|
+
@neo.create_relationship("friends", node1, node2)
|
|
12
|
+
@neo.create_relationship("friends", node2, node1)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def suggestions_for(node)
|
|
16
|
+
@neo.traverse(node,"nodes", {"order" => "breadth first",
|
|
17
|
+
"uniqueness" => "node global",
|
|
18
|
+
"relationships" => {"type"=> "friends", "direction" => "in"},
|
|
19
|
+
"return filter" => {
|
|
20
|
+
"language" => "javascript",
|
|
21
|
+
"body" => "position.length() == 2;"},
|
|
22
|
+
"depth" => 2})
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
johnathan = create_person('Johnathan')
|
|
26
|
+
mark = create_person('Mark')
|
|
27
|
+
phill = create_person('Phill')
|
|
28
|
+
mary = create_person('Mary')
|
|
29
|
+
luke = create_person('Luke')
|
|
30
|
+
|
|
31
|
+
make_mutual_friends(johnathan, mark)
|
|
32
|
+
make_mutual_friends(mark, mary)
|
|
33
|
+
make_mutual_friends(mark, phill)
|
|
34
|
+
make_mutual_friends(phill, mary)
|
|
35
|
+
make_mutual_friends(phill, luke)
|
|
36
|
+
|
|
37
|
+
puts "Johnathan should become friends with #{suggestions_for(johnathan).map{|n| n["data"]["name"]}.join(', ')}"
|
|
38
|
+
|
|
39
|
+
# RESULT
|
|
40
|
+
# Johnathan should become friends with Mary, Phill
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'neography'
|
|
3
|
+
|
|
4
|
+
@neo = Neography::Rest.new
|
|
5
|
+
|
|
6
|
+
def suggestions_for(node)
|
|
7
|
+
node.incoming(:friends).order("breadth first").uniqueness("node global").filter("position.length() == 2;").depth(2)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
johnathan = Neography::Node.create("name" =>'Johnathan')
|
|
11
|
+
mark = Neography::Node.create("name" =>'Mark')
|
|
12
|
+
phill = Neography::Node.create("name" =>'Phill')
|
|
13
|
+
mary = Neography::Node.create("name" =>'Mary')
|
|
14
|
+
luke = Neography::Node.create("name" =>'Luke')
|
|
15
|
+
|
|
16
|
+
johnathan.both(:friends) << mark
|
|
17
|
+
mark.both(:friends) << mary
|
|
18
|
+
mark.both(:friends) << phill
|
|
19
|
+
phill.both(:friends) << mary
|
|
20
|
+
phill.both(:friends) << luke
|
|
21
|
+
|
|
22
|
+
puts "Johnathan should become friends with #{suggestions_for(johnathan).map{|n| n.name }.join(', ')}"
|
|
23
|
+
|
|
24
|
+
# RESULT
|
|
25
|
+
# Johnathan should become friends with Mary, Phill
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'neography'
|
|
3
|
+
|
|
4
|
+
def create_great(name)
|
|
5
|
+
Neography::Node.create("name" => name)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
game = create_great('The 1958 NFL Championship Game')
|
|
9
|
+
brando = create_great('Marlon Brando')
|
|
10
|
+
alex = create_great('Alexander the Great')
|
|
11
|
+
circus = create_great('The Ringling Bros. and Barnum and Bailey')
|
|
12
|
+
beatles = create_great('The Beatles')
|
|
13
|
+
ali = create_great('Muhammad Ali')
|
|
14
|
+
bread = create_great('Sliced Bread')
|
|
15
|
+
gatsby = create_great('The Great Gatsby')
|
|
16
|
+
|
|
17
|
+
greats = [game,brando,alex,circus,beatles,ali,bread,gatsby]
|
|
18
|
+
|
|
19
|
+
def as_great(great, other_greats)
|
|
20
|
+
other_greats.each do |og|
|
|
21
|
+
great.outgoing(:as_great) << og
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
greats.each do |g|
|
|
26
|
+
ogs = greats.select{|v| v != g }.sample(1 + rand(5))
|
|
27
|
+
as_great(g, ogs)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def the_greatest
|
|
31
|
+
neo = Neography::Rest.new
|
|
32
|
+
neo.execute_script("m = [:];
|
|
33
|
+
c = 0;
|
|
34
|
+
g.
|
|
35
|
+
V.
|
|
36
|
+
out.
|
|
37
|
+
groupCount(m).
|
|
38
|
+
loop(2){c++ < 1000}.iterate();
|
|
39
|
+
|
|
40
|
+
m.sort{a,b -> b.value <=> a.value}.keySet().name[0];")
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
puts "The greatest is #{the_greatest}"
|