From f677ea5c7db62c6bf455b0c520155002c34349a5 Mon Sep 17 00:00:00 2001 From: Charles Ivie Date: Thu, 30 Jan 2025 16:35:34 +0000 Subject: [PATCH 1/4] #725 added new query to notebook to add direct edge --- .../02-Air-Routes-GeoNames.ipynb | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) 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..18957fbd 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 }, @@ -277,6 +276,39 @@ "RETURN gn_country, matches, ar_country" ] }, + { + "cell_type": "markdown", + "id": "31766ec9", + "metadata": {}, + "source": [ + "### Modifying the linked data graph\n", + "\n", + "We can use openCypher to insert new edges, creating alternative connections within the data to simplify querying and pathfinding.\n", + "\n", + "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", + "\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": "b8e296aa", + "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 +360,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.10.8" } }, "nbformat": 4, From 374dff8ca71e309b86713f703c5689c18c4cf125 Mon Sep 17 00:00:00 2001 From: Charles Ivie Date: Mon, 3 Feb 2025 15:03:04 +0000 Subject: [PATCH 2/4] OC-OVER-RDF 725 cleaned up a bit --- .../04-OpenCypher-Over-RDF/02-Air-Routes-GeoNames.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 18957fbd..f6ad3e80 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 @@ -278,7 +278,7 @@ }, { "cell_type": "markdown", - "id": "31766ec9", + "id": "45a59ae1", "metadata": {}, "source": [ "### Modifying the linked data graph\n", @@ -293,7 +293,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b8e296aa", + "id": "e5767b62", "metadata": {}, "outputs": [], "source": [ From d5d7d8657a0283f2382f90cc25ad97c041f29ebb Mon Sep 17 00:00:00 2001 From: charivie Date: Mon, 3 Feb 2025 16:17:09 +0000 Subject: [PATCH 3/4] OC-OVER-RDF 725 cleaned up a bit --- .../02-Air-Routes-GeoNames.ipynb | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) 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 f6ad3e80..7bf20233 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 @@ -35,6 +35,16 @@ "In this notebook, we work around a subset of the GeoNames and AirRoutes ontologies, linked by the country code, as shown here:" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "69284480", + "metadata": {}, + "outputs": [], + "source": [ + "%graph_notebook_host g-rvcp9jxb51.us-east-1.neptune-graph.amazonaws.com" + ] + }, { "attachments": { "Airroutes-GeoNames-111.png": { @@ -244,6 +254,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", @@ -281,11 +303,9 @@ "id": "45a59ae1", "metadata": {}, "source": [ - "### Modifying the linked data graph\n", - "\n", - "We can use openCypher to insert new edges, creating alternative connections within the data to simplify querying and pathfinding.\n", + "### Create a transitive edge (shortcut)\n", "\n", - "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", + "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." ] From ab749cce62b4aa4a2cff16cd358f5b97ced258b4 Mon Sep 17 00:00:00 2001 From: charivie Date: Mon, 3 Feb 2025 16:40:25 +0000 Subject: [PATCH 4/4] OC-OVER-RDF 725 added new paragraph --- .../02-Air-Routes-GeoNames.ipynb | 10 ---------- 1 file changed, 10 deletions(-) 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 7bf20233..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 @@ -35,16 +35,6 @@ "In this notebook, we work around a subset of the GeoNames and AirRoutes ontologies, linked by the country code, as shown here:" ] }, - { - "cell_type": "code", - "execution_count": null, - "id": "69284480", - "metadata": {}, - "outputs": [], - "source": [ - "%graph_notebook_host g-rvcp9jxb51.us-east-1.neptune-graph.amazonaws.com" - ] - }, { "attachments": { "Airroutes-GeoNames-111.png": {