Module: Neo4j::Core::Traversal
- Includes:
- ToJava
- Included in:
- Node
- Defined in:
- lib/neo4j-core/traversal/traversal.rb,
lib/neo4j-core/traversal/evaluator.rb,
lib/neo4j-core/traversal/traverser.rb,
lib/neo4j-core/traversal/rel_expander.rb,
lib/neo4j-core/traversal/prune_evaluator.rb,
lib/neo4j-core/traversal/filter_predicate.rb
Overview
Contains methods that are mixin for Neo4j::Node The builder pattern is used to construct traversals (all methods returns Neo4j::Traversal::Traverser)
Defined Under Namespace
Classes: CypherQuery, Evaluator, FilterPredicate, PruneEvaluator, RelExpander, Traverser
Instance Method Summary collapse
-
#both(type = nil) ⇒ Neo4j::Core::Traversal::Traverser
Returns both incoming and outgoing nodes of given types(s).
-
#eval_paths(&eval_block) ⇒ Neo4j::Core::Traversal::Traverser
Traverse using a block.
-
#expand {|node| ... } ⇒ Neo4j::Core::Traversal::Traverser
A more powerful alternative of #outgoing, #incoming and #both method.
-
#incoming(type) ⇒ Neo4j::Core::Traversal::Traverser
Returns the incoming nodes of given type(s).
-
#outgoing(type) ⇒ Neo4j::Core::Traversal::Traverser
Returns the outgoing nodes for this node.
-
#unique(u) ⇒ Neo4j::Core::Traversal::Traverser
Sets uniqueness of nodes or relationships to visit during a traversals.
Methods included from ToJava
dir_from_java, dir_to_java, type_to_java, types_to_java
Instance Method Details
#both(type = nil) ⇒ Neo4j::Core::Traversal::Traverser
Returns both incoming and outgoing nodes of given types(s)
If a type is not given then it will return all types of relationships.
83 84 85 |
# File 'lib/neo4j-core/traversal/traversal.rb', line 83 def both(type=nil) Traverser.new(self, :both, type) end |
#eval_paths(&eval_block) ⇒ Neo4j::Core::Traversal::Traverser
Traverse using a block. The block is expected to return one of the following values:
-
:exclude_and_continue
-
:exclude_and_prune
-
:include_and_continue
-
:include_and_prune
This value decides if it should continue to traverse and if it should include the node in the traversal result. The block will receive a path argument.
See also
-
How to use - neo4j.rubyforge.org/guides/traverser.html
-
the path parameter - api.neo4j.org/1.4/org/neo4j/graphdb/Path.html
-
the #unique method - if paths should be visit more the once, etc…
106 107 108 |
# File 'lib/neo4j-core/traversal/traversal.rb', line 106 def eval_paths(&eval_block) Traverser.new(self).eval_paths(&eval_block) end |
#expand {|node| ... } ⇒ Neo4j::Core::Traversal::Traverser
A more powerful alternative of #outgoing, #incoming and #both method. You can use this method for example to only traverse nodes based on properties on the relationships
26 27 28 |
# File 'lib/neo4j-core/traversal/traversal.rb', line 26 def (&) Traverser.new(self).(&) end |
#incoming(type) ⇒ Neo4j::Core::Traversal::Traverser
Returns the incoming nodes of given type(s).
73 74 75 |
# File 'lib/neo4j-core/traversal/traversal.rb', line 73 def incoming(type) Traverser.new(self, :incoming, type) end |
#outgoing(type) ⇒ Neo4j::Core::Traversal::Traverser
Returns the outgoing nodes for this node.
Of course all the methods outgoing
, incoming
, both
, depth
, include_start_node
, filter
, and prune
, eval_paths
, unique
can be combined.
62 63 64 |
# File 'lib/neo4j-core/traversal/traversal.rb', line 62 def outgoing(type) Traverser.new(self, :outgoing, type) end |
#unique(u) ⇒ Neo4j::Core::Traversal::Traverser
Sets uniqueness of nodes or relationships to visit during a traversals.
Allowed values
-
:node_global
A node cannot be traversed more than once (default) -
:node_path
For each returned node there ‘s a unique path from the start node to it. -
:node_recent
This is like :node_global, but only guarantees uniqueness among the most recent visited nodes, with a configurable count. -
:none
No restriction (the user will have to manage it). -
:rel_global
A relationship cannot be traversed more than once, whereas nodes can. -
:rel_path
No restriction (the user will have to manage it). -
:rel_recent
Same as for :node_recent, but for relationships.
125 126 127 |
# File 'lib/neo4j-core/traversal/traversal.rb', line 125 def unique(u) Traverser.new(self).unique(u) end |