0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 <!DOCTYPE html>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 <html>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 <head>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 <style type="text/css">
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 .center {
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 margin-left: auto;
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 margin-right: auto;
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 text-align: center;
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 }
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 </style>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 <title>Presentation</title>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 <meta charset='utf-8'>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14 <script src='./slides.js'></script>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 </head>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 <body style='display: none'>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17 <section class='slides layout-regular template-default'>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 <article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 <h1>GraphDB 入門<br>TinkerPop の使い方</h1>
|
5
|
20 <p>Shoshi Tamaki<br>Nobuyasu Oshiro<br>08 Sep 2012</p>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 </article>
|
5
|
22
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 <article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 <h3>もくじ</h3>
|
5
|
25 <br/>
|
|
26 <small>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 <ul>
|
5
|
28 <li>ストライクウィッチーズで,GraphDB/TinkerPop入門</li>
|
|
29 <ul>
|
|
30 <li>GraphDBとは</li>
|
|
31 <li>PropertyGraphについて</li>
|
|
32 <li>TinkerPopとは</li>
|
|
33 <li>TinkerPopを使ってストライクウィッチーズの相関図を解析</li>
|
|
34 </ul>
|
|
35 <li>TinkerPop による PageRank の実装</li>
|
|
36 <ul>
|
7
|
37 <li>PageRank アルゴリズム</li>
|
|
38 <li>Page と PageRank の GraphDB による表現</li>
|
|
39 <li>TinkerPop による PageRank の計算</li>
|
|
40 <li>Pipes による走査</li>
|
|
41 <li>PageRank の計算にかかる時間</li>
|
5
|
42 </ul>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
43 </ul>
|
5
|
44 </small>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
45 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
46
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
47 <article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
48 <h3>GraphDB とは?</h3>
|
5
|
49 <p>Graph構造を保存するためのデータベース.</p>
|
|
50 <p>Graph構造とは,たとえばこんなもの</p>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
51 <br/>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
52 <img src="./images/de2bf86e.jpeg" class="centered" height="470px"/>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
53 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
54
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
55 <article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
56 <h3>GraphDB とは?</h3>
|
5
|
57 <p>このような構造をしたGraphは<span style="color: red">PropertyGraph</span>と呼ばれる.</p>
|
|
58 <p>PropertyGraphとは,</p>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
59 <br/>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
60 <img src="./images/propertygraph_sw.png" height="470px" class="centered"/>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
61 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
62
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
63 <article>
|
5
|
64 <h3>PropertyGraph</h3>
|
|
65 <p><span color="red">関係・人物・名前・特徴</span>は<span color="red">Vertex・Edge・Label・Property</span>と呼ばれる.</p>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
66 <small>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
67 <ul>
|
5
|
68 <li>Edge(関係)が方向を持つ</li>
|
|
69 <li>Vertex(人物)とEdge(関係)はLabel(名前)を持つ</li>
|
|
70 <li><span style="color: red">VertexとEdgeはKey/Valueのマップ(Property)を持っている.</span></li>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
71 </ul>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
72 </small>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
73 <img src="./images/propertygraph_sw2.png" height="400px" class="centered"/>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
74 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
75
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
76 <article>
|
5
|
77 <h3>GraphDBとは?</h3>
|
|
78 <p>GraphDBは,保存されたGraphのVertex,Edgeを渡り歩き,目的のデータを取得するようなデータベースである.</p>
|
|
79 <p>渡り歩くことをTraverseという.</p>
|
|
80 <br/>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
81 <img src="./images/traverse_sw.png" class="centered"/>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
82 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
83
|
5
|
84 <!--
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
85 <article>
|
5
|
86 <h3>GraphDB入門</h3>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
87 <p>ここまでに,GraphDB とそのデータ構造である,Property Graph とは何か説明してきた.</p>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
88 <p>今日は,この<span style="color: red">ストライクウィッチーズの相関図</span>を GraphDB に叩きこみ <span style="color:red">TinkerPop</span> を使って解析する.</p>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
89 <br/>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
90 <img src="./images/today-demo.png" class="centered"/>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
91 </article>
|
5
|
92 -->
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
93
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
94 <article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
95 <h3>TinkerPop</h3>
|
5
|
96 <p>TinkerPopはGraphDBを利用するためのツール群である.</p>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
97 <br/>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
98 <br/>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
99 <img height="300px" src="./images/tinkerpop_with_name.png" class="centered"/>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
100 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
101
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
102 <article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
103 <h3>Blueprints</h3>
|
5
|
104 <p>Blueprintsは,PropertyGraphのJavaのinterfaceを提供する.</p>
|
|
105 <p>GraphDBの世界のJDBCの立場を目指している.</p><br/>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
106 <small>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
107 Blueprints を実装している GraphDB の一例
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
108 <ul>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
109 <li>Neo4j<li>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
110 <li>OrientDB</li>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
111 <li>MongoDB</li>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
112 <li>etc...</li>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
113 </ul>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
114 </small>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
115 <img src="./images/blueprints-logo.png" height="100px"/>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
116 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
117
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
118 <article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
119 <h3>Gremlin</h3>
|
5
|
120 <p>GraphをTraverseするための言語.Groovyがベースである.GraphDBに対してQueryを発行することが出来る.コンソールも利用できる.</p>
|
|
121 <pre>gremlin> graph.v(1).out.name
|
|
122 ==>vadas
|
|
123 ==>lop
|
|
124 ==>josh</pre>
|
|
125 <p>GremlinはPipesを利用して,GraphをTraverseする..out.nameがPipeである..</p>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
126 <img src="./images/gremlin-logo.png"/>
|
5
|
127 </article>
|
|
128
|
|
129 <article>
|
|
130 <h3>Pipes</h3>
|
|
131 <p>PipesはGraphを処理するためのフレームワークである.Pipeという処理の単位を複数連結し,複雑なTraverseを実現する.</p>
|
|
132 <img src="./images/pipes.png" height="150px" class="center"/>
|
|
133 <p>graph.v(1)はGraphからIDか1のVertexを取得する,.out .name がぞれぞれPipeに値する.</p>
|
|
134 <img src="./images/pipes-logo.png" height="200px"/>
|
|
135 </article>
|
|
136
|
|
137 <article>
|
|
138 <h3>Pipes</h3>
|
|
139 <p>この例題の動作は・・・</p>
|
|
140 <br/>
|
|
141 <br/>
|
|
142 <img style="float: left; margin-right:10px" src="./images/pipes-mario-2.png" height="300px"/>
|
|
143 <br/>
|
|
144 <img src="./images/pipes-mario-4.png" height="75px"/>
|
|
145 <pre>gremlin> g.v(1).out.name
|
|
146 ==>vadas
|
|
147 ==>lop
|
|
148 ==>josh</pre>
|
|
149 <br style="clear: both;"/>
|
|
150 <small>
|
|
151 <p>outはVertexから外向きのEdgeで繋がっているVertex一覧を取得する,nameはProperty名でPipeではVertexのnameを取得している.</p>
|
|
152 </small>
|
|
153 </article>
|
|
154
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
155 <article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
156 <h3>ストライクウィッチーズの相関図を解析するには?</h3>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
157 <br/>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
158 <ol>
|
5
|
159 <li>BlueprintsでTinkerGraphにストライクウィッチーズの相関図を入力する.</li>
|
|
160 <li>作成したTinkerGraphを,</li>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
161 <ul>
|
5
|
162 <li>Gremlinのコンソールから解析してみる.</li>
|
|
163 <li>JavaからGremlinを使って解析してみる.</li>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
164 </ul>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
165 </ol>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
166 <br/>
|
5
|
167 <p>まずは,TinkerGraphにストライクウィッチーズの相関図を入力する.</p>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
168 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
169
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
170 <article>
|
5
|
171 <h3>この発表のサンプルコードについて</h3>
|
|
172 <br/>
|
|
173 <p><span style="color:red">hg clone https://bitbucket.org/suikwasha/graphdb_javakuche</span></p>
|
|
174 <br/>
|
|
175 <small>
|
|
176 <p>Mavenというプロジェクト管理ツールを利用したプロジェクトになってます.</p>
|
|
177 </small>
|
|
178 <pre>ビルド方法・解凍したディレクトリに移動して
|
|
179 $ mvn compile</pre>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
180 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
181
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
182 <article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
183 <h3>ストライクウィッチーズの相関図を解析するには?</h3>
|
5
|
184 <p>Blueprintsは,GraphDBへのインターフェイスを提供する.TinkerGraphはBlueprintsを用いて利用できる.</p>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
185 <small>
|
5
|
186 <p>相関図のGraphを作るためには,<span style="color:red">Graph</span>を作成し<span style="color:red">人物(Vertex)</span>と<span style="color:red">関係(Edge)</span>,<span style="color:red">特徴(Property)</span>を作る必要がある.</p>
|
|
187 </small>
|
|
188 <small>
|
|
189 <pre>// 相関図(Graph)の作成,データを保存するディレクトリを引数に取る
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
190 Graph g = new TinkerGraph();</pre>
|
5
|
191 <pre>// 人物(Vertex)の作成,設定したいIDを引数に取る
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
192 Vertex character = g.addVertex(ID);</pre>
|
5
|
193 <pre>// 関係(Edge)の作成,設定したいIDを引数に取る
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
194 Edge relation = g.addEdge(ID,From,To,Label);</pre>
|
5
|
195 <pre>// 特徴(Property)の作成 , Vertex・Edgeともに同様のメソッド
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
196 character.setProperty(PropertyName,PropertyValue);</pre>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
197 </small>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
198 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
199
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
200 <article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
201 <h3>ストライクウィッチーズの相関図を解析するには?</h3>
|
5
|
202 <p>これを入力します.</p>
|
|
203 <img src="./images/de2bf86e.jpeg" height="550px" class="centered"/>
|
|
204 </article>
|
|
205
|
|
206 <article>
|
|
207 <h3>ストライクウィッチーズの相関図を解析するには?</h3>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
208 <p>画像を見ながらコードに書き起こすと・・・</p>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
209 <small>
|
5
|
210 <pre>Graph g = new TinkerGraph("./strikewitches"); // 保存ディレクトリ
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
211 Vertex strikeWitches = g.addVertex("StrikeWitches");
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
212 Vertex yoshika = g.addVertex("yoshika");
|
5
|
213 yoshika.setProperty(propName,"宮藤芳佳");
|
|
214 yoshika.setProperty(propRank,"軍曹");
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
215 yoshika.setProperty(propAge,14);
|
5
|
216 yoshika.setProperty(propCV,"福圓美里");
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
217 yoshika.setProperty(propUnit,"扶桑皇国海軍遣欧艦隊");
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
218 yoshika.setProperty(propPersonality,"明るく前向きで一生懸命");
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
219 Vertex lynett = g.addVertex("lynett");
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
220 lynett.setProperty(propName,"リネット・ビショップ");
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
221 lynett.setProperty(propRank,"軍曹");
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
222 lynett.setProperty(propAge, 15);
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
223 lynett.setProperty(propCV,"名塚佳織");
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
224 lynett.setProperty(propUnit,"ブリタニア空軍");
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
225 lynett.setProperty(propPersonality,"家庭的で戦闘は苦手");
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
226 g.addEdge(null,yoshika,lynett,"仲良し新人コンビ");
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
227 g.addEdge(null,lynett,yoshika,"仲良し新人コンビ");</pre>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
228 </small>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
229 </article>
|
5
|
230
|
|
231 <article>
|
|
232 <h3>CreateStrikeWitchesGraph</h3>
|
|
233 <p>実際にコードを動作させてTinkerGraphに入力する.</p>
|
|
234 <br/>
|
|
235 <small>
|
|
236 <p>mvn exec:java -Dexec.mainClass=suikwasha.javakuche.CreateStrikeWitchesGraph</p>
|
|
237 </small>
|
|
238 <br/>
|
|
239 <p>プロジェクトのディレクトリにstrikwitchesが作成される.</p>
|
|
240 </article>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
241
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
242 <article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
243 <h3>ストライクウィッチーズの相関図を解析するには?</h3>
|
5
|
244 <p>Blueprintsを用いてTinkerGraphに相関図を書き込むことが出来た.</p>
|
|
245 <p>今回は,Graph探索のサンプルのため"StrikeWitches"というキャラクター全員が所属する頂点を追加してある.</p>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
246 <br/>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
247 <ol>
|
5
|
248 <li>BlueprintsでTinkerGraphにストライクウィッチーズの相関図を入力する.</li>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
249 <span style="color:red">
|
5
|
250 <li>Gremlinを使って,TinkerGraphを読み込み,</li>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
251 <ul>
|
5
|
252 <li>Gremlinのコンソールから解析してみる.</li>
|
|
253 <li>JavaからGremlinを使って解析してみる.</li>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
254 </ul>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
255 </span>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
256 </ol>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
257 <br/>
|
5
|
258 <p>では,Gremlinを利用して相関図を解析してみる.</p>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
259 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
260
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
261 <article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
262 <h3>ストライクウィッチーズの相関図を解析するには?</h3>
|
5
|
263 <p>Gremlinのセットアップ</p>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
264 <ul>
|
5
|
265 <li>github tinkerpop/gremlin > Wiki のdownloadsから<span style="color:red">gremlin-groovy-2.1.0.zip</span>を利用する.</span></li>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
266 <li>解凍して展開する.</li>
|
5
|
267 <li>bin/gremlin.shを実行</li>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
268 </ul>
|
5
|
269 <pre>% ./gremlin.sh [~/Downloads/gremlin-groovy-2.1.0/bin]
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
270 \,,,/
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
271 (o o)
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
272 -----oOOo-(_)-oOOo-----
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
273 gremlin></pre>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
274 <p>こんなの表示される.</p>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
275 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
276
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
277 <article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
278 <h3>ストライクウィッチーズの相関図を解析するには?</h3>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
279 <p>Gremlin に相関図を食べさせて,解析開始.</p>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
280 <pre>gremlin> g = new TinkerGraph("path_to_graph");
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
281 ==>tinkergraph[vertices:12 edges:32 directory:path_to_graph]
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
282 gremlin> </pre>
|
5
|
283 <p>Vertexの一覧を取得してみる.</p>
|
|
284 <pre>gremlin> g.V // GraphのVertex一覧
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
285 ==>v[mio]
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
286 ...
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
287 ==>v[minna]
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
288 ==>v[lynett]
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
289 ...
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
290 ==>v[gertrud]
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
291 ==>v[francesca]</pre>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
292 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
293
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
294 <article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
295 <h3>ストライクウィッチーズの相関図を解析するには?</h3>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
296 <p><span style="color:red">宮藤芳佳</span>の<span style="color:red">年齢</span>を取得.</p>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
297 <pre>gremlin> g.v("yoshika").age
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
298 ==>14</pre>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
299 <p><span style="color:red">宮藤芳佳</span>を<span style="color:red">指導</span>しているのは誰?</p>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
300 <pre>gremlin> g.v("yoshika").in("指導").name
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
301 ==>坂本美緒</pre>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
302 <p><small><span style="color:red">宮藤芳佳</span>のことを<span style="color:red">きっー!なんなんですのアナタは!?</span>と思っている人が<span style="color:red">勤務態度に不満</span>を持っている人たち</small></p>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
303 <pre>gremlin> g.v("yoshika").in("きっー!なんなんですのアナタは!?")
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
304 .out("勤務態度に不満").name
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
305 ==>シャーロット・E・イエーガー
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
306 ==>フランチェスカ・ルッキーニ</pre>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
307 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
308
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
309 <article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
310 <h3>ストライクウィッチーズの相関図を解析するには?</h3>
|
5
|
311 <p><small><span style="color:red">宮藤芳佳</span>のことを<span style="color:red">きっー!なんなんですのアナタは!?</span>と思っている人が<span style="color:red">勤務態度に不満</span>を持っている人たち</small></p>
|
|
312 <pre>gremlin> g.v("yoshika").in("きっー!なんなんですのアナタは!?")
|
|
313 .out("勤務態度に不満").name
|
|
314 ==>シャーロット・E・イエーガー
|
|
315 ==>フランチェスカ・ルッキーニ</pre>
|
|
316 <img src="./images/traverse_demo.png" height="250px" class="centered"/>
|
|
317 </article>
|
|
318
|
|
319 <article>
|
|
320 <h3>ストライクウィッチーズの相関図を解析するには?</h3>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
321 <p><span style="color:red">16歳以下</span>の<span style="color:red">ウィッチ一覧</span></p>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
322 <pre>gremlin> g.v("StrikeWitches").out.filter{it.age < 16}.name
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
323 ==>宮藤芳佳
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
324 ==>エイラ・イルマタル・ユーティライネン
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
325 ==>サーニャ・V・リトヴャク
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
326 ==>リネット・ビショップ
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
327 ==>ペリーヌ・クロステルマン
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
328 ==>フランチェスカ・ルッキーニ</pre>
|
5
|
329 <small>
|
|
330 <p>{it.age < 16}はクロージャである.outで出力されたキャラクターのVertexが,それぞれitに格納される.Groovyでitは暗黙に定義されるクロージャの変数であり,第一引数が自動的に割り当てられる.</p>
|
|
331 </small>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
332 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
333
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
334 <article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
335 <h3>ストライクウィッチーズの相関図を解析するには?</h3>
|
5
|
336 <p>GremlinをJavaから使うためには,Mavenを利用するのが簡単である.</p>
|
|
337 <p>Mavenはプロジェクト管理ツールであり,他のプロジェクトのライブラリを簡単に取り込むことができる.</p>
|
|
338 <p>pom.xmlにGremlinを取り込むように記述する.</p>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
339 <pre><dependency>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
340 <groupId>com.tinkerpop.gremlin</groupId>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
341 <artifactId>gremlin-java</artifactId>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
342 <version>2.1.0</version>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
343 </dependency></pre>
|
5
|
344 <p>"Using Gremlin through Java" よりtinkerpop/gremlin wiki</p>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
345 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
346
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
347 <article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
348 <h3>ストライクウィッチーズの相関図を解析するには?</h3>
|
5
|
349 <p>TinkerGraphで作った,相関図を読み込む</p>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
350 <pre>Graph g = new TinkerGraph("path_to_graph");</pre>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
351 <p>GremlinPipeline の作成</p>
|
5
|
352 <pre>GremlinPipeline<Vertex,String> pipe
|
|
353 = new GremlinPipeline<Vertex,String>();
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
354 pipe.start(g.getVertex("yoshika"))....</pre>
|
5
|
355 <p>GremlinはGraphに対して処理をするPipeをつなげて,複雑な探索を可能にする.Gremlin コンソールでは見えないが,JavaではPipesを利用しているのが確認できる.</p>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
356 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
357
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
358 <article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
359 <h3>ストライクウィッチーズの相関図を解析するには?</h3>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
360 <p><span style="color:red">宮藤芳佳</span>を<span style="color:red">指導</span>しているのは誰?</p>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
361 <pre>pipe.start(g.getVertex("yoshika")).in("指導").property("name");
|
5
|
362 for(String name : pipe){
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
363 System.out.println("name")
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
364 }</pre>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
365 <p><small><span style="color:red">宮藤芳佳</span>のことを<span style="color:red">きっー!なんなんですのアナタは!?</span>と思っている人が<span style="color:red">勤務態度に不満</span>を持っている人たちの年齢</small></p>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
366 <pre>pipe.start(g.getVertex("yoshika")).in("きっー!なんなんですのアナタは!?")
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
367 .out("勤務態度に不満").property("age");
|
5
|
368 for(Integer age : pipe){
|
|
369 System.out.println(age);
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
370 }</pre>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
371 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
372
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
373 <article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
374 <h3>ストライクウィッチーズの相関図を解析するには?</h3>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
375 <p><span style="color:red">15歳以上</span>の<span style="color:red">ウィッチーズの名前</span></p>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
376 <pre>pipe.start(g.getVertex("StrikeWitches")).out("member")
|
5
|
377 .filter(new PipeFunction<Vertex,Boolean>(){
|
|
378 public Boolean compute(Vertex _argument){
|
|
379 return (Integer)_argument.getProperty("age") >= 15;
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
380 }
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
381 }).name;
|
5
|
382 for(String name : pipe){
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
383 System.out.println(name);
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
384 }</pre>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
385 <p>書き方としては,Gremlin コンソールでのほうが簡潔.</p>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
386 <pre>gremlin> g.v("StrikeWitches").out.filter{it.age > 15}.name</pre>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
387 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
388
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
389 <article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
390 <h3>ストライクウィッチーズの相関図を解析するには?</h3>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
391 <p>Gremlin コンソールでの書き方を Java で利用することができる.</p>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
392 <pre>Pipe pipe = Gremlin.compile("_().out.filter{it.age > 15}.name");
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
393 pipe.setStarts(
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
394 new SingleIterator<Vertex>(g.getVertex("StrikeWitches"));
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
395 for(Object name : pipe){
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
396 System.out.println(name);
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
397 }</pre>
|
5
|
398 <p>_()はGremlinePipelineに定義されている何もしないPipe</p>
|
|
399 <p>JavaでPipeを直接構築するより,こっちのほうが簡単である.</p>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
400 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
401
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
402 <article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
403 <h3>まとめ</h3>
|
5
|
404 <p>これまでに,ストライクウィッチーズの相関図を利用してGraphDBの概要とTinkerPopの簡単な使い方を見てきた.</p>
|
|
405 <p>この発表で大体のイメージが掴めてもらえれば幸いです.</p>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
406 <ul>
|
5
|
407 <li>GraphDBは,GraphのEdgeをTraverseして,目的のデータを取得するデータベース</li>
|
|
408 <li>GraphDBは,PropertyGraphを格納する.</p>
|
|
409 <li>TinkerPopは,GraphDBを利用するためのツールの集合</li>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
410 </ul>
|
5
|
411 <br/>
|
|
412 <p>次に,具体的な利用例としてPageRankのGraphDBでの表現について発表する.</p>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
413 </article>
|
5
|
414
|
9
|
415 <article>
|
10
|
416 <h3>TinkerPopによるPageRankの実装</h3>
|
9
|
417 <ul>
|
|
418 <li>PageRankアルゴリズム</li>
|
|
419 <li>PageとPageRankのGraphDBによる表現</li>
|
|
420 <li>TinkerPopによるPageRankの計算</li>
|
|
421 <li>Pipesによる走査</li>
|
|
422 <li>PageRankの計算にかかる時間</li>
|
|
423 </ul>
|
|
424 </article>
|
5
|
425
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
426 <article>
|
9
|
427 <h3>GoogleのPageRankアルゴリズム</h3>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
428 <ul>
|
9
|
429 <li>GoogleのWebページ検索エンジンに使われているアルゴリズム。</li>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
430 <li>あるページの『重要度』を示す値で、各ページ毎に持っている。 </li>
|
9
|
431 <li>PageRankが高いほど検索結果の上位に表示される。</li>
|
1
|
432 <li>『多くの良質なページからリンクされているページは、やはり良質なページである』という考えのアルゴリズム<br></li>
|
9
|
433 <li>GraphDBはPageRankの計算に向いている。</li>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
434 </ul>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
435 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
436
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
437
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
438 <article>
|
9
|
439 <h3>PageとPageRankのGraphDBによる表現</h3>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
440 <ul>
|
9
|
441 <li>アンサイクロペディアの各ページをGraphDBで表す。</li>
|
|
442 <li>1Vertexが1つのページを表す。</li>
|
|
443 <li>各VertexはPageTitleとPageRankをPropertyとして持つ。</li>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
444 <li>リンクは "HAS_LINK" という関係で表される。</li>
|
9
|
445 <li>PageRankはdoubleで初期値は 0.15 , 最大値はページ数*0.15</li>
|
|
446 <li>アンサイクロペディアではURIはページタイトルと同じ。</li>
|
|
447 <li>URIに対してユニークなVertexID を割り振る。</li>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
448 </ul>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
449 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
450
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
451 <article>
|
9
|
452 <h3>TinkerPopによるPageRankの計算</h3>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
453 <ul>
|
9
|
454 <li>○はVertexを、→ はEdgeを表す。</li>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
455 <p class="center">
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
456 <img src="./pic/graph.png" style="height:70%;">
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
457 </p>
|
2
|
458 <small><p>例:アンサイクロペディア内のページ『琉球大学』のリンクの関係 </p></small>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
459 </ul>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
460 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
461
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
462 <article>
|
9
|
463 <h3>PageRankアルゴリズム</h3>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
464 <ul>
|
9
|
465 <li>PageRankは次の計算式で求めることができる。</li>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
466 <pre>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
467 PR(A) = (1-d) + d (PR(T1)/C(T1) + ... + PR(Tn)/C(Tn))</pre>
|
9
|
468 <li>PR(A) は A というページのPageRankを表す。</li>
|
1
|
469 <li>d は定数で 0.85</li>
|
|
470 <li>C(T1) は T1 というページがリンクを張っている数を表す。 </li>
|
2
|
471 <li>T1...Tn は A をリンクしているページなので、C(T1)...C(Tn) は 0 にならない。</li>
|
9
|
472 <li>GoogleのPageRankはこれを改良したものである。</li>
|
11
|
473 <li>今回はこのアルゴリズムを使ってPageRankを求める。</li>
|
2
|
474 <!--
|
9
|
475 <li>PageRankはリンクを張ってくるページのPageRankが加算される。 </li>
|
|
476 <li>この時加算されるPageRankはリンクの数で割られた値となる。</li>
|
2
|
477 -->
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
478 </ul>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
479 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
480
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
481 <article>
|
9
|
482 <h3>PageRankの取得</h3>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
483 <ul>
|
12
|
484 <p class="center">
|
|
485 <img src="./pic/page_rank.png" style="height:40%;">
|
|
486 </p>
|
|
487 <li>TinkerGraph上でPageRankの値を出すために以下の2つの値が必要</li>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
488 <ul>
|
9
|
489 <li>リンク("HasLink")の関係を張ってくるVertexの取得</li>
|
|
490 <li>リンクしてくるVertexがどれだけリンクを張っているかを取得</li>
|
|
491 <small><p>*各ページの情報はXMLから取り出しBlueprintsを用いてTinkerGraphに書き込み済み。</p></small>
|
2
|
492
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
493 </ul>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
494 </ul>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
495 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
496
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
497 <article>
|
9
|
498 <h3>Pipesによる走査</h3>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
499 <ul>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
500 <li>あるページへとリンクを張るページ(Vertex)の取得</li>
|
12
|
501 <small><p>「id」はVertexのIDを表す。</p></small>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
502 <pre>
|
2
|
503 Graph graph = ...
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
504 GremlinPipeline pipe = new GremlinPipeline();
|
2
|
505 pipe.start(graph.getVertex(id));
|
|
506 pipe.in("HasLink");
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
507 for (Object inVerObj : pipe) {
|
9
|
508 VertexinVer = (Vertex)inVerObj;
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
509 :
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
510 } </pre>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
511 <p class="center">
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
512 <img src="./pic/inHasLink.png" style="height:30%;">
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
513 </p>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
514 </ul>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
515 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
516
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
517 <article>
|
9
|
518 <h3>Pipesによる走査</h3>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
519 <ul>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
520 <li>あるページが張っているリンクの数の取得</li>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
521 <pre>
|
2
|
522 Graph graph = ...
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
523 GremlinPipeline pipe = new GremlinPipeline();
|
2
|
524 pipe.start(graph.getVertex(id));
|
|
525 pipe.out("HasLink");
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
526 long linkNum = pipe.count();
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
527 </ul>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
528 <p class="center">
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
529 <img src="./pic/outHasLink.png" style="height:30%;">
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
530 </p>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
531
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
532 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
533
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
534 <article>
|
9
|
535 <h3>TinkerPopによるPageRankの計算</h3>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
536 <ul>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
537 <pre>
|
2
|
538 final double weight = 0.85;
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
539 double sum = 0.0;
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
540 double pageRank = 0.0;
|
9
|
541 Vertexv = graph.getVertex(id);
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
542 GremlinPipeline pipe = new GremlinPipeline();
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
543 pipe.start(graph.getVertex(id)).in("HasLink");
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
544 for (Object inVerObj : pipe) {
|
9
|
545 VertexinVer = (Vertex) inVerObj;
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
546 Object inVerId = inVer.getId();
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
547 GremlinPipeline inPipe = new GremlinPipeline();
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
548 inPipe.start(graph.getVertex(inVerId)).out("HasLink");
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
549 long linkNum = inPipe.count();
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
550 double pr = (Double) inVer.getProperty(PAGE_RANK);
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
551 sum += (double) pr / linkNum;
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
552 }
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
553 pageRank = (double) 1 - weight + (double) sum * weight;
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
554 v.setProperty(PAGE_RANK, pageRank);
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
555 </pre>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
556 </ul>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
557 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
558
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
559 <article>
|
7
|
560 <h3>計算結果</h3>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
561 <ul>
|
9
|
562 <li>アンサイクロペディア内でPageRankの高いページ</li>
|
2
|
563 <li>総ページ数: 242014 ページ</li>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
564 <table>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
565 <tr>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
566 <td>ページ名</td>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
567 <td>リンク数</td>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
568 <td>PageRank</td>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
569 </tr>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
570 <tr>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
571 <td>ユーモア枯渇症</td>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
572 <td>7162</td>
|
4
|
573 <td>71.120</td>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
574 <!-- <td>2.9387157726301383E-4</td> -->
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
575 </tr>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
576 <tr>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
577 <td>日本</td>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
578 <td>3537</td>
|
4
|
579 <td>54.584</td>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
580 <!-- <td>2.2555002445844352E-4</td> -->
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
581 </tr>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
582 <tr>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
583 <td>アンサイクロペディア</td>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
584 <td>3887</td>
|
4
|
585 <td>54.164</td>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
586 <!-- <td>2.2381320294806578E-4</td> -->
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
587 </tr>
|
4
|
588 <tr>
|
|
589 <td>ウィキペディア </td>
|
|
590 <td>2414</td>
|
|
591 <td>44.617</td>
|
|
592 </tr>
|
|
593 <tr>
|
|
594 <td>ニンジャスター</td>
|
|
595 <td>177</td>
|
|
596 <td>36.167</td>
|
|
597 </tr>
|
|
598
|
|
599 </table>
|
|
600 </ul>
|
|
601 </article>
|
|
602
|
|
603 <article>
|
9
|
604 <h3>PageRankの計算にかかる時間</h3>
|
4
|
605 <ul>
|
12
|
606 <li>PageRankは 10 回かからずの計算でほぼ収束した。</li>
|
4
|
607 <table>
|
|
608 <td>
|
|
609 <img src="./pic/pageRank.png" style="height:70%;">
|
|
610 </td>
|
|
611 <td>
|
|
612 <img src="./pic/computePageRank.png" style="height:70%;">
|
|
613 </td>
|
|
614 </table>
|
9
|
615 <li>PageRankの計算は10回行うとして、ページ数に対してかかる時間を測ってみた。</li>
|
4
|
616 </ul>
|
|
617 </article>
|
|
618
|
|
619 <article>
|
9
|
620 <h3>PageRankの計算にかかる時間</h3>
|
4
|
621 <ul>
|
|
622 <li>各ページ数で行う10回計算をそれぞれ10回ずつタイムを測り平均をとった。</li>
|
|
623 <table>
|
|
624 <tr>
|
|
625 <td>ページ数</td>
|
|
626 <td>10回の計算にかかった時間(単位:ms)</td>
|
|
627 </tr>
|
|
628 <tr>
|
|
629 <td>100</td>
|
|
630 <td>21</td>
|
|
631 </tr>
|
|
632 <tr>
|
|
633 <td>1000</td>
|
|
634 <td>67</td>
|
|
635 </tr>
|
|
636 <tr>
|
|
637 <td>10000</td>
|
|
638 <td>976</td>
|
|
639 </tr>
|
|
640 <tr>
|
|
641 <td>50000</td>
|
|
642 <td>7140</td>
|
|
643 </tr>
|
|
644 <tr>
|
|
645 <td>100000</td>
|
|
646 <td>26150</td>
|
|
647 </tr>
|
|
648 <tr>
|
|
649 <td>200000</td>
|
|
650 <td>74130</td>
|
|
651 </tr>
|
|
652 <tr>
|
|
653 <td>242014</td>
|
|
654 <td>93512</td>
|
|
655 </tr>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
656 </table>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
657 </ul>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
658 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
659
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
660
|
4
|
661 <article>
|
9
|
662 <h3>PageRankの計算にかかる時間</h3>
|
4
|
663 <ul>
|
|
664 <img src="./pic/pageRankCompare.png">
|
|
665 </ul>
|
|
666 </article>
|
|
667
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
668 <article>
|
7
|
669 <h3>まとめ</h3>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
670 <ul>
|
9
|
671 <li>今回、TinkerPopを用いてアンサイクロペディアの各ページのPageRankを求めた。</li>
|
|
672 <li>各ページとVertex, リンクの関係をEdgeで表すことで各ページ間の関係をTinkerPop上で表した。 </li>
|
|
673 <li>Gremlin を用いて各Vertexを渡り歩ことでPageRankの計算を行った。</li>
|
|
674 <li>全Vertexに対しての計算量はVertexの数に比例していることが確認できた。 </li>
|
7
|
675 </ul>
|
|
676 </article>
|
|
677
|
|
678 <article>
|
8
|
679 <h3>今日の勉強会で覚えておきたいこと</h3>
|
7
|
680 <ul>
|
9
|
681 <li>Graph の関係を表すようなデータはGraphDBで表現しやすい。</li>
|
|
682 <li>GraphDBではVertex間を渡り歩く(Traverse)ことでデータの取得を行う。 </li>
|
|
683 <li>GraphDBは局所性のあるデータを高速に計算することができる。</li>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
684 </ul>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
685 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
686
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
687 <article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
688 <h3>参考文献・サイト</h3>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
689 <ul>
|
9
|
690 <small><li>[1]Googleの秘密 -PageRank徹底解説<br>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
691 <a href="http://homepage2.nifty.com/baba_hajime/wais/pagerank.html">http://homepage2.nifty.com/baba_hajime/wais/pagerank.html</a></li></small>
|
9
|
692 <small><li>[2] LawrencePage, Sergey Brin, Rajeev Motwani, Terry Winograd, 'ThePageRankCitation Ranking: Bringing Order to the Web', 1998,<br>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
693 <a href="http://www-db.stanford.edu/~backrub/pageranksub.ps">http://www-db.stanford.edu/~backrub/pageranksub.ps</a></li></small>
|
9
|
694 <small><li>[3] ThePageRankAlgorithm<br>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
695 <a href="http://pr.efactory.de/e-pagerank-algorithm.shtml">http://pr.efactory.de/e-pagerank-algorithm.shtml</a></li></small>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
696
|
9
|
697 <small><li>[4] グラフデータベースを用いたPageRank実装の試み:スケーラブルなグラフ処理系に向けて<br>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
698 <a href="http://live-e.naist.jp/sensor_overlay/5/doc/hanai.pdf">http://live-e.naist.jp/sensor_overlay/5/doc/hanai.pdf</a></li></small>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
699 <!--
|
9
|
700 <small><li>Taher H. Haveliwala, 'Efficient Computation ofPageRank', Stanford Technical Report, 1999,<br>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
701 <a href="http://dbpubs.stanford.edu:8090/pub/1999-31">http://dbpubs.stanford.edu:8090/pub/1999-31</a></li>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
702 -->
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
703 </small>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
704 </ul>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
705 </article>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
706
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
707
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
708
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
709 <article>
|
9
|
710 <h3>なぜPageRankなのか</h3>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
711 <ul>
|
9
|
712 <li>PageRankはPageとPageのリンクの有無を利用して計算できる。</li>
|
|
713 <li>GraphDBはVertexとVertexを結ぶEdgeを走査(Traverse)することで、
|
5
|
714 目的のデータを得るようなデータベースである。</li>
|
9
|
715 <li>また、GraphDBは局所性のあるデータを高速に計算することができる。 </li>
|
|
716 <li>PageRankのPageの関係はGraphDBのVertexとEdgeで表すことができる<li>
|
|
717 <li>また、Pageの数が増えても局所的な計算ができるためGraphDBはPageRank
|
5
|
718 を求める DB に向いている。</li>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
719 </ul>
|
5
|
720 </article>
|
0
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
721
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
722
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
723 </section>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
724 </body>
|
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
725 </html>
|