Class: Pacer::Neo4j2::Algo::PathWrapper

Inherits:
Object
  • Object
show all
Includes:
Wrapping
Defined in:
lib/pacer-neo4j2/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.



13
14
15
16
17
18
# File 'lib/pacer-neo4j2/algo/path_wrapper.rb', line 13

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.



11
12
13
# File 'lib/pacer-neo4j2/algo/path_wrapper.rb', line 11

def graph
  @graph
end

#raw_pathObject (readonly)

Returns the value of attribute raw_path.



11
12
13
# File 'lib/pacer-neo4j2/algo/path_wrapper.rb', line 11

def raw_path
  @raw_path
end

Instance Method Details

#both(*args) ⇒ Object



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

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

#both_e(*args) ⇒ Object



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

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

#both_edges(*args) ⇒ Object

skips route creation = faster but less features



88
89
90
# File 'lib/pacer-neo4j2/algo/path_wrapper.rb', line 88

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

#both_vertices(*args) ⇒ Object

skips route creation = faster but less features



103
104
105
# File 'lib/pacer-neo4j2/algo/path_wrapper.rb', line 103

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

#eObject

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



50
51
52
# File 'lib/pacer-neo4j2/algo/path_wrapper.rb', line 50

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.



35
36
37
# File 'lib/pacer-neo4j2/algo/path_wrapper.rb', line 35

def end_e
  wrap_edge raw_path.lastRelationship
end

#end_vObject

Returns the end vertex of this path.



21
22
23
# File 'lib/pacer-neo4j2/algo/path_wrapper.rb', line 21

def end_v
  wrap_vertex raw_path.endNode
end

#in(*args) ⇒ Object



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

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

#in_e(*args) ⇒ Object



112
113
114
# File 'lib/pacer-neo4j2/algo/path_wrapper.rb', line 112

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

#in_edges(*args) ⇒ Object

skips route creation = faster but less features



83
84
85
# File 'lib/pacer-neo4j2/algo/path_wrapper.rb', line 83

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

#in_vertices(*args) ⇒ Object

skips route creation = faster but less features



98
99
100
# File 'lib/pacer-neo4j2/algo/path_wrapper.rb', line 98

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

#inspectObject



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

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

#lengthObject

Returns the length of this path.



40
41
42
# File 'lib/pacer-neo4j2/algo/path_wrapper.rb', line 40

def length
  raw_path.length
end

#out(*args) ⇒ Object



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

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

#out_e(*args) ⇒ Object



108
109
110
# File 'lib/pacer-neo4j2/algo/path_wrapper.rb', line 108

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

#out_edges(*args) ⇒ Object

skips route creation = faster but less features



78
79
80
# File 'lib/pacer-neo4j2/algo/path_wrapper.rb', line 78

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

#out_vertices(*args) ⇒ Object

skips route creation = faster but less features



93
94
95
# File 'lib/pacer-neo4j2/algo/path_wrapper.rb', line 93

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

#pathObject

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



26
27
28
# File 'lib/pacer-neo4j2/algo/path_wrapper.rb', line 26

def path
  wrap_path raw_path.iterator
end

#reverse_eObject

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



60
61
62
# File 'lib/pacer-neo4j2/algo/path_wrapper.rb', line 60

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.



55
56
57
# File 'lib/pacer-neo4j2/algo/path_wrapper.rb', line 55

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.



65
66
67
# File 'lib/pacer-neo4j2/algo/path_wrapper.rb', line 65

def start_v
  wrap_vertex raw_path.startNode
end

#to_aObject



30
31
32
# File 'lib/pacer-neo4j2/algo/path_wrapper.rb', line 30

def to_a
  path.to_a
end

#to_sObject



69
70
71
# File 'lib/pacer-neo4j2/algo/path_wrapper.rb', line 69

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.



45
46
47
# File 'lib/pacer-neo4j2/algo/path_wrapper.rb', line 45

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