-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.rb
More file actions
45 lines (32 loc) · 936 Bytes
/
Copy pathapp.rb
File metadata and controls
45 lines (32 loc) · 936 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# entry point of application
require './node.rb'
class App
def self.launch
# Loads data from file to objects
IO.foreach('data.txt') do |line|
if Node.count == 0
n = Node.new(line[0].upcase)
n.add_edges(line[1].upcase , line[2])
p n
else
n = Node.new(line[0].upcase)
n.add_edges(line[1].upcase , line[2])
# check if node with name is already exists or not
# if exists , add adjacent node to previously
# initialize object array
if Node.exists(n) != false
m = Node.exists(n)
m.add_edges(line[1] , line[2])
end
#Node.delete(n)
#p n
end
end
Node.all
#result = Node.distance('A','D','C')
#puts "distance of route => #{result}"
# finding possible paths b/w source and terminal
puts Node.find_paths('A','C')
end
end
App.launch