Skip to content

Commit

Permalink
#725 added new query to notebook to add direct edge
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesivie committed Jan 30, 2025
1 parent fb66141 commit f677ea5
Showing 1 changed file with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
"execution_count": null,
"id": "98bf6d5e82a415f6",
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
Expand Down Expand Up @@ -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: <http://neptune.aws.com/ontology/airroutes/>\n",
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\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",
Expand Down Expand Up @@ -328,7 +360,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.10.8"
}
},
"nbformat": 4,
Expand Down

0 comments on commit f677ea5

Please sign in to comment.