Module: Pacer::Core::Graph::MixedRoute

Includes:
ElementRoute
Defined in:
lib/pacer/core/graph/mixed_route.rb

Overview

Basic methods for routes that may contain both vertices and edges. That can happen as the result of a branched route, for example.

Instance Method Summary (collapse)

Methods included from ElementRoute

#[], #build_index, #clone_into, #copy_into, #delete!, #element_ids, #properties, #property?, #subgraph

Instance Method Details

- (Object) both_e(*args, &block)

All edges from matching vertices.



46
47
48
# File 'lib/pacer/core/graph/mixed_route.rb', line 46

def both_e(*args, &block)
  v.both_e(*args, &block)
end

- (Object) both_v(*args, &block)

All vertices from matching edges.



61
62
63
# File 'lib/pacer/core/graph/mixed_route.rb', line 61

def both_v(*args, &block)
  e.both_v(*args, &block)
end

- (Object) e(*args, &block)

Pass through only edges.



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

def e(*args, &block)
  route = chain_route :element_type => :edge,
    :pipe_class => Pacer::Pipes::TypeFilterPipe,
    :pipe_args => Pacer::EdgeMixin,
    :extensions => extensions
  Pacer::Route.property_filter(route, args, block)
end

- (Object) element_type



70
71
72
# File 'lib/pacer/core/graph/mixed_route.rb', line 70

def element_type
  graph.element_type(:mixed)
end

- (Object) filter(*args, &block)



26
27
28
# File 'lib/pacer/core/graph/mixed_route.rb', line 26

def filter(*args, &block)
  mixed(*args, &block)
end

- (Object) in_e(*args, &block)

In edges from matching vertices.



41
42
43
# File 'lib/pacer/core/graph/mixed_route.rb', line 41

def in_e(*args, &block)
  v.in_e(*args, &block)
end

- (Object) in_v(*args, &block)

In vertices from matching edges.



56
57
58
# File 'lib/pacer/core/graph/mixed_route.rb', line 56

def in_v(*args, &block)
  e.in_v(*args, &block)
end

- (Object) labels(&block)

Return an iterator of or yield all labels on matching edges.



66
67
68
# File 'lib/pacer/core/graph/mixed_route.rb', line 66

def labels(&block)
  e.labels(&block)
end

- (Object) mixed(*args, &block)



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

def mixed(*args, &block)
  route = chain_route :pipe_class => Pacer::Pipes::IdentityPipe
  Pacer::Route.property_filter(route, args, block)
end

- (Object) out_e(*args, &block)

Out edges from matching vertices.



36
37
38
# File 'lib/pacer/core/graph/mixed_route.rb', line 36

def out_e(*args, &block)
  v.out_e(*args, &block)
end

- (Object) out_v(*args, &block)

Out vertices from matching edges.



51
52
53
# File 'lib/pacer/core/graph/mixed_route.rb', line 51

def out_v(*args, &block)
  e.out_v(*args, &block)
end

- (Object) result(name = nil)

Calculate and save result.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/pacer/core/graph/mixed_route.rb', line 75

def result(name = nil)
  ids = collect do |element|
    if element.is_a? Pacer::VertexMixin
      [:vertex, element.element_id]
    else
      [:edge, element.element_id]
    end
  end
  args = {
    :graph => graph,
    :element_type => :mixed,
    :extensions => extensions,
    :info => [name, info].compact.join(':')
  }
  ids.to_route(:info => "#{ ids.count } ids").map(args) do |method, id|
    graph.send(method, id)
  end
end

- (Object) v(*args, &block)

Pass through only vertices.



9
10
11
12
13
14
15
# File 'lib/pacer/core/graph/mixed_route.rb', line 9

def v(*args, &block)
  route = chain_route :element_type => :vertex,
    :pipe_class => Pacer::Pipes::TypeFilterPipe,
    :pipe_args => Pacer::VertexMixin,
    :extensions => extensions
  Pacer::Route.property_filter(route, args, block)
end