-
-
Notifications
You must be signed in to change notification settings - Fork 366
GSoC 2021 Implement Edge Coloring Algorithm for pgRouting by the Boost Graph Library
- Proposal
- Participants
- Timeline
- Log of Pull Requests
- Slides
- Final Report
- Weekly Reports
- References
Edge Coloring is an algorithm used for coloring of the edges for the vertices in the graph. It is an assignment of colors to the edges of the graph so that no two adjacent edges have the same color.
If edges are ordered as e1, e2, ..., en it assigns colors c1, c2, ..., cn in such a way that no vertex connects with 2 edges of the same color.
It is used in several representations of real-world systems like traffic signalling, bi-processors, fiber-optic communication, etc. It can also tell us if a graph is Bipartite. It is implemented in Boost Graph Library (BGL) as Boost::Edge Coloring. It is applicable for undirected and loop-free (i.e no self-loops and no parallel edges) graph. It has a polynomial-time complexity of O(|E| |V|).
I propose to add the above algorithm into pgRouting during the GSoC period.
pgRouting currently does not have the proposed algorithm implemented.
Edge Coloring is not implemented before in pgRouting. The Sequential Vertex Coloring has been implemented in pgRouting during the GSoC 2020 period by Ashish Kumar. However, a single standard function does not exist for this coloring algorithm, besides it has various other applications apart from checking if a graph is Bipartite. Also, it helps complete the coloring algorithms part of the Boost Graph Library in pgRouting.
-
Adding Boost::Edge Coloring algorithm to pgRouting adds more functionality to it and helps future users and developers to use and integrate it with other routing algorithms. It allows access to the algorithm with a single function. It has applications in traffic signalling, scheduling problems, processors and in frequency assignment for fiber optic networks.
-
One of the benefits is, it can tell us whether a graph is Bipartite or not. If in a graph (G), the chromatic number χ′(G) i.e. minimum number of colors needed for proper edge coloring of G is equal to degree Δ(G) (largest number of edges incident to any single vertex) of the graph, (i.e. χ′(G) = Δ(G)) then G is said to be Bipartite.
-
One of the most useful real-world benefits is in fiber-optic communication, the Edge Coloring algorithm is the problem of assigning colors (frequencies of light) to pairs of nodes (edges) that wish to communicate with each other, and paths through a fiber-optic communications network for each pair, subject to the restriction that no two paths that share a segment of fiber use the same frequency (color) as each other.
To provide users of pgRouting more functionality I am going to implement this algorithm from Boost Graph Library (BGL). As due to new changes in GSoC this year the time has been reduced but if the time permits I intend to create lots of tests and implement more applications. All these algorithms and applications are helpful for future developers, users and development of pgRouting as a whole.
The deliverables for the proposal would be:
- Implementation of pgr_edgeColoring().
- SQL, C, C++ code related to the function.
- A wiki page for the project.
- User documentation.
- Example Query for the documentation.
- Basic pgTap tests.
- Report for evaluations.
Detailed Proposal in PDF format
Title | GitHub Handle | Name |
---|---|---|
1st Mentor | @dkastl | Daniel Kastl |
2nd Mentor | @ashrafroni | Ashraf Hossain |
3rd Mentor | @rahulworld | Rahul Chauhan |
Student Developer | @Veenits123 | Veenit Kumar |
- Set up the development environment.
- Interact with mentors, introduce myself to the community, and actively get involved in the discussion.
- Get familiar with pgRouting’s development style. Understand expected coding, documentation, and testing standards set by pgRouting.
- Set up a wiki page to keep track of weekly progress.
- Develop a better understanding of PostgreSQL, PostGIS, Pl/pgSQL, and how they interact with pgRouting.
- Learn to create unit tests using pgTap.
- Implement simple dummy functions to better understand pgRouting.
- Design
pgr_edgeColoring()
function. - Create a basic skeleton for documentation and tests.
- Create code skeleton of SQL and C code which allows the C++ implementation of the function to work with PostgreSQL.
- Design the detailed signature for the
pgr_edgeColoring()
function. - Go through the Boost related work in pgRouting for a better understanding and skills on the implementation.
- Implement
pgr_edgeColoring()
function along with its helper files.
- Read data from PostgreSQL.
- Transfer data to C++ containers suitable for use with Boost Graph Library.
- Create the necessary class wrapper for the Boost function.
- Process the data with the Boost Function.
- Transform result to C containers suitable for executing with PostgreSQL queries.
- Prepare user documentation.
- Create suitable queries using the sample data provided on pgRouting documentation.
- Work on the submissions required as part of the first evaluation.
- Prepare the First Coding Period report.
- Work on the feedback as provided from the First Evaluation.
- Finalize the above coding part (if remaining) to get an overall solution.
- Prepare Second Coding Period synopsis.
- Prepare a basic outline and framework for the pgTap tests.
- Create units and internal tests for the
pgr_edgeColoring()
function.- Create pgTap tests to check no server crash.
- Create pgTap unit tests for expected results for different small graphs:
- One vertex graph.
- One edge graph.
- Two edge graph.
- Cyclic graph with 3 edges.
- Test all the critical edge cases.
- Fix bugs if found (any).
- Fix all the bugs and documentation details.
- Review, complete and finalize all the tests and documentation for all the functions implemented.
- Integration to the
develop
branch in the main repository of pgRouting.
- Prepare final submission along with final user documentation.
- Create a detailed final report.
Link to all the Pull Requests made in GSoC-pgRouting repository for GSoC 2021
Pull Request | Description | Date | Status |
---|---|---|---|
#2084 | [GSoC-2021] Updating pgr_edgeColoring Doc | August 13th, 2021 | Merged |
#2061 | [GSoC-2021] Experimental Function - pgr_edgeColoring | August 11th, 2021 | Merged |
#188 | GSoC-2021 Week9: pgr_edgeColoring | August 6th, 2021 | Merged |
#186 | GSoC-2021 Week8: pgr_edgeColoring | August 2nd, 2021 | Merged |
#184 | GSoC-2021 Week7: pgr_edgeColoring | July 24th, 2021 | Merged |
#182 | GSoC-2021 Week6: pgr_edgeColoring | July 19th, 2021 | Merged |
#179 | GSoC-2021 Week5: pgr_edgeColoring | July 11th, 2021 | Merged |
#176 | GSoC-2021 Week4: pgr_edgeColoring | July 04th, 2021 | Merged |
#173 | GSoC-2021 Week3: pgr_edgeColoring | June 27th, 2021 | Merged |
#171 | GSoC-2021 Week2: pgr_edgeColoring | June 19th, 2021 | Merged |
#169 | GSoC-2021 Week1: pgr_edgeColoring | June 12th, 2021 | Merged |
#142 | Task 2: Experience with GitHub & Git | February 9th, 2021 | GSoC Task Pull Request - Not to Merge |
https://docs.google.com/presentation/d/1NMg7qBB1QMqyygdzpqZvp6aRlG7iUkGWrpYQy1ddK2E/edit?usp=sharing
Report Mail - [SoC], [pgrouting-dev] (sent to these two mailing lists of OSGeo).
Hello everyone,
With GSoC coming to an end, I hereby present my final report of the work I have done over the past two and half months. It has been an awesome experience and great learning, working with the pgRouting community and mentors. This report is following the guidelines set by Google and OSGeo GSoC Admins.
Title: Implement Edge Coloring Algorithm for pgRouting by the Boost Graph Library
Organisation: pgRouting under OSGeo
Abstract: This GSoC project dealt with the implementation of one new Graph algorithm in pgRouting. The algorithm is described below:
-
Edge Coloring: It is an algorithm used for coloring the edges for the vertices in the graph. It is an assignment of colors to the edges of the graph so that no two adjacent edges have the same color.
If edges are ordered as e1, e2, ..., en it assigns colors c1, c2, ..., cn in such a way that no vertex connects with 2 edges of the same color.
It is used in several representations of real-world systems like traffic signaling, bi-processors, fiber-optic communication, etc. It can also tell us if a graph is Bipartite. It is implemented in Boost Graph Library (BGL) as
boost::edge_coloring
. It is applicable for undirected and loop-free (i.e no self-loops and no parallel edges) graphs. It has a polynomial-time complexity ofO(|E| |V|)
.
State of the Project Before GSoC: pgRouting currently does not have this algorithm implemented. A single standard function does not exist for this coloring algorithm.
The addition that my project brought to pgRouting: The deliverables are code, documentation, documentation tests, and the pgTAP tests of the function.
- Edge Coloring (pgr_edgeColoring) can be used to check whether a graph is Bipartite or not. If in a graph (G), the chromatic number χ′(G) i.e. the minimum number of colors needed for proper edge coloring of G is equal to degree Δ(G) (largest number of edges incident to any single vertex) of the graph, (i.e. χ′(G) = Δ(G)) then G is said to be Bipartite.
Potential Future Work:
-
The implementation of Edge Coloring completes the coloring algorithms part of the Boost Graph Library in pgRouting. But, we can implement
Boman et al Graph Coloring Algorithm
by the Parallel Boost Graph Library, which colors the vertices of an undirected, distributed graph such that no two adjacent vertices have the same color. -
Cuthill-Mckee Algorithm
can be implemented by the Boost Graph Library, it adds functionality to pgRouting for reducing the bandwidth of an undirected graph.
Links:
-
Code Documentation:
- Edge Coloring (pgr_edgeColoring): https://docs.pgrouting.org/3.3/en/pgr_edgeColoring.html
-
Tags:
- Edge Coloring (GSoC-2021-veenits123-edgeColoring): https://github.com/pgRouting/GSoC-pgRouting/releases/tag/GSoC-2021-veenits123-edgeColoring
-
Pull Requests:
-
Final Pull Request: (#2061) Experimental Function - pgr_edgeColoring (https://github.com/pgRouting/pgrouting/pull/2061).
-
Pull Request for removing links from linkcheck_ignore: (#2084) Updating pgr_edgeColoring Doc (https://github.com/pgRouting/pgrouting/pull/2084).
-
Intermediate pull requests: https://github.com/pgRouting/GSoC-pgRouting/pulls?q=is%3Apr+author%3Aveenits123
-
-
Project Documentation (Wiki Page): https://github.com/pgRouting/pgrouting/wiki/GSoC-2021-Implement-Edge-Coloring-Algorithm-for-pgRouting-by-the-Boost-Graph-Library
Images:
- pgr_edgeColoring: https://drive.google.com/file/d/1cPMjYeNolHJ2YjAsFc4RrOkbxcsheVMY/view?usp=sharing
Media:
- Slide Demonstration: https://docs.google.com/presentation/d/1NMg7qBB1QMqyygdzpqZvp6aRlG7iUkGWrpYQy1ddK2E/edit?usp=sharing
I am so glad to be a part of the amazing GSoC community. I have learned a lot during this period and I am sure that will help me in my future development journey. I would be happy if my code proves beneficial to the community. Lastly, thank you everyone for the supports!
Thanks and Regards,
Veenit Kumar
-
Report Mail - [SoC], [pgrouting-dev]
-
What did I get done this week?
- Merged two Pull Requests in the pgRouting develop branch:
- Created a issue for adding
pgr_edgeColoring
in pgRouting:- #2060: Detailed signature of the new function pgr_edgeColoring to be added in pgRouting
- Created a tag in GSoC-pgRouting containing the code of experimental function
pgr_edgeCOloring
: GSoC-2021-veenits123-edgeColoring
-
What do I plan on doing next week?
- Make the final report along with the presentation of the work.
- Submit the final evaluation of my mentors.
-
Am I blocked on anything?
- No, I am not blocked on anything.
-
Report Mail - [SoC], [pgrouting-dev]
-
What did I get done this week?
- Refined all the files I have worked on during the GSoC period.
- Combined all the commits according to proper files and folders wise.
- Made a pull request with all these changes (#188).
-
What do I plan on doing next week?
- Create an issue of my GSoC work on: https://github.com/pgRouting/pgrouting/issues
- Create a pull request in the
pgRouting
main repository: https://github.com/pgRouting/pgrouting/pulls
-
Am I blocked on anything?
- No, I am not blocked on anything.
-
Report Mail - [SoC], [pgrouting-dev]
-
What did I get done this week?
- Refined the pgTap files.
- Added more pgTap tests to the file
edge-cases.sql
. - Made a pull request with all these changes (#186).
-
What do I plan on doing next week?
- Refine the similar commits together and merge them in the main repository: https://github.com/pgRouting/GSoC-pgRouting.
- Final fixing and updating of files failing on building according to new styles.
-
Am I blocked on anything?
- No, I am not blocked on anything.
-
Report Mail - [SoC], [pgrouting-dev]
-
What did I get done this week?
- Refined all the files.
- Removed all the unwanted code and comments.
- Made a pull request with all these changes (#184).
-
What do I plan on doing next week?
- Refine pgTap files.
- Make more pgTap tests of various Graphs types.
-
Am I blocked on anything?
- No, I am not blocked on anything.
-
Report Mail - [SoC], [pgrouting-dev]
-
What did I get done this week?
- Made
tools/testers/doc_queries_generator.pl -alg coloring
test pass. - Made
tools/developer/taptest.sh coloring/edgeColoring -p 5432
pass. - Made a pull request with all these changes (#182).
- Made
-
What do I plan on doing next week?
- Rectify coding styles of C++ files.
-
Am I blocked on anything?
- No, I am not blocked on anything.
-
Report Mail - [SoC], [pgrouting-dev]
-
What did I get done this week?
- Created the necessary class wrapper for the Boost function.
- Worked on
include/coloring/pgr_edgeColoring.hpp
. - Worked on
src/coloring/edgeColoring_driver.cpp
. - Worked on
src/coloring/pgr_edgeColoring.cpp
. - Made a pull request with all these changes (#179).
-
What do I plan on doing next week?
- Make pgTap tests pass.
- Make
tools/testers/doc_queries_generator.pl -alg coloring
pass.
-
Am I blocked on anything?
- No, I am not blocked on anything.
-
Report Mail - [SoC], [pgrouting-dev]
-
What did I get done this week?
- Created the necessary files for pgTap tests.
- Worked on pgtap/coloring/edgeColoring/
- Modified
innerQuery.sql
- Modified
types_check.sql
- Modified
no_crash_test.sql
- Modified
edge-cases.sql
- Modified
- Made a pull request with all these changes (#176).
-
What do I plan on doing next week?
- Make
tools/testers/doc_queries_generator.pl -alg coloring
pass. - Update the required Boost function file and other helper functions files.
- Discussion on the objective: https://gitter.im/pgRouting/pgrouting?at=60df1e9e65513b4d91439da7
- Make
-
Am I blocked on anything?
- Yes, I am blocked.
- Due to an external situation I will use less time for Week 5 that will be compensated on week 6 as follows:
- Originally there are 2 objectives for Weeks 5 & 6:
- Week 5: Objective is to have
tools/testers/doc_queries_generator.pl -alg coloring
working. - Week 6: Objective
pgTap
test must pass.
- Week 5: Objective is to have
- Originally there are 2 objectives for Weeks 5 & 6:
- So, because of reducing the time on Week 5 and moving it to week 6:
- Week 5: Initial work on the objective:
tools/testers/doc_queries_generator.pl -alg coloring
working. - Week 6: Final work on the objective:
tools/testers/doc_queries_generator.pl -alg coloring
working andpgTap
test must pass.
- Week 5: Initial work on the objective:
-
Report Mail - [SoC], [pgrouting-dev]
-
What did I get done this week?
- Created the necessary class wrapper for the Boost function.
- Created a new file
src/coloring/pgr_edgeColoring.cpp
containing all the necessary function to be called by the driver file. - Worked on
include/coloring/pgr_edgeColoring.hpp
to read data. - Worked on
src/coloring/edgeColoring_driver.cpp
, the main file responsible for reading data of type SQL. - Updated
doc/conf.py.in
by adding links to ignore so that it gets compiled on GitHub action. - Updated
docqueries/coloring/test.conf
by addingdoc-edgeColoring
. - Made a pull request with all these changes (#173).
-
What do I plan on doing next week?
- Update all the pgTap files related to
pgr_edgeColoring
. - Create the tests for handling:
edge Cases, inner Queries, no Crash, types Check
. - Work will be reflected here: https://github.com/pgRouting/GSoC-pgRouting/tree/veenit-2021/pgtap/coloring/edgeColoring
- Update all the pgTap files related to
-
Am I blocked on anything?
- No, I am not blocked on anything.
-
Report Mail - [SoC], [pgrouting-dev]
-
What did I get done this week?
- Created the necessary class wrapper for the Boost function.
- Worked on
include/coloring/pgr_edgeColoring.hpp
to read data. - Worked on documentation for the
pgr_edgeColoring
function. - Updated
doc/coloring/
:pgr_edgeColoring.rst, coloring-family.rst
anddocqueries/coloring/
:doc-edgeColoring.result, doc-edgeColoring.test.sql
files. - Made a pull request with all these changes (#171).
-
What do I plan on doing next week?
- Creating new files for connecting Boost.
- Implement my own code for the Graph type and not using
pgr_base_graph
. - Create the necessary class wrapper for the Boost function.
- Process the data with the Boost Function.
- Details in the Gitter chat: https://gitter.im/pgRouting/pgrouting?at=60ccc7b387848634af29a743
-
Am I blocked on anything?
- Yes, I am blocked on connecting Boost Library to pgRouting.
- Calling function in
include/coloring/pgr_edgeColoring.hpp
fromsrc/coloring/edgeColoring_driver.cpp
gives error on compiling. - The error log: https://github.com/pgRouting/GSoC-pgRouting/pull/171/checks?check_run_id=2865466232
-
Report Mail - [SoC], [pgrouting-dev]
-
What did I get done this week?
- Started working on the
pgr_edgeColoring
function. - Dummy placements of all the files that I need to create during the GSoC period.
- Checked the code after committing using command:
bash tools/scripts/code_checker.sh coloring
- Updated
CMakeLists.txt
forsql, src, doc, docqueries
files. - Learned about
license_check
,News_check
,shell_check
,signature_check
, etc. - Learned how to use terminal and GitHub Action to check the error while building files.
- Made a pull request with all these changes (#169).
- Started working on the
-
What do I plan on doing next week?
- Fix all the Bugs and Errors getting on the building and compiling of files during Week-1.
- Design
boost::edge_coloring()
. - Create the necessary class wrapper for the Boost function.
- Process the data with the Boost Function.
-
Am I blocked on anything?
- No, I have no issues.
-
Introductory Mail - [SoC], [pgrouting-dev]
-
Commmunity Bonding Period Report Mail - [SoC], [pgrouting-dev]
- Set up the development environment.
- Interact with mentors, introduce myself to the community, and actively get involved in the discussion.
- Set up a wiki page to keep track of weekly progress.
- Add a wiki link to OSGeo's accepted student's wiki page.
- Studied GSoC students guide and the OSGeo recommendations for students.
- Introduce myself and my project on OSGeo's SOC and pgrouting-dev mailing list.
- Get familiar with pgRouting’s development style. Understand expected coding, documentation, and testing standards set by pgRouting.
- Develop a better understanding of PostgreSQL, PostGIS, Pl/pgSQL, and how they interact with pgRouting.
- Learn to create unit tests using pgTAP.
- Created a public repository
GSoC-pgRouting
where all my works are reflected in the GSoC period. - Learned how and where to create Pull Request, merge and how to commit, etc.
- Created a new branch named
veenit-2021
in the GSoC-pgRouting repository, where I will be merging all the Pull Requests.
-
May 21st
- Introduction meeting with the mentors.
- Discussion on the future plans of the GSoC period.
-
May 28th
- Cancelled due to Cyclone in my area.
-
June 1st
- Basic Repository preparation of pgRouting.
- Understood the files and structures:
sql, src, include, pgtap, doc, docqueries
of various functions. - Understood and analyzed the coding style of
pgr_dijkstra
,pgr_bdDijkstra
,pgr_bipartite
, etc.
-
June 4th
- Learned how to design the functions, create various tests, run tests, etc.
- Understood how is a test designed and how to do the testing using pgTAP like types-check, inner-query, no-crash-test, edge-cases.
- Understood the development and coding style of C++, SQL and C files of the functions.
- Learned how and where to create Pull Request, how to commit, etc.
-
June 11th
- Checked the code after committing using command:
bash tools/scripts/code_checker.sh
- Learned about
license_check
,News_check
,shell_check
,signature_check
, etc. - Learned how to use terminal and GitHub Action to check the error while building files.
- Checked the code after committing using command:
-
June 18th
- Tried to fix the Boost connection error.
- Details here: https://gitter.im/pgRouting/pgrouting?at=60cca9c43169e234987242ee
- Discuss the future work related to the blocking issue in Boost.
- How to comment in the file so that compiler does not read it:
#if 0
.....what to comment inside;
#endif
-
June 25th
- Discussed the changes in SQL files of
pgRouting
. - Discussed about OSD - Open Source Day and issues created in regard to that: https://github.com/pgRouting/pgrouting/issues?q=is%3Aissue+is%3Aopen+label%3AOSD.
- How to work on the next Week Milestone i.e. pgTap tests.
- Discussed the changes in SQL files of
-
July 2nd
- Discussed what changes needed to make in C++ files.
- Discussed next week milestone i.e. to make
docqueries
test pass. - Discussion in the gitter: https://gitter.im/pgRouting/pgrouting?at=60df1e9e65513b4d91439da7
-
July 09
- Meeting was cancelled and scheduled for July 13.
-
July 13
- Made pgTap and docqueries tests pass.
- Discussed new coding styles in C++ files.
-
July 23
- Discussion about how to create pgTap tests on different types of Graphs.
-
July 30
- Discussion about how to combine commit together and merge them in the main repository: https://github.com/pgRouting/GSoC-pgRouting.
-
August 06
- Discussion about how to create an issue and final pull request to merge GSoC work in the
pgRouting
main repository: https://github.com/pgRouting/pgrouting.
- Discussion about how to create an issue and final pull request to merge GSoC work in the
-
August 10
- Reviewing of the final pull request that needs to get merged in the
pgRouting
develop branch: (#2061): Experimental Function - pgr_edgeColoring. - Discussion on how to create a tag for the GSoC work.
- Reviewing of the final pull request that needs to get merged in the
-
Proposal Mail - [SoC], [pgrouting-dev]
- Misra & Gries Edge Coloring Algorithm https://en.wikipedia.org/wiki/Misra_%26_Gries_edge_coloring_algorithm
- Edge Coloring https://en.wikipedia.org/wiki/Edge_coloring
- https://www.cs.utexas.edu/users/misra/psp.dir/vizing.pdf Misra, Jayadev; Gries, David(1992). "A constructive proof of Vizing's theorem"
- https://github.com/pgRouting/pgrouting/tree/master
- https://github.com/pgRouting/pgrouting/tree/develop
- Graph Coloring https://en.wikipedia.org/wiki/Graph_coloring
- Graph Bandwidth https://en.wikipedia.org/wiki/Graph_bandwidth
- https://codeforces.com/blog/entry/75431 Story about Edge Coloring of Graph
- pgRouting queries on Stack Overflow https://stackoverflow.com/search?q=pgrouting
- pgRouting GSoC Ideas: 2021 https://github.com/pgRouting/pgrouting/wiki/GSoC-Ideas:-2021
- https://github.com/pgRouting/GSoC-pgRouting/wiki/Creating-a-GSoC-schedule
- pgRouting Workshop https://workshop.pgrouting.org/2.6/en/index.html
- https://docs.pgrouting.org/3.2/en/genindex.html pgRouting Documentation
- MIT 6.042J Mathematics for Computer Science, Fall 2010 http://www.youtube.com/watch?v=h9wxtqoa1jY
- https://www.youtube.com/watch?v=_3-XbvYqMEo 2019 - Shortest path in the database and more with pgRouting
- Google Summer of Code Recommendations for Students https://wiki.osgeo.org/wiki/Google_Summer_of_Code_Recommendations_for_Students
- https://www.openstreetmap.org/ OpenStreetMap