diff --git a/src/graph_notebook/notebooks/02-Neptune-Analytics/04-OpenCypher-Over-RDF/02-Air-Routes-GeoNames.ipynb b/src/graph_notebook/notebooks/02-Neptune-Analytics/04-OpenCypher-Over-RDF/02-Air-Routes-GeoNames.ipynb index 3d08fe8a..5c51f2a8 100644 --- a/src/graph_notebook/notebooks/02-Neptune-Analytics/04-OpenCypher-Over-RDF/02-Air-Routes-GeoNames.ipynb +++ b/src/graph_notebook/notebooks/02-Neptune-Analytics/04-OpenCypher-Over-RDF/02-Air-Routes-GeoNames.ipynb @@ -63,7 +63,6 @@ "execution_count": null, "id": "98bf6d5e82a415f6", "metadata": { - "collapsed": false, "jupyter": { "outputs_hidden": false }, @@ -245,6 +244,18 @@ "RETURN gn_country.gn::name, ar_country.rdfs::label" ] }, + { + "cell_type": "markdown", + "id": "d38bce25", + "metadata": {}, + "source": [ + "## Modifying the RDF graph using openCypher\n", + "\n", + "We can use openCypher to modify the RDF graph, by performing CRUD (create, update and delete) operations.\n", + "\n", + "Here we insert new edges, creating alternative connections within the data to simplify querying and pathfinding:" + ] + }, { "cell_type": "markdown", "id": "843d2e72", @@ -277,6 +288,37 @@ "RETURN gn_country, matches, ar_country" ] }, + { + "cell_type": "markdown", + "id": "45a59ae1", + "metadata": {}, + "source": [ + "### Create a transitive edge (shortcut)\n", + "\n", + "Execute the following query to create a 'shortcut' in the model. It adds a direct edge between airports whenever a direct route exists, allowing for more efficient traversal.\n", + "\n", + "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." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e5767b62", + "metadata": {}, + "outputs": [], + "source": [ + "%%oc\n", + "\n", + "PREFIX nepo: \n", + "PREFIX rdfs: \n", + "\n", + "MATCH (origin: nepo::Airport)\n", + " <-[:nepo::source]-(r: nepo::Route)-[:nepo::destination]->\n", + " (destination: nepo::Airport)\n", + "\n", + "CREATE (origin)-[:nepo::hasDirectRouteTo]->(destination)" + ] + }, { "cell_type": "markdown", "id": "e19cbac4", @@ -328,7 +370,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.10.8" } }, "nbformat": 4,