Class: Pacer::Neo4j::Algo::PathWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/pacer-neo4j/algo/path_wrapper.rb

Overview

Uses the interface defined here: api.neo4j.org/1.8/org/neo4j/graphdb/Path.html

Note that I have removed methods that I didn’t understand, assuming they are internal.

Direct Known Subclasses

TraversalBranchWrapper

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, graph) ⇒ PathWrapper

Returns a new instance of PathWrapper.



15
16
17
18
19
20
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 15

def initialize(path, graph)
  @raw_path = path
  @graph = graph
  @gv = graph.v
  @ge = graph.e
end

Instance Attribute Details

#graphObject (readonly)

Returns the value of attribute graph.



13
14
15
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 13

def graph
  @graph
end

#raw_pathObject (readonly)

Returns the value of attribute raw_path.



13
14
15
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 13

def raw_path
  @raw_path
end

Instance Method Details

#both(*args) ⇒ Object



136
137
138
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 136

def both(*args)
  end_v.both(*args)
end

#both_e(*args) ⇒ Object



124
125
126
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 124

def both_e(*args)
  end_v.both_e(*args)
end

#both_edges(*args) ⇒ Object

skips route creation = faster but less features



96
97
98
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 96

def both_edges(*args)
  end_v.both_edges(*args)
end

#both_vertices(*args) ⇒ Object

skips route creation = faster but less features



111
112
113
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 111

def both_vertices(*args)
  end_v.both_vertices(*args)
end

#eObject

Returns all the edges in between the vertices which this path consists of.



58
59
60
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 58

def e
  raw_path.relationships.map { |r| wrap_edge r }.to_route based_on @ge
end

#end_eObject

Returns the last edge in this path.



43
44
45
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 43

def end_e
  wrap_edge raw_path.lastRelationship
end

#end_vObject

Returns the end vertex of this path.



23
24
25
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 23

def end_v
  wrap_vertex raw_path.endNode
end

#in(*args) ⇒ Object



132
133
134
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 132

def in(*args)
  end_v.in(*args)
end

#in_e(*args) ⇒ Object



120
121
122
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 120

def in_e(*args)
  end_v.in_e(*args)
end

#in_edges(*args) ⇒ Object

skips route creation = faster but less features



91
92
93
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 91

def in_edges(*args)
  end_v.in_edges(*args)
end

#in_vertices(*args) ⇒ Object

skips route creation = faster but less features



106
107
108
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 106

def in_vertices(*args)
  end_v.in_vertices(*args)
end

#inspectObject



81
82
83
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 81

def inspect
  "#<Path #{ to_s }>"
end

#lengthObject

Returns the length of this path.



48
49
50
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 48

def length
  raw_path.length
end

#out(*args) ⇒ Object



128
129
130
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 128

def out(*args)
  end_v.out(*args)
end

#out_e(*args) ⇒ Object



116
117
118
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 116

def out_e(*args)
  end_v.out_e(*args)
end

#out_edges(*args) ⇒ Object

skips route creation = faster but less features



86
87
88
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 86

def out_edges(*args)
  end_v.out_edges(*args)
end

#out_vertices(*args) ⇒ Object

skips route creation = faster but less features



101
102
103
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 101

def out_vertices(*args)
  end_v.out_vertices(*args)
end

#pathObject

Iterates through both the vertices and edges of this path in order.



28
29
30
31
32
33
34
35
36
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 28

def path
  raw_path.iterator.to_route.map(graph: graph, element_type: :mixed) do |e|
    if e.is_a? Node
      wrap_vertex e
    else
      wrap_edge e
    end
  end
end

#reverse_eObject

Returns all the edges in between the vertices which this path consists of in reverse order, i.e.



68
69
70
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 68

def reverse_e
  raw_path.reverseRelationships.map { |r| wrap_edge r }.to_route based_on @ge
end

#reverse_vObject

Returns all the vertices in this path in reversed order, i.e.



63
64
65
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 63

def reverse_v
  raw_path.reverseNodes.map { |n| wrap_vertex n }.to_route based_on @gv
end

#start_vObject

Returns the start vertex of this path.



73
74
75
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 73

def start_v
  wrap_vertex raw_path.startNode
end

#to_aObject



38
39
40
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 38

def to_a
  path.to_a
end

#to_sObject



77
78
79
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 77

def to_s
  "#{ start_v.inspect }-(#{length})->#{end_v.inspect}"
end

#vObject

Returns all the vertices in this path starting from the start vertex going forward towards the end vertex.



53
54
55
# File 'lib/pacer-neo4j/algo/path_wrapper.rb', line 53

def v
  raw_path.nodes.map { |n| wrap_vertex n }.to_route based_on: @gv
end