-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtwitter.neo4j-browser-guide
264 lines (264 loc) · 8.83 KB
/
twitter.neo4j-browser-guide
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
<article class="guide">
<carousel class="deck container-fluid">
<slide class="row-fluid">
<div class="col-sm-3">
<h3>Twitter Graph</h3>
<p class="lead">Show data from your personal Twitter account</p>
</div>
<div class="col-sm-6">
<p><em>The Graph Your Network</em> application inserts your Twitter activity into Neo4j.</p>
<p>Here is a data model of the graph:<img src="//neo4jsandbox.com/guides/twitter/img/twitter-data-model.svg" class="img-responsive"></p>
</div>
<div class="col-sm-3"><img src="https://guides.neo4j.com/sandbox/twitter/images/click-next.png" style="position:relative;right:-23px" class="pull-right"></div>
</slide>
<slide class="row-fluid">
<div class="col-sm-3">
<h3>Twitter Graph</h3>
<p class="lead">Show data from your personal Twitter account</p>
</div>
<div class="col-sm-9">
<p><em>The Graph Your Network</em> application inserts your Twitter activity into Neo4j.</p>
<p>This application allows you to query things like:</p>
<ol class="big">
<li>Who's mentioning you on Twitter</li>
<li>Who are your most influential followers?</li>
<li>What tags you use frequently</li>
<li>How many people you follow also follow you back</li>
<li>People tweeting about you, but you don't follow</li>
<li>Links from intresting retweets</li>
<li>Other people tweeting with some of your top hashtags</li>
</ol>
</div>
</slide>
<slide class="row-fluid">
<div class="col-sm-3">
<h5>Twitter Graph</h5><br>
<h3>Your mentions</h3>
<p>
To the right is a giant code block containing a single Cypher query statement
to determine who's mentioning you on Twitter.
</p>
<ol>
<li>Click on the code blocks</li>
<li>Notice they get copied to the editor above ↑</li>
<li>Click the editor's play button to execute</li>
<li>Wait for the query to finish</li>
</ol>
</div>
<div class="col-sm-9">
<h5>Graph of some of your mentions</h5>
<figure>
<pre class="pre-scrollable code runnable">// Graph of some of your mentions
MATCH
(u:Me:User)-[p:POSTS]->(t:Tweet)-[:MENTIONS]->(m:User)
WITH
u,p,t,m, COUNT(m.screen_name) AS count
ORDER BY
count DESC
RETURN
u,p,t,m
LIMIT 10</pre>
</figure>
<h5>Details as a table</h5>
<figure>
<pre class="pre-scrollable code runnable">// Detailed table of some of your mentions
MATCH
(u:User:Me)-[:POSTS]->(t:Tweet)-[:MENTIONS]->(m:User)
RETURN
m.screen_name AS screen_name, COUNT(m.screen_name) AS count
ORDER BY
count DESC
LIMIT 10</pre>
</figure>
</div>
</slide>
<slide class="row-fluid">
<div class="col-sm-3">
<h5>Twitter Graph</h5><br>
<h3>Most Influential Followers</h3>
<p>Who are your most influential followers?</p>
<ol>
<li>Click on the code block</li>
<li>Notice it gets copied to the editor above ↑</li>
<li>Click the editor's play button to execute</li>
<li>Wait for the query to finish</li>
</ol>
</div>
<div class="col-sm-9">
<figure>
<pre class="pre-scrollable code runnable">// Most influential followers
MATCH
(follower:User)-[:FOLLOWS]->(u:User:Me)
RETURN
follower.screen_name AS user, follower.followers AS followers
ORDER BY
followers DESC
LIMIT 10</pre>
</figure>
</div>
</slide>
<slide class="row-fluid">
<div class="col-sm-3">
<h5>Twitter Graph</h5><br>
<h3>Most Tagged</h3>
<p>What hashtags have you used most often?</p>
<ol>
<li>Click on the code block</li>
<li>Notice it gets copied to the editor above ↑</li>
<li>Click the editor's play button to execute</li>
<li>Wait for the query to finish</li>
</ol>
</div>
<div class="col-sm-9">
<figure>
<pre class="pre-scrollable code runnable">// The hashtags you have used most often
MATCH
(h:Hashtag)<-[:TAGS]-(t:Tweet)<-[:POSTS]-(u:User:Me)
WITH
h, COUNT(h) AS Hashtags
ORDER BY
Hashtags DESC
LIMIT 10
RETURN
h.name, Hashtags</pre>
</figure>
</div>
</slide>
<slide class="row-fluid">
<div class="col-sm-3">
<h5>Twitter Graph</h5><br>
<h3>Followback Rate</h3>
<p>At what rate do people you follow also follow you back?</p>
<ol>
<li>Click on the code block</li>
<li>Notice it gets copied to the editor above ↑</li>
<li>Click the editor's play button to execute</li>
<li>Wait for the query to finish</li>
</ol>
</div>
<div class="col-sm-9">
<figure>
<pre class="pre-scrollable code runnable">// Followback rate
MATCH
(me:User:Me)-[:FOLLOWS]->(f)
WITH
me, f, size((f)-[:FOLLOWS]->(me)) as doesFollowBack
RETURN
SUM(doesFollowBack) / toFloat(COUNT(f)) AS followBackRate</pre>
</figure>
</div>
</slide>
<slide class="row-fluid">
<div class="col-sm-3">
<h5>Twitter Graph</h5><br>
<h3>Follower Recommendations</h3>
<p>Who tweets about you, but you do not follow?</p>
<ol>
<li>Click on the code block</li>
<li>Notice it gets copied to the editor above ↑</li>
<li>Click the editor's play button to execute</li>
<li>Wait for the query to finish</li>
</ol>
</div>
<div class="col-sm-9">
<figure>
<pre class="pre-scrollable code runnable">// Follower Recommendations - tweeting about you, but you don't follow
MATCH
(ou:User)-[:POSTS]->(t:Tweet)-[mt:MENTIONS]->(me:User:Me)
WITH
DISTINCT ou, me
WHERE
(ou)-[:FOLLOWS]->(me)
AND NOT
(me)-[:FOLLOWS]->(ou)
RETURN
ou.screen_name</pre>
</figure>
</div>
</slide>
<slide class="row-fluid">
<div class="col-sm-3">
<h5>Twitter Graph</h5><br>
<h3>Links from interesting retweets</h3>
<p>What links do you retweet, and how often are they favorited?</p>
<ol>
<li>Click on the code block</li>
<li>Notice it gets copied to the editor above ↑</li>
<li>Click the editor's play button to execute</li>
<li>Wait for the query to finish</li>
</ol>
</div>
<div class="col-sm-9">
<figure>
<pre class="pre-scrollable code runnable">// Links from interesting retweets
MATCH
(:User:Me)-[:POSTS]->
(t:Tweet)-[:RETWEETS]->(rt)-[:CONTAINS]->(link:Link)
RETURN
t.id_str AS tweet, link.url AS url, rt.favorites AS favorites
ORDER BY
favorites DESC
LIMIT 10</pre>
</figure>
</div>
</slide>
<slide class="row-fluid">
<div class="col-sm-3">
<h5>Twitter Graph</h5><br>
<h3>Common Hashtags</h3>
<p>What users tweet with some of your top hashtags?</p>
<ol>
<li>Click on the code block</li>
<li>Notice it gets copied to the editor above ↑</li>
<li>Click the editor's play button to execute</li>
<li>Wait for the query to finish</li>
</ol>
</div>
<div class="col-sm-9">
<figure>
<pre class="pre-scrollable code runnable">// Users tweeting with your top hashtags
MATCH
(me:User:Me)-[:POSTS]->(tweet:Tweet)-[:TAGS]->(ht)
MATCH
(ht)<-[:TAGS]-(tweet2:Tweet)<-[:POSTS]-(sugg:User)
WHERE
sugg <> me
AND NOT
(tweet2)-[:RETWEETS]->(tweet)
WITH
sugg, collect(distinct(ht)) as tags
RETURN
sugg.screen_name as friend, size(tags) as common
ORDER BY
common DESC
LIMIT 20</pre>
</figure>
</div>
</slide>
<slide class="row-fluid header">
<div class="col-sm-4">
<h3>Next steps</h3>
<ul class="undecorated">
<li><a play-topic="start">Getting Started with Neo4j</a></li>
<li><a href="http://neo4j.com/download">Download Neo4j</a></li>
</ul>
</div>
<div class="col-sm-4">
<h3>More code</h3>
<ul class="undecorated">
<li><a play-topic="movie-graph">Movie Graph</a> - Movies and actors</li>
<li><a play-topic="northwind-graph">Northwind Graph</a> - from RDBMS to graph</li>
<li><a play-topic="query-template">Query Templates</a> - common ad-hoc queries</li>
<li><a play-topic="cypher">Cypher</a> - query language fundamentals</li>
</ul>
</div>
<div class="col-sm-4">
<h3>Reference</h3>
<ul class="undecorated">
<li><a href="http://neo4j.com/developer">Developer resources</a></li>
<li><a href="http://neo4j.com/docs/{{neo4j.version | neo4jdoc }}/">Neo4j Manual</a></li>
</ul>
</div>
</slide>
</carousel>
</article>