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.

Yields:

  • (VertexWrapper)

    filter proc, see Route#property_filter



46
47
48
49
50
51
# File 'lib/pacer/core/graph/edges_route.rb', line 46

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.

Yields:

  • (EdgeWrapper)

    filter proc, see Route#property_filter



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

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.



88
89
90
# File 'lib/pacer/core/graph/edges_route.rb', line 88

def element_type
  :edge
end

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

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

Yields:

  • (VertexWrapper)

    filter proc, see Route#property_filter



30
31
32
33
# File 'lib/pacer/core/graph/edges_route.rb', line 30

def in_v(*filters, &block)
  Pacer::Route.property_filter(inV,
                              filters, block)
end

#inVObject



35
36
37
38
39
# File 'lib/pacer/core/graph/edges_route.rb', line 35

def inV
  chain_route(:element_type => :vertex,
              :pipe_class => InVertexPipe,
              :route_name => 'inV')
end

#labelsCore::Route

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



66
67
68
69
70
# File 'lib/pacer/core/graph/edges_route.rb', line 66

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.

Yields:

  • (VertexWrapper)

    filter proc, see Route#property_filter



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

def out_v(*filters, &block)
  Pacer::Route.property_filter(outV,
                              filters, block)
end

#outVObject



19
20
21
22
23
# File 'lib/pacer/core/graph/edges_route.rb', line 19

def outV
  chain_route(:element_type => :vertex,
              :pipe_class => OutVertexPipe,
              :route_name => 'outV')
end

#to_hHash

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

See #subgraph for a more useful method.



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

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