{"id":20409709,"url":"https://github.com/sleekpanther/bipartite-testing","last_synced_at":"2026-05-28T01:31:51.565Z","repository":{"id":115108609,"uuid":"87490274","full_name":"SleekPanther/bipartite-testing","owner":"SleekPanther","description":"Algorithm to test if a given graph is Bipartite or not","archived":false,"fork":false,"pushed_at":"2017-04-08T19:41:19.000Z","size":615,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-05T02:43:05.198Z","etag":null,"topics":["algorithm","bfs","bipartite","bipartite-graphs","bipartite-test","bipartite-testing","breadth","edges","graph","graph-algorithms","graphs","java","noah","noah-patullo","pattullo","patullo","patulo"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SleekPanther.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-07T01:14:37.000Z","updated_at":"2017-05-21T12:16:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"90ecd4f7-8a36-4008-9fee-c9ebc2892af2","html_url":"https://github.com/SleekPanther/bipartite-testing","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SleekPanther/bipartite-testing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SleekPanther%2Fbipartite-testing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SleekPanther%2Fbipartite-testing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SleekPanther%2Fbipartite-testing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SleekPanther%2Fbipartite-testing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SleekPanther","download_url":"https://codeload.github.com/SleekPanther/bipartite-testing/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SleekPanther%2Fbipartite-testing/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33590884,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-27T02:00:06.184Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","bfs","bipartite","bipartite-graphs","bipartite-test","bipartite-testing","breadth","edges","graph","graph-algorithms","graphs","java","noah","noah-patullo","pattullo","patullo","patulo"],"created_at":"2024-11-15T05:43:07.816Z","updated_at":"2026-05-28T01:31:51.551Z","avatar_url":"https://github.com/SleekPanther.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bipartite Graph Testing Algorithm\nModification of **Breadth First Serach** to check if a graph is **bipartite**  \nUses the same BFS approach as I use in [BFS/DFS Algorithms](https://github.com/SleekPanther/breadth-first-search-depth-first-search-graphs)\n\n## Bipartite Graphs\nA bipartite graph is one that can be partitioned into 2 sets of vertices where **no edge has both end-nodes in the same set**  \nA helpful abstraction is to imagine coloring the vertices 1 of 2 colors so that **every edge has end-nodes of different colors**  \n\n### This is the 1st graph tested in the code\n\u003cimg src=\"images/bipartite-graph-example.png\" width=\"300\"\u003e\n\nAn important property of Bipartite graphs is they **contain NO odd-length cycle**  \n**A Bipartite Graph (even length cycle)**  \n\u003cimg src=\"images/graph-even-cycle.png\" width=\"300\"\u003e\n\n**A Non-Bipartite Graph (odd length cycle CANNOT be colored \u0026 still maintain edges with different colored end-nodes)**\n\n### This is the 2nd graph that the code tests\n\u003cimg src=\"images/graph-odd-cycle.png\" width=\"300\"\u003e  \n\n## Algorithm\n- Modification of Breadth First Search\n- Explore from any arbitrary node\n- Color all nodes in a layer of BFS **Red** if if layer number is even, **Blue** if odd\n- Scan edges to see if any edge with the same color on both ends (return false if that's the case)\n\n![](images/bipartite-pseudocode.png)\n\n## Code Notes\n- Uses an **adjacency list** graph representation\n- `String[] color` is calculated during BFS based on if `layerCounter` is even or odd\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsleekpanther%2Fbipartite-testing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsleekpanther%2Fbipartite-testing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsleekpanther%2Fbipartite-testing/lists"}