Skip to content

Commit 769bc39

Browse files
committed
update
1 parent 28ab020 commit 769bc39

File tree

3 files changed

+53
-22
lines changed

3 files changed

+53
-22
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
.ipynb_checkpoints/
2-
log/
2+
log/
3+
metastore_db/
4+
derby.log

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
Tutorial que utiliza as bibliotecas Spark GraphX (https://spark.apache.org/graphx/
66
), GraphFrames (https://graphframes.github.io/) e D3 (https://d3js.org/) para criação, análise e visualização de Grafos no Spark.
77

8-
Ver **tutorial.ipynb**
8+
* **tutorial.ipynb**: Jupyter Notebook de Tutorial
9+
* **d3.html**: Visualização do Gráfo gerada pelo D3
10+
11+
### Medium
12+
13+
https://medium.com/@marlessonsantana/introdução-ao-spark-graphx-e-graphframes-9b10089f2e7f
914

1015
![Alt Text](./img/graph.png)
1116

tutorial.ipynb

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197
},
198198
{
199199
"cell_type": "code",
200-
"execution_count": 8,
200+
"execution_count": 52,
201201
"metadata": {},
202202
"outputs": [],
203203
"source": [
@@ -206,12 +206,13 @@
206206
" Return a list containing the most friends\n",
207207
" '''\n",
208208
" g_indegrees = g.inDegrees\n",
209-
" return g.vertices.join(g_indegrees, \"id\").orderBy(\"inDegree\", ascending=False).limit(topN)"
209+
" return g.vertices.join(g_indegrees, \"id\")\\\n",
210+
" .orderBy(\"inDegree\", ascending=False).limit(topN)"
210211
]
211212
},
212213
{
213214
"cell_type": "code",
214-
"execution_count": 9,
215+
"execution_count": 67,
215216
"metadata": {},
216217
"outputs": [
217218
{
@@ -232,13 +233,12 @@
232233
"|5736| Lemon| 1289|\n",
233234
"| 403| Alvah| 1280|\n",
234235
"+----+---------+--------+\n",
235-
"only showing top 10 rows\n",
236236
"\n"
237237
]
238238
}
239239
],
240240
"source": [
241-
"most_connected = get_most_connected(g, 1000)\n",
241+
"most_connected = get_most_connected(g, 10)\n",
242242
"most_connected.show(10)"
243243
]
244244
},
@@ -255,7 +255,7 @@
255255
},
256256
{
257257
"cell_type": "code",
258-
"execution_count": 10,
258+
"execution_count": 68,
259259
"metadata": {},
260260
"outputs": [
261261
{
@@ -282,7 +282,9 @@
282282
" '''\n",
283283
" Return a list of connected users\n",
284284
" '''\n",
285-
" return g.find(\"(a)-[e]->(b)\").filter(\"b.id = %d\" % user_id).select(\"a.id\", \"a.NAME\")\n",
285+
" return g.find(\"(a)-[e]->(b)\")\\\n",
286+
" .filter(\"b.id = %d\" % user_id)\\\n",
287+
" .select(\"a.id\", \"a.NAME\")\n",
286288
"\n",
287289
"users = get_users_connected(g, 859)\n",
288290
"print(\"Total de usuários conectados a 'Hallie': \", users.count())\n",
@@ -302,23 +304,23 @@
302304
},
303305
{
304306
"cell_type": "code",
305-
"execution_count": 11,
307+
"execution_count": 69,
306308
"metadata": {},
307309
"outputs": [
308310
{
309311
"name": "stdout",
310312
"output_type": "stream",
311313
"text": [
312-
"Total de possíveis amigos: 56331\n",
313-
"+----+--------+\n",
314-
"| id| name|\n",
315-
"+----+--------+\n",
316-
"|4845| Winnie|\n",
317-
"|3219| Juan|\n",
318-
"|1310|Laurence|\n",
319-
"| 177|Nicholas|\n",
320-
"|1003| George|\n",
321-
"+----+--------+\n",
314+
"Total de possíveis amigos: 15181\n",
315+
"+----+-------+\n",
316+
"| id| name|\n",
317+
"+----+-------+\n",
318+
"|1289| Abram|\n",
319+
"|1484|Wilburn|\n",
320+
"|4040| Ralph|\n",
321+
"| 208| Andy|\n",
322+
"|3750| Emmitt|\n",
323+
"+----+-------+\n",
322324
"only showing top 5 rows\n",
323325
"\n"
324326
]
@@ -329,10 +331,11 @@
329331
" '''\n",
330332
" Returns a list of suggested friendships \"people you may know\"\n",
331333
" '''\n",
332-
" users = g.find(\"(a)-[e]->(b); (b)-[e2]->(c); !(a)-[]->(c)\").filter(\"a.id = %d\" % user_id)\n",
334+
" users = g.find(\"(a)-[e]->(b); (b)-[e2]->(c); !(a)-[]->(c)\")\\\n",
335+
" .filter(\"a.id = %d\" % user_id)\n",
333336
" return users.select(\"c.id\", \"c.name\")\n",
334337
"\n",
335-
"users = get_friends_suggestion(g, 859).cache()\n",
338+
"users = get_friends_suggestion(g, 1572).cache()\n",
336339
"print(\"Total de possíveis amigos: \", users.count())\n",
337340
"users.show(5)"
338341
]
@@ -490,6 +493,27 @@
490493
"source": [
491494
"graph_to_file(g_users, \"graph.json\")"
492495
]
496+
},
497+
{
498+
"cell_type": "code",
499+
"execution_count": null,
500+
"metadata": {},
501+
"outputs": [],
502+
"source": []
503+
},
504+
{
505+
"cell_type": "code",
506+
"execution_count": null,
507+
"metadata": {},
508+
"outputs": [],
509+
"source": []
510+
},
511+
{
512+
"cell_type": "code",
513+
"execution_count": null,
514+
"metadata": {},
515+
"outputs": [],
516+
"source": []
493517
}
494518
],
495519
"metadata": {

0 commit comments

Comments
 (0)