agama 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/agama.gemspec +3 -2
  3. data/examples/wiki_example.rb +178 -0
  4. metadata +5 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.5.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{agama}
8
- s.version = "0.5.1"
8
+ s.version = "0.5.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aditya Rachakonda"]
12
- s.date = %q{2011-05-10}
12
+ s.date = %q{2011-05-16}
13
13
  s.description = %q{A simple Graph DB on a key-value store}
14
14
  s.email = %q{aditya.rachakonda@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
25
25
  "Rakefile",
26
26
  "VERSION",
27
27
  "agama.gemspec",
28
+ "examples/wiki_example.rb",
28
29
  "lib/agama.rb",
29
30
  "lib/agama/adapters/tokyocabinet.rb",
30
31
  "lib/agama/config.rb",
@@ -0,0 +1,178 @@
1
+ require 'rubygems'
2
+ require 'agama'
3
+ require 'agama/adapters/tokyocabinet'
4
+ require 'pp'
5
+
6
+ graph = Agama::Graph.new( :path => "/tmp",
7
+ :db => Agama::Adapters::TC.new)
8
+
9
+
10
+
11
+ graph.open
12
+
13
+
14
+ #Inserting Nodes
15
+
16
+ na = graph.set_node(:name => "a", :type => "triangle", :importance => 1)
17
+ nb = graph.set_node(:name => "b", :type => "square", :importance => 6)
18
+ nc = graph.set_node(:name => "c", :type => "circle", :importance => 3)
19
+ nd = graph.set_node(:name => "d", :type => "square", :importance => 2)
20
+ ne = graph.set_node(:name => "e", :type => "circle", :importance => 4)
21
+ nf = graph.set_node(:name => "f", :type => "square", :importance => 7)
22
+ ng = graph.set_node(:name => "g", :type => "circle", :importance => 2)
23
+ nh = graph.set_node(:name => "h", :type => "triangle", :importance => 6)
24
+ ni = graph.set_node(:name => "i", :type => "triangle", :importance => 8)
25
+ nj = graph.set_node(:name => "j", :type => "circle", :importance => 3)
26
+ nk = graph.set_node(:name => "k", :type => "circle", :importance => 5)
27
+
28
+ #Fetching Nodes
29
+ =begin
30
+ na = graph.get_node(:name => "a", :type => "rhombus")
31
+
32
+ nb = graph.get_node(:name => "b", :type => "circle")
33
+
34
+ nc = graph.get_node(:name => "c", :type => "circle")
35
+
36
+ nd = graph.get_node(:name => "d", :type => "rhombus")
37
+
38
+ ne = graph.get_node(:name => "e", :type => "square")
39
+
40
+ p na[:importance], nb[:importance], nc[:importance], nd[:importance], ne[:importance]
41
+ p na, nb, nc, nd, ne
42
+ p graph.node_count
43
+ #graph.close
44
+ =end
45
+
46
+ #Inserting Edges
47
+
48
+ graph.set_edge(:from => nb,
49
+ :to => na,
50
+ :type => "dotted",
51
+ :directed => true,
52
+ :weight => 1)
53
+ graph.set_edge(:from => nc,
54
+ :to => nb,
55
+ :type => "dotted",
56
+ :directed => true,
57
+ :weight => 5)
58
+ graph.set_edge(:from => nc,
59
+ :to => nd,
60
+ :type => "line",
61
+ :directed => false,
62
+ :weight => 3)
63
+ graph.set_edge(:from => na,
64
+ :to => nk,
65
+ :type => "line",
66
+ :weight => 4)
67
+ graph.set_edge(:from => nd,
68
+ :to => ne,
69
+ :type => "dotted",
70
+ :directed => true,
71
+ :weight => 9)
72
+ graph.set_edge(:from => nb,
73
+ :to => ne,
74
+ :type => "dotted",
75
+ :directed => true,
76
+ :weight => 7)
77
+ graph.set_edge(:from => nk,
78
+ :to => nb,
79
+ :type => "dotted",
80
+ :directed => true,
81
+ :weight => 6)
82
+ graph.set_edge(:from => nj,
83
+ :to => nk,
84
+ :type => "dotted",
85
+ :directed => true,
86
+ :weight => 1)
87
+ graph.set_edge(:from => nj,
88
+ :to => nb,
89
+ :type => "line",
90
+ :directed => false,
91
+ :weight => 3)
92
+ graph.set_edge(:from => ni,
93
+ :to => nj,
94
+ :type => "dotted",
95
+ :directed => true,
96
+ :weight => 2)
97
+ graph.set_edge(:from => ni,
98
+ :to => nh,
99
+ :type => "dotted",
100
+ :directed => true,
101
+ :weight => 2)
102
+ graph.set_edge(:from => ne,
103
+ :to => ni,
104
+ :type => "line",
105
+ :directed => false,
106
+ :weight => 6)
107
+ graph.set_edge(:from => nb,
108
+ :to => ni,
109
+ :type => "dotted",
110
+ :directed => true,
111
+ :weight => 11)
112
+ graph.set_edge(:from => nf,
113
+ :to => ne,
114
+ :type => "dotted",
115
+ :directed => true,
116
+ :weight => 8)
117
+ graph.set_edge(:from => ng,
118
+ :to => ne,
119
+ :type => "line",
120
+ :directed => false,
121
+ :weight => 8)
122
+ graph.set_edge(:from => ng,
123
+ :to => nf,
124
+ :type => "dotted",
125
+ :directed => true,
126
+ :weight => 6)
127
+ graph.set_edge(:from => nh,
128
+ :to => ng,
129
+ :type => "line",
130
+ :directed => false,
131
+ :weight => 5)
132
+ graph.close
133
+
134
+ =begin
135
+ #Fetching edges
136
+
137
+ eab = graph.get_edge(:from => na, :to => nb, :type => "dotted")
138
+
139
+ ecb = graph.get_edge(:from => nb, :to => nc, :type => "line") #Note: Direction reversed
140
+
141
+ ebd = graph.get_edge(:from => nb, :to => nd)
142
+
143
+ ede = graph.get_edge(:from => nd, :to => ne)
144
+
145
+ #p eab[:weight], ecb[:weight], ebd[:weight], ede[:weight]
146
+ p eab, ecb, ebd, ede
147
+ p graph.edge_count
148
+ =end
149
+
150
+ graph.neighbours(ni).each do |edge|
151
+ p edge
152
+ end
153
+
154
+ puts "\n---------------------------------------\n"
155
+
156
+ graph.neighbours(ni).along("dotted").each do |edge|
157
+ p edge
158
+ end
159
+
160
+ puts "\n---------------------------------------\n"
161
+
162
+ graph.neighbours(ni).along("dotted").outgoing.each do |edge|
163
+ p edge
164
+ end
165
+
166
+ puts "\n---------------------------------------\n"
167
+
168
+ graph.neighbours(ni).along("dotted").outgoing.of_type("circle").each do |edge|
169
+ p edge
170
+ end
171
+ puts "\n---------------------------------------\n"
172
+
173
+ p graph.node_count
174
+ p graph.node_count("square")
175
+ p graph.edge_count
176
+
177
+ graph.close
178
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agama
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 1
10
- version: 0.5.1
9
+ - 2
10
+ version: 0.5.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Aditya Rachakonda
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-10 00:00:00 +05:30
18
+ date: 2011-05-16 00:00:00 +05:30
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -96,6 +96,7 @@ files:
96
96
  - Rakefile
97
97
  - VERSION
98
98
  - agama.gemspec
99
+ - examples/wiki_example.rb
99
100
  - lib/agama.rb
100
101
  - lib/agama/adapters/tokyocabinet.rb
101
102
  - lib/agama/config.rb