Skip to content

Conversation

@cvvergara
Copy link
Member

@cvvergara cvvergara commented Oct 1, 2025

Changes proposed in this pull request:

  • Reorganize the chapters
    • Talk about graphs first
  • Rewrite the graphs chapter
    • Adjust the scripts for the rewrite
    • Adjust the images for Auckland

@pgRouting/admins

Summary by CodeRabbit

  • New Features

    • Added copy-to-clipboard for code blocks and a new cost‑matrix visualization with expanded vehicle/taxi/pedestrian examples and multi-source routing support.
  • Documentation

    • Major rewrite of the "Graphs" chapter: clearer terminology (source/target), vertex-centric workflow, connected-component and cost-matrix guidance, expanded pedestrian-only guidance, updated images, translations, many wording and formatting fixes.
  • Chores

    • Added documentation dependency for copy buttons and streamlined doc build and image handling.

@cvvergara cvvergara added this to the FOSS4G 2025 milestone Oct 1, 2025
@cvvergara cvvergara requested a review from iosefa October 1, 2025 20:51
@coderabbitai
Copy link

coderabbitai bot commented Oct 1, 2025

Walkthrough

Reworks the Graphs workshop: adds sphinx-copybutton, reorganizes docs/CMake and image/script build targets, expands and renames graph documentation to a vertices-centric schema (adds tag_id propagation), introduces pgr_dijkstraCostMatrix and images.sql for cost-matrix generation, and updates localization files.

Changes

Cohort / File(s) Summary
Dependencies & Sphinx config
REQUIREMENTS.txt, docs/conf.py
Add sphinx-copybutton to requirements and sphinx_copybutton to Sphinx extensions.
Docs structure (toctree/order)
docs/basic/CMakeLists.txt, docs/index.rst
Reorder/include basic/graphs.rst and remove duplicated entry; adjust CMake ordering for basic docs.
Graphs documentation
docs/basic/graphs.rst
Rename "Graph views" → "Graphs"; add "Configuration from osm2pgrouting"; switch source_osm/target_osmsource/target; expand vehicle/pedestrian/taxi narratives; add verification rubrics and pgr_dijkstraCostMatrix docs; many formatting and example updates.
Images build rules
docs/basic/images/CMakeLists.txt, docs/basic/images/graphs/CMakeLists.txt
Replace per-file copy loop with add_subdirectory and configure_file(... COPYONLY); update image lists (add costMatrix.png, pedestrian_only_roads.png, roads_tag_ids.png, taxi_net.png) and adjust debug messages; remove duplicates.
Scripts: basic data
docs/scripts/basic/data/CMakeLists.txt
Simplify file handling to direct configure_file(data.sh ...); preserve basic_data_scripts target producing data.txt.
Scripts: graphs orchestration
docs/scripts/basic/CMakeLists.txt, docs/scripts/basic/graphs/CMakeLists.txt
Add graphs directory to workflow; create basic_graphs_scripts target; rewire dependencies so pedestrian/vehicle/sql targets depend on graphs; expand generated artifacts and include images.sql.
SQL: graphs & images
docs/scripts/basic/graphs/graphs.sql, docs/scripts/basic/graphs/images.sql
Move to vertices-centric extraction (rename ways_verticesvertices); replace source_osm/target_osm with source/target; add tag_id propagation; add configuration inspection outputs; switch uses to pgr_dijkstraCostMatrix; add images.sql producing costMatrix_png; add per-net vertex extraction views.
Localization / translations
locale/en/LC_MESSAGES/basic/graphs.po, locale/pot/basic/graphs.pot
Update timestamps, rename sections, add references for pgr_extractVertices, pgr_connectedComponents, pgr_dijkstraCostMatrix, and rewrite many strings to match updated docs and identifiers.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant CMake as CMake
  participant Data as basic_data_scripts
  participant Graphs as basic_graphs_scripts
  participant Ped as basic_pedestrian_scripts
  participant Veh as basic_vehicles_scripts
  participant SQL as basic_sql_function_scripts

  Note over CMake: Revised build orchestration for graphs/images/scripts
  CMake->>Data: build data.txt
  CMake->>Graphs: generate graphs artifacts (graphs.sql, images.sql → generated .txt)
  Graphs-->>Ped: satisfy dependency
  Graphs-->>Veh: satisfy dependency
  Graphs-->>SQL: satisfy dependency (alongside Veh)
Loading
sequenceDiagram
  autonumber
  participant U as User
  participant DB as Postgres
  participant PGR as pgr_dijkstraCostMatrix
  participant VNet as vehicle_net
  participant Vtx as vertices
  participant Out as costMatrix_png

  rect rgba(230,245,255,0.6)
    Note over U,DB: images.sql flow (cost matrix generation)
    U->>DB: RUN images.sql
    DB->>PGR: CALL pgr_dijkstraCostMatrix(SELECT * FROM vehicle_net, [ID array])
    PGR-->>DB: returns rows (start_vid, end_vid, agg_cost)
  end
  DB->>Vtx: JOIN start_vid/end_vid → coordinates
  DB->>Out: INSERT gid, ST_MakeLine(start_geom,end_geom), name
  Note over Out: Visualization rows produced
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

administrative

Suggested reviewers

  • iosefa
  • sanak

Poem

Hop hop, I tidy docs with cheerful vim,
New graphs and vertices now brim to the brim.
A copy-button click, a matrix that gleams,
Tags hop through rows and networks in streams.
I bound through builds and nibble bright dreams. 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “Graphs chapter rewrite” clearly and concisely describes the primary change in this pull request, which focuses on reorganizing and rewriting the graphs chapter documentation and related scripts.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/basic/graphs.rst (1)

128-142: Incorrect function description.

Lines 128-130 state that pgr_extractVertices computes connected components using Depth First Search, but this description actually belongs to pgr_connectedComponents. The function pgr_extractVertices extracts vertices from an edge table.

Additionally, Line 142 links to pgr_connectedComponents documentation when it should link to pgr_extractVertices documentation.

Apply this diff to fix the description and link:

-``pgr_extractVertices`` compute the connected components of an undirected
-graph using a Depth First Search approach. A connected component of an
-undirected graph is a set of vertices that are all reachable from each other.
+``pgr_extractVertices`` extracts all vertices from an edge table, creating a 
+vertices table with unique vertex identifiers and their associated properties.
 Description of the function can be found in `pgr_extractVertices
-<https://docs.pgrouting.org/latest/en/pgr_connectedComponents.html>`__
+<https://docs.pgrouting.org/latest/en/pgr_extractVertices.html>`__
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 37663d6 and a0f21a4.

⛔ Files ignored due to path filters (7)
  • docs/basic/images/graphs/ch7-e3.png is excluded by !**/*.png
  • docs/basic/images/graphs/costMatrix.png is excluded by !**/*.png
  • docs/basic/images/graphs/pedestrian_only_roads.png is excluded by !**/*.png
  • docs/basic/images/graphs/roads_tag_ids.png is excluded by !**/*.png
  • docs/basic/images/graphs/taxi_net.png is excluded by !**/*.png
  • docs/basic/images/graphs/vehicle_net.png is excluded by !**/*.png
  • docs/basic/images/graphs/walk_net.png is excluded by !**/*.png
📒 Files selected for processing (14)
  • REQUIREMENTS.txt (1 hunks)
  • docs/basic/CMakeLists.txt (1 hunks)
  • docs/basic/graphs.rst (23 hunks)
  • docs/basic/images/CMakeLists.txt (1 hunks)
  • docs/basic/images/graphs/CMakeLists.txt (1 hunks)
  • docs/conf.py (1 hunks)
  • docs/index.rst (1 hunks)
  • docs/scripts/basic/CMakeLists.txt (2 hunks)
  • docs/scripts/basic/data/CMakeLists.txt (1 hunks)
  • docs/scripts/basic/graphs/CMakeLists.txt (2 hunks)
  • docs/scripts/basic/graphs/graphs.sql (4 hunks)
  • docs/scripts/basic/graphs/images.sql (1 hunks)
  • locale/en/LC_MESSAGES/basic/graphs.po (3 hunks)
  • locale/pot/basic/graphs.pot (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build
🔇 Additional comments (13)
docs/basic/graphs.rst (2)

65-124: Well-structured new configuration section.

The new "Configuration from osm2pgrouting" section provides valuable context about OSM data types and their usage in routing. The progressive disclosure using collapse blocks and verification rubrics enhances readability.


617-633: Good addition of pgr_dijkstraCostMatrix documentation.

The new section properly documents the cost matrix function with signature, description, and proper external documentation links. This aligns well with Exercise 8 below.

docs/index.rst (1)

34-34: LGTM: Graphs chapter correctly repositioned.

The reordering places the graphs documentation earlier in the Basic section, which aligns with the PR objective to present graphs first.

locale/pot/basic/graphs.pot (1)

11-11: LGTM: POT file updated to reflect documentation changes.

The translation template has been regenerated with the updated POT-Creation-Date and all msgid entries correctly reflect the restructured graphs documentation. As a generated artifact, this file appropriately mirrors the source RST changes.

docs/scripts/basic/graphs/graphs.sql (7)

6-18: Good addition of configuration inspection queries.

The new configuration-related queries provide valuable insight into OSM highway types and their usage in the dataset. The output files align with the references in the documentation.


165-182: Verify pgr_dijkstraCostMatrix usage with vertex IDs.

The queries pass ARRAY[@ID_1@, @ID_2@, @ID_3@, @ID_4@, @ID_5@] as vertex identifiers to pgr_dijkstraCostMatrix. Confirm that these substitution variables resolve to vertex IDs that exist in the respective net views (vehicle_net, taxi_net, walk_net).

According to pgRouting documentation, the vertex array should contain identifiers that match the source and target columns in the edge SQL.


148-161: Good practice: Creating separate vertex tables for each network.

Extracting vertices from each network view (vehicle_net, taxi_net, walk_net) ensures that each routing network has its own consistent vertex set. This is a solid approach for managing different routing graphs.


1-4: Ensure CASCADE drops are intentional.

The DROP statements use CASCADE, which will drop dependent objects. Verify this is intentional, especially for the vertices table which may have dependencies from the net views.


22-26: Verify ways table schema includes required columns
Ensure the ways table defines source, target, source_osm, and target_osm before running this script, as they’re referenced in the UPDATE statements on lines 36 and 41.


36-42: Confirm source_osm and target_osm exist on the ways table.
The SQL relies on osm2pgrouting’s import to create these columns—please verify your database schema includes them before running these updates.


93-97: Inconsistent source/target identifiers in vehicle_net
The documentation (docs/basic/graphs.rst:451) specifies that pgRouting’s source/target must be OSM node IDs, yet the view selects the internal source, target columns from ways. Either change the SELECT to

source_osm AS source, target_osm AS target

or update the docs to reflect that you’re using internal routing IDs.

docs/basic/images/graphs/CMakeLists.txt (2)

6-12: LGTM: New images added for expanded documentation.

The new image files (costMatrix.png, pedestrian_only_roads.png, roads_tag_ids.png, taxi_net.png) align with the expanded graphs chapter content, particularly the new "Configuration from osm2pgrouting" section and cost matrix visualization.


19-19: Good refactor: Using configure_file instead of FILE(COPY).

Switching from FILE(COPY ${f} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") to configure_file(${f} ${f} COPYONLY) is more idiomatic in modern CMake and produces equivalent behavior for copying files.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a0f21a4 and 54e7e6f.

📒 Files selected for processing (2)
  • docs/basic/graphs.rst (23 hunks)
  • docs/scripts/basic/graphs/images.sql (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/scripts/basic/graphs/images.sql
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (3)
locale/pot/basic/graphs.pot (3)

109-110: Use standard abbreviation for meters per second.

The abbreviation "mts/sec" is non-standard. Consider using "m/s" or spelling out "meters per second" for clarity.

Apply this diff to use the standard abbreviation:

-msgid "The walking speed is ``2 mts/sec``."
+msgid "The walking speed is ``2 m/s``."

543-545: Use standard abbreviation for meters per second.

Same issue as line 109: "mts/sec" should be "m/s" or "meters per second".

Apply this diff:

-msgid "The speed is ``2 mts/sec``."
+msgid "The speed is ``2 m/s``."

454-455: Clarify source/target column requirements.

The text states "The source and target requirements for the function are to be with OSM identifiers" which may be confusing. If the columns are named source and target (not source_osm and target_osm), clarify whether the values are OSM identifiers or internal vertex IDs.

Consider rewording for clarity, such as: "The source and target columns contain vertex identifiers derived from OSM data."

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 54e7e6f and f305738.

📒 Files selected for processing (2)
  • locale/en/LC_MESSAGES/basic/graphs.po (3 hunks)
  • locale/pot/basic/graphs.pot (3 hunks)
🔇 Additional comments (6)
locale/pot/basic/graphs.pot (6)

1-18: LGTM!

The POT file header is correctly formatted with appropriate metadata and the updated creation date.


31-46: LGTM!

The pgRouting function references are properly formatted for Sphinx documentation.


286-420: LGTM!

The pgr_connectedComponents section has the correct function description, proper documentation URL, and well-structured exercises.


574-584: LGTM!

The pgr_dijkstraCostMatrix function description and documentation URL are correct.


635-677: LGTM!

Exercise 8 provides clear, comprehensive instructions for testing the created views with practical examples.


254-256: No change needed—source_osm remains a valid column storing OSM IDs separate from the source vertex ID; the documentation reference is correct.

Likely an incorrect or invalid review comment.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f305738 and 3ea09d8.

📒 Files selected for processing (3)
  • docs/basic/graphs.rst (23 hunks)
  • locale/en/LC_MESSAGES/basic/graphs.po (3 hunks)
  • locale/pot/basic/graphs.pot (3 hunks)

@cvvergara cvvergara merged commit c776d26 into pgRouting:develop Oct 4, 2025
1 check passed
@cvvergara cvvergara deleted the graphs-chapter-rewrite branch October 4, 2025 16:50
@coderabbitai coderabbitai bot mentioned this pull request Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant