Skip to content

#725 added new query to notebook to add direct edge #726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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",
Expand Down Expand Up @@ -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: <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 +370,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.10.8"
}
},
"nbformat": 4,
Expand Down