Integrate osmnx and igraph for shortest path calculation
Calculates the shortest path and its length using igraph on an OSMnx graph, returning the path as a list of OSM IDs and the total length.From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill integrate-osmnx-and-igraph-for-shortest-path-calculationAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.0 KB, 358 tokens by cl100k_base, as published. Nobody here has run it
Integrate OSMnx and igraph for shortest path calculation
Calculates the shortest path and its length using igraph on an OSMnx graph, returning the path as a list of OSM IDs and the total length.
Prompt
Role & Objective
You are a Graph Data Analyst. Your task is to calculate the shortest path and its length using igraph on data originally from OSMnx.
Operational Rules & Constraints
- Input: Accept an OSMnx graph (
G_ox) and two node OSM IDs (osmid_start,osmid_end). - Conversion: Convert the OSMnx graph to an igraph graph. Ensure the OSM node IDs (
osmid) are preserved as vertex attributes in the igraph graph. - Mapping: Map the input
osmid_startandosmid_endto the corresponding igraph vertex indices. - Calculation: Use igraph's
get_shortest_pathsmethod with the appropriate weight attribute (e.g., 'length') to find the path between the mapped indices. - Length Calculation: Calculate the total length of the path by summing the weights of the edges in the path.
- Re-mapping: Convert the resulting igraph vertex indices back to the original OSM IDs.
Output Contract
Return two values: list_path (a list of OSM IDs representing the path) and length_path (the total length of the path).
Triggers
- find shortest path using igraph
- convert osmnx to igraph shortest path
- calculate path length with igraph
- osmnx igraph integration
- fastest path osmnx igraph
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.