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

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

Instance Method Details

#both_e(*args, &block) ⇒ Object

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

#both_v(*args, &block) ⇒ Object

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

#e(*args, &block) ⇒ Object

Pass through only edges.



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

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

#element_typeObject



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

def element_type
  :mixed
end

#filter(*args, &block) ⇒ Object



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

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

#in_e(*args, &block) ⇒ Object

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

#in_v(*args, &block) ⇒ Object

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

#labels(&block) ⇒ Object

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

#mixed(*args, &block) ⇒ Object



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, true)
end

#out_e(*args, &block) ⇒ Object

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

#out_v(*args, &block) ⇒ Object

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

#result(name = nil) ⇒ Object

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::Vertex
      [: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

#v(*args, &block) ⇒ Object

Pass through only vertices.



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

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