From a848d0fd96b4003cf9fd813239c417e3d09297ef Mon Sep 17 00:00:00 2001 From: i-vishi Date: Tue, 2 Oct 2018 02:15:19 +0530 Subject: [PATCH] Create checkBipartite.cpp check bipartite graph using bfs --- checkBipartite.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 checkBipartite.cpp diff --git a/checkBipartite.cpp b/checkBipartite.cpp new file mode 100644 index 0000000..c6bb6b9 --- /dev/null +++ b/checkBipartite.cpp @@ -0,0 +1,61 @@ +//Check whether a graph is bipartite or not + +#include +#define max 10000 // Limit of vertices + +int mat[max][max]; //Adjacency Matrix (to be taken as input) +int bfsQ[max]; //Queue for BFS +int r = -1; +int f = 0; +bool bfsVisited[max]; //Visited array for vertices +bool color[max]; //Color array for vertices + +void makeBFS(int v, int n){ //make bfs and assign alternate colors to vertices + for(int i=0;i>n; + cout<<"Enter adjacency matrix: \n"; + for(int i=0;i>mat[i][j]; + } + } + bool ch = checkBipartite(n); + cout<