Skip to content

Added Bipartite Algorithm #646

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

Closed
wants to merge 1 commit into from

Conversation

hargunkaur286
Copy link
Contributor

@hargunkaur286 hargunkaur286 commented Mar 15, 2025

References to other Issues or PRs or Relevant literature

Fixes #645

Brief description of what is fixed or changed

This PR introduces the implementation of a bipartite-check algorithm.

  1. Added the is_bipartite function in pydatastructs/graphs/algorithms.py to determine whether an undirected graph is bipartite using a BFS-based approach. The algorithm runs in O(V + E) time and returns a tuple containing a boolean indicating bipartiteness and a dictionary mapping vertices to their assigned colors.

  2. Updated the documentation with an example usage snippet, and relevant reference link.

  3. Updated the all list to expose is_bipartite as part of the public API.

  4. Added the test cases for the bipartite-check algorithm.

Other comments

Signed-off-by: Hargun Kaur <hargunkaur286@gmail.com>
@czgdp1807
Copy link
Member

Thanks for this. Actually there is another PR for this - https://github.com/codezonediitj/pydatastructs/pull/655/files and it looks better to me. So closing this one.

@czgdp1807 czgdp1807 closed this Mar 19, 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.

Add Bipartite Graph Checking Algorithm
2 participants