Module: Pacer::Core::Graph::EdgesRoute

Included in:
Wrappers::EdgeWrapper
Defined in:
lib/pacer/core/graph/edges_route.rb

Overview

Basic methods for routes that contain only edges.

Instance Method Summary collapse

Instance Method Details

#both_v(*filters) {|VertexWrapper| ... } ⇒ VerticesRoute

Extends the route with both in and oud vertices from this route’s matching edges.

Parameters:

  • filter (Array<Hash, extension>, Hash, extension)

    see Route#property_filter

Yields:

  • (VertexWrapper)

    filter proc, see Route#property_filter

Returns:



38
39
40
41
42
43
# File 'lib/pacer/core/graph/edges_route.rb', line 38

def both_v(*filters, &block)
  Pacer::Route.property_filter(chain_route(:element_type => :vertex,
                                           :pipe_class => BothVerticesPipe,
                                           :route_name => 'bothV'),
                              filters, block)
end

#e(*filters) {|EdgeWrapper| ... } ⇒ EdgesRoute

Extend route with the additional edge label, property and block filters.

Parameters:

  • filter (Array<Hash, extension>, Hash, extension)

    see Route#property_filter

Yields:

  • (EdgeWrapper)

    filter proc, see Route#property_filter

Returns:



50
51
52
# File 'lib/pacer/core/graph/edges_route.rb', line 50

def e(*filters, &block)
  filter(*filters, &block)
end

#element_typeelement_type(:edge)

The element type of this route for this graph implementation.

which graph is in use.

Returns:



80
81
82
# File 'lib/pacer/core/graph/edges_route.rb', line 80

def element_type
  :edge
end

#in_v(*filters) {|VertexWrapper| ... } ⇒ VerticesRoute

Extends the route with in vertices from this route’s matching edges.

Parameters:

  • filter (Array<Hash, extension>, Hash, extension)

    see Route#property_filter

Yields:

  • (VertexWrapper)

    filter proc, see Route#property_filter

Returns:



26
27
28
29
30
31
# File 'lib/pacer/core/graph/edges_route.rb', line 26

def in_v(*filters, &block)
  Pacer::Route.property_filter(chain_route(:element_type => :vertex,
                                           :pipe_class => InVertexPipe,
                                           :route_name => 'inV'),
                              filters, block)
end

#labelsCore::Route

Return an route to all edge labels for edges emitted from this route.

Returns:



58
59
60
61
62
# File 'lib/pacer/core/graph/edges_route.rb', line 58

def labels
  chain_route(:pipe_class => com.tinkerpop.pipes.transform.LabelPipe,
              :route_name => 'labels',
              :element_type => :object)
end

#out_v(*filters) {|VertexWrapper| ... } ⇒ VerticesRoute

Extends the route with out vertices from this route’s matching edges.

Parameters:

  • filter (Array<Hash, extension>, Hash, extension)

    see Route#property_filter

Yields:

  • (VertexWrapper)

    filter proc, see Route#property_filter

Returns:



14
15
16
17
18
19
# File 'lib/pacer/core/graph/edges_route.rb', line 14

def out_v(*filters, &block)
  Pacer::Route.property_filter(chain_route(:element_type => :vertex,
                                           :pipe_class => OutVertexPipe,
                                           :route_name => 'outV'),
                              filters, block)
end

#to_hHash

Returns a hash of in vertices with an array of associated out vertices.

See #subgraph for a more useful method.

Returns:



69
70
71
72
73
74
# File 'lib/pacer/core/graph/edges_route.rb', line 69

def to_h
  inject(Hash.new { |h,k| h[k]=[] }) do |h, edge|
    h[edge.out_vertex] << edge.in_vertex
    h
  end
end