Skip to content

Commit f677ea5

Browse files
committed
#725 added new query to notebook to add direct edge
1 parent fb66141 commit f677ea5

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

src/graph_notebook/notebooks/02-Neptune-Analytics/04-OpenCypher-Over-RDF/02-Air-Routes-GeoNames.ipynb

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
"execution_count": null,
6464
"id": "98bf6d5e82a415f6",
6565
"metadata": {
66-
"collapsed": false,
6766
"jupyter": {
6867
"outputs_hidden": false
6968
},
@@ -277,6 +276,39 @@
277276
"RETURN gn_country, matches, ar_country"
278277
]
279278
},
279+
{
280+
"cell_type": "markdown",
281+
"id": "31766ec9",
282+
"metadata": {},
283+
"source": [
284+
"### Modifying the linked data graph\n",
285+
"\n",
286+
"We can use openCypher to insert new edges, creating alternative connections within the data to simplify querying and pathfinding.\n",
287+
"\n",
288+
"Execute the following query to extend the model. It adds a direct edge between airports whenever a direct route exists, allowing for more efficient traversal.\n",
289+
"\n",
290+
"This modification, known as \"edge shortcutting\" or \"transitive edge creation,\" is a common technique in graph data modeling to enhance pathfinding efficiency and speed up queries. It is particularly useful when integrating large graphs into a unified structure."
291+
]
292+
},
293+
{
294+
"cell_type": "code",
295+
"execution_count": null,
296+
"id": "b8e296aa",
297+
"metadata": {},
298+
"outputs": [],
299+
"source": [
300+
"%%oc\n",
301+
"\n",
302+
"PREFIX nepo: <http://neptune.aws.com/ontology/airroutes/>\n",
303+
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n",
304+
"\n",
305+
"MATCH (origin: nepo::Airport)\n",
306+
" <-[:nepo::source]-(r: nepo::Route)-[:nepo::destination]->\n",
307+
" (destination: nepo::Airport)\n",
308+
"\n",
309+
"CREATE (origin)-[:nepo::hasDirectRouteTo]->(destination)"
310+
]
311+
},
280312
{
281313
"cell_type": "markdown",
282314
"id": "e19cbac4",
@@ -328,7 +360,7 @@
328360
"name": "python",
329361
"nbconvert_exporter": "python",
330362
"pygments_lexer": "ipython3",
331-
"version": "3.10.13"
363+
"version": "3.10.8"
332364
}
333365
},
334366
"nbformat": 4,

0 commit comments

Comments
 (0)