diff --git a/dors-cluc-workshop/game-of-graphs.ipynb b/dors-cluc-workshop/game-of-graphs.ipynb index 39ac36e..ec49f53 100644 --- a/dors-cluc-workshop/game-of-graphs.ipynb +++ b/dors-cluc-workshop/game-of-graphs.ipynb @@ -87,7 +87,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 1, "id": "7b913342", "metadata": {}, "outputs": [], @@ -111,7 +111,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 2, "id": "dc3b280d", "metadata": {}, "outputs": [ @@ -134,7 +134,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 3, "id": "e8aefd2d", "metadata": { "scrolled": true @@ -164,7 +164,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 4, "id": "7b521170", "metadata": {}, "outputs": [ @@ -195,7 +195,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 5, "id": "8198f12b", "metadata": {}, "outputs": [ @@ -225,7 +225,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 6, "id": "d387293e", "metadata": {}, "outputs": [], @@ -305,7 +305,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 7, "id": "06ba29c8", "metadata": {}, "outputs": [ @@ -330,7 +330,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 8, "id": "38b466c9", "metadata": { "scrolled": true @@ -374,7 +374,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 9, "id": "951b2985", "metadata": {}, "outputs": [ @@ -399,7 +399,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 10, "id": "5d9a2d43", "metadata": {}, "outputs": [ @@ -452,7 +452,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 11, "id": "206dc6a8", "metadata": {}, "outputs": [], @@ -484,7 +484,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 12, "id": "48497779", "metadata": { "scrolled": false @@ -524,7 +524,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 13, "id": "3e14f31e", "metadata": {}, "outputs": [ @@ -561,7 +561,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 14, "id": "d4668039", "metadata": {}, "outputs": [ @@ -598,7 +598,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 15, "id": "df5c41d9", "metadata": {}, "outputs": [ @@ -644,7 +644,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 16, "id": "3b2365ff", "metadata": {}, "outputs": [ @@ -695,7 +695,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 17, "id": "02fdba60", "metadata": {}, "outputs": [ @@ -738,7 +738,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 18, "id": "9fe6edc3", "metadata": {}, "outputs": [ @@ -797,7 +797,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 19, "id": "431c4119", "metadata": { "scrolled": true @@ -808,21 +808,21 @@ "output_type": "stream", "text": [ "Character: Melisandre the Red Woman of Asshai | Method: Old Age\n", - "Character: Peasant | Method: Poison\n", - "Character: Gladiator | Method: Sword\n", - "Character: Gladiator | Method: Spear\n", - "Character: Tommen Baratheon | Method: Falling\n", - "Character: Jaqen Hghar | Method: Poison\n", - "Character: Dothraki man | Method: Arakh\n", - "Character: Sandor the Hound Clegane | Method: Dragonfire (Dragon)\n", - "Character: Aemon Targaryen | Method: Old Age\n", "Character: Bolton soldier | Method: Arrow\n", - "Character: Selyse Florent | Method: Rope\n", "Character: Sons of the Harpy agent | Method: Sword\n", + "Character: Selyse Florent | Method: Rope\n", + "Character: Tommen Baratheon | Method: Falling\n", "Character: Greyjoy Soldier | Method: Sword\n", "Character: Greyjoy Soldier | Method: Axe\n", "Character: Greyjoy Soldier | Method: Mace\n", - "Character: Greyjoy Soldier | Method: Knife\n" + "Character: Greyjoy Soldier | Method: Knife\n", + "Character: Aemon Targaryen | Method: Old Age\n", + "Character: Jaqen Hghar | Method: Poison\n", + "Character: Sandor the Hound Clegane | Method: Dragonfire (Dragon)\n", + "Character: Dothraki man | Method: Arakh\n", + "Character: Peasant | Method: Poison\n", + "Character: Gladiator | Method: Sword\n", + "Character: Gladiator | Method: Spear\n" ] } ], @@ -867,7 +867,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 20, "id": "36b563bf", "metadata": {}, "outputs": [ @@ -875,26 +875,26 @@ "name": "stdout", "output_type": "stream", "text": [ - "Episode: Kings Landing | Rank: 0.06106011381918923\n", - "Episode: Roseroad | Rank: 0.010786290904476399\n", - "Episode: Winterfell | Rank: 0.00965060421661062\n", - "Episode: Meereen | Rank: 0.007653449136907163\n", - "Episode: The Twins | Rank: 0.005029859049634092\n", - "Episode: Beyond the Wall | Rank: 0.0048574484597048535\n", - "Episode: Castle Black | Rank: 0.003955983097311169\n", - "Episode: The Narrow Sea | Rank: 0.0021040262793516795\n", - "Episode: Riverlands | Rank: 0.0019043870463720022\n", - "Episode: The Wall | Rank: 0.001583596860766157\n" + "Episode: Kings Landing | Rank: 0.23956779130768424\n", + "Episode: Roseroad | Rank: 0.04258314482360096\n", + "Episode: Winterfell | Rank: 0.034810126582276814\n", + "Episode: Meereen | Rank: 0.02805987389902162\n", + "Episode: The Twins | Rank: 0.018445877653173345\n", + "Episode: Beyond the Wall | Rank: 0.016195793425421594\n", + "Episode: Castle Black | Rank: 0.013741156086056073\n", + "Episode: The Narrow Sea | Rank: 0.007400009626028442\n", + "Episode: Riverlands | Rank: 0.005968137844731878\n", + "Episode: The Wall | Rank: 0.005559031621504291\n" ] } ], "source": [ "results = memgraph.execute_and_fetch(\n", " \"\"\"\n", - " CALL pagerank.get()\n", + " MATCH p=(:Death)-[:HAPPENED_IN]->(:Location)\n", + " WITH project(p) AS subgraph\n", + " CALL pagerank.get(subgraph)\n", " YIELD *\n", - " WITH node, rank\n", - " WHERE node:Location\n", " RETURN node, rank\n", " ORDER BY rank DESC\n", " LIMIT 10;\n", @@ -915,7 +915,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 21, "id": "118403fc", "metadata": { "scrolled": true @@ -962,7 +962,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 22, "id": "f2713c8a", "metadata": {}, "outputs": [ @@ -970,26 +970,26 @@ "name": "stdout", "output_type": "stream", "text": [ - "Episode: The Bells | Rank: 0.043164724601018695\n", - "Episode: The Winds of Winter | Rank: 0.010801371244279762\n", - "Episode: The Spoils of War | Rank: 0.010652824071617745\n", - "Episode: Battle of the Bastards | Rank: 0.007326424536668109\n", - "Episode: The Watchers on the Wall | Rank: 0.004888653411156206\n", - "Episode: Blackwater | Rank: 0.0040451560244256475\n", - "Episode: The Dance of Dragons | Rank: 0.003304325314698726\n", - "Episode: Dragonstone | Rank: 0.002979021268992005\n", - "Episode: Sons of the Harpy | Rank: 0.002835536547706026\n", - "Episode: The Rains of Castamere | Rank: 0.002811794141977363\n" + "Episode: The Bells | Rank: 0.1717263469904861\n", + "Episode: The Spoils of War | Rank: 0.0418917626810729\n", + "Episode: The Winds of Winter | Rank: 0.0414853946550654\n", + "Episode: Battle of the Bastards | Rank: 0.027262513744800945\n", + "Episode: The Watchers on the Wall | Rank: 0.017712865133623402\n", + "Episode: Blackwater | Rank: 0.01486828895157052\n", + "Episode: The Dance of Dragons | Rank: 0.012023712769517645\n", + "Episode: Dragonstone | Rank: 0.011210976717502538\n", + "Episode: Sons of the Harpy | Rank: 0.009991872639479874\n", + "Episode: The Rains of Castamere | Rank: 0.009382320600468544\n" ] } ], "source": [ "results = memgraph.execute_and_fetch(\n", " \"\"\"\n", - " CALL pagerank.get()\n", + " MATCH p=(:Death)-[:HAPPENED_IN]->(:Episode)\n", + " WITH project(p) AS subgraph\n", + " CALL pagerank.get(subgraph)\n", " YIELD *\n", - " WITH node, rank\n", - " WHERE node:Episode\n", " RETURN node, rank\n", " ORDER BY rank DESC\n", " LIMIT 10;\n", @@ -1010,7 +1010,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 23, "id": "d1834484", "metadata": { "scrolled": true @@ -1065,7 +1065,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 24, "id": "32535947", "metadata": { "scrolled": true @@ -1117,7 +1117,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 25, "id": "55679941", "metadata": {}, "outputs": [ @@ -1167,7 +1167,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 26, "id": "329bd44a", "metadata": { "scrolled": true @@ -1228,7 +1228,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 27, "id": "52cef37b", "metadata": {}, "outputs": [ @@ -1274,7 +1274,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 28, "id": "c82986be", "metadata": {}, "outputs": [ @@ -1291,20 +1291,20 @@ "Victim: The Masters Soldier | Kill Count: 12 | Episode name: Battle of the Bastards\n", "Victim: Greyjoy Soldier | Kill Count: 2 | Episode name: The Bells\n", "Victim: Horse | Kill Count: 2 | Episode name: The Spoils of War\n", - "Victim: Kraznys mo Nakloz | Kill Count: 1 | Episode name: And Now His Watch Is Ended\n", - "Victim: Golden Company horse | Kill Count: 1 | Episode name: The Bells\n", - "Victim: Cersei Lannister | Kill Count: 1 | Episode name: The Bells\n", - "Victim: Khal Moro | Kill Count: 1 | Episode name: Book of the Stranger\n", - "Victim: Goat | Kill Count: 1 | Episode name: The Laws of Gods and Men\n", - "Victim: Randyll Tarly | Kill Count: 1 | Episode name: Eastwatch\n", - "Victim: Mirri Maz Duur | Kill Count: 1 | Episode name: Fire and Blood\n", - "Victim: Varys | Kill Count: 1 | Episode name: The Bells\n", "Victim: Xaro Xhoan Daxos | Kill Count: 1 | Episode name: Valar Morghulis\n", + "Victim: Khal Moro | Kill Count: 1 | Episode name: Book of the Stranger\n", + "Victim: Golden Company horse | Kill Count: 1 | Episode name: The Bells\n", "Victim: Pyat Pree | Kill Count: 1 | Episode name: Valar Morghulis\n", "Victim: Zalla | Kill Count: 1 | Episode name: The Children\n", + "Victim: Kraznys mo Nakloz | Kill Count: 1 | Episode name: And Now His Watch Is Ended\n", + "Victim: Varys | Kill Count: 1 | Episode name: The Bells\n", "Victim: Doreah | Kill Count: 1 | Episode name: Valar Morghulis\n", + "Victim: Cersei Lannister | Kill Count: 1 | Episode name: The Bells\n", + "Victim: Goat | Kill Count: 1 | Episode name: The Laws of Gods and Men\n", + "Victim: Mirri Maz Duur | Kill Count: 1 | Episode name: Fire and Blood\n", "Victim: Khal Drogo | Kill Count: 1 | Episode name: Fire and Blood\n", "Victim: Dickon Tarly | Kill Count: 1 | Episode name: Eastwatch\n", + "Victim: Randyll Tarly | Kill Count: 1 | Episode name: Eastwatch\n", "Victim: Jaime Lannister | Kill Count: 1 | Episode name: The Bells\n" ] } @@ -1343,7 +1343,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 29, "id": "94c66c50", "metadata": {}, "outputs": [ @@ -1351,16 +1351,16 @@ "name": "stdout", "output_type": "stream", "text": [ - "Daenerys Targaryen | BC: 0.26416716859707745\n", + "Daenerys Targaryen | BC: 0.2641671685970775\n", "Lannister soldier | BC: 0.11163138590238263\n", "Sons of the Harpy agent | BC: 0.043261207465688026\n", - "Jon Snow | BC: 0.041527339730212665\n", - "Wildling | BC: 0.03782396045716544\n", - "Stark Soldier | BC: 0.028609456095599343\n", - "Baratheon of Dragonstone soldier | BC: 0.02753381662259538\n", + "Jon Snow | BC: 0.04152733973021263\n", + "Wildling | BC: 0.03782396045716539\n", + "Stark Soldier | BC: 0.02860945609559934\n", + "Baratheon of Dragonstone soldier | BC: 0.027533816622595374\n", "Cersei Lannister | BC: 0.026445092829209964\n", - "Stark soldier | BC: 0.024328184592014485\n", - "Nights Watch brother | BC: 0.022719177729567448\n" + "Stark soldier | BC: 0.02432818459201448\n", + "Nights Watch brother | BC: 0.02271917772956744\n" ] } ], @@ -1399,7 +1399,7 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 30, "id": "51741a10", "metadata": {}, "outputs": [ @@ -1409,11 +1409,11 @@ "text": [ "Victim: Bolton soldier | Kill count: 20\n", "Victim: Lannister soldier | Kill count: 7\n", - "Victim: Stark Soldier | Kill count: 1\n", + "Victim: Daenerys Targaryen | Kill count: 1\n", "Victim: Olly | Kill count: 1\n", + "Victim: Stark Soldier | Kill count: 1\n", "Victim: Alliser Thorne | Kill count: 1\n", "Victim: Othell Yarwyck | Kill count: 1\n", - "Victim: Daenerys Targaryen | Kill count: 1\n", "Victim: Bowen Marsh | Kill count: 1\n" ] } @@ -1444,7 +1444,7 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 31, "id": "65e19f9e", "metadata": {}, "outputs": [ @@ -1490,7 +1490,7 @@ }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 32, "id": "b99e8f42", "metadata": {}, "outputs": [ @@ -1499,15 +1499,15 @@ "output_type": "stream", "text": [ "Traitor: Jon Snow | Kill count: 8 | Allegiance: Nights Watch\n", - "Traitor: Ramsay Bolton | Kill count: 4 | Allegiance: House Bolton\n", "Traitor: Theon Greyjoy | Kill count: 4 | Allegiance: House Greyjoy\n", - "Traitor: Daario Naharis | Kill count: 2 | Allegiance: House Targaryen\n", - "Traitor: Tyrion Lannister | Kill count: 2 | Allegiance: House Lannister\n", - "Traitor: Nights Watch mutineer | Kill count: 2 | Allegiance: Nights Watch\n", + "Traitor: Ramsay Bolton | Kill count: 4 | Allegiance: House Bolton\n", "Traitor: Euron Greyjoy | Kill count: 2 | Allegiance: House Greyjoy\n", - "Traitor: Reek | Kill count: 2 | Allegiance: House Bolton\n", + "Traitor: Nights Watch mutineer | Kill count: 2 | Allegiance: Nights Watch\n", + "Traitor: Daenerys Targaryen | Kill count: 2 | Allegiance: House Targaryen\n", + "Traitor: Sandor the Hound Clegane | Kill count: 2 | Allegiance: House Lannister\n", + "Traitor: Tyrion Lannister | Kill count: 2 | Allegiance: House Lannister\n", "Traitor: Karl Tanner | Kill count: 2 | Allegiance: Nights Watch\n", - "Traitor: Daenerys Targaryen | Kill count: 2 | Allegiance: House Targaryen\n" + "Traitor: Daario Naharis | Kill count: 2 | Allegiance: House Targaryen\n" ] } ], @@ -1544,7 +1544,7 @@ }, { "cell_type": "code", - "execution_count": 56, + "execution_count": 33, "id": "cef0423c", "metadata": { "scrolled": true