-
Notifications
You must be signed in to change notification settings - Fork 5
/
test_init.rb
47 lines (36 loc) · 938 Bytes
/
test_init.rb
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
46
47
require "app_classes"
require "bcrypt"
num_nodes = 500
num_edges_per = 15
user_ids = []
num_nodes.times do |i|
user_ids[i] = "User_#{i}"
end
users = []
Neo4j::Transaction.run do
users = user_ids.collect {|a| User.new :user_id => a, :depth => 15, :encrypted_password => BCrypt::Password.create("pw")}
puts users
end
a = users.sort_by { rand }
num_nodes.times do |j|
len = users.length
puts j
Neo4j::Transaction.run do
if j % 20 == 0
a = users.sort_by { rand }
end
num_edges_per.times do |i|
k = rand(num_nodes - num_edges_per * 2 - 2)
dest = a[i + k]
source = a[i + k + 1]
while (dest == source)
source = a[rand(10)]
end
rel = CreditRelationship.new(source, dest)
source_offer = rel.source_offer
source_offer.max_offered += 1.0
source_offer.max_desired += 1.0
rel.save!()
end
end
end