Module: Neo4j::Core::Traversal
- Included in:
- Node
- Defined in:
- lib/neo4j-core/traversal/traversal.rb,
lib/neo4j-core/traversal/traverser.rb,
lib/neo4j-core/traversal/evaluator.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, Traverser
Instance Method Summary (collapse)
-
- (Neo4j::Core::Traversal::Traverser) both(type = nil)
Returns both incoming and outgoing nodes of given types(s).
-
- (Neo4j::Core::Traversal::Traverser) eval_paths(&eval_block)
Traverse using a block.
-
- (Neo4j::Core::Traversal::Traverser) expand {|node| ... }
A more powerful alternative of #outgoing, #incoming and #both method.
-
- (Neo4j::Core::Traversal::Traverser) incoming(type)
Returns the incoming nodes of given type(s).
-
- (Neo4j::Core::Traversal::Traverser) outgoing(type)
Returns the outgoing nodes for this node.
-
- (Neo4j::Core::Traversal::Traverser) unique(u)
Sets uniqueness of nodes or relationships to visit during a traversals.
Instance Method Details
- (Neo4j::Core::Traversal::Traverser) both(type = nil)
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 |
- (Neo4j::Core::Traversal::Traverser) eval_paths(&eval_block)
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 |
- (Neo4j::Core::Traversal::Traverser) expand {|node| ... }
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 |
- (Neo4j::Core::Traversal::Traverser) incoming(type)
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 |
- (Neo4j::Core::Traversal::Traverser) outgoing(type)
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 |
- (Neo4j::Core::Traversal::Traverser) unique(u)
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 |