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
program to check undirected graph is bipartite or not in c++ #3958
base: master
Are you sure you want to change the base?
Conversation
cin>>n>>m; | ||
|
||
// adj is 2-D vector to store edges between vertex | ||
vector<vector<long int > >adj(n,vector<long int>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix your spacing to match our C++ style guide.
1.) updating header File . 2.) removing extra spacing 3.) Better declaration of variable
std::vector<long int> color(vertex,-1); | ||
std::queue<long int>q; | ||
//for number of edges times | ||
for(int i=0;i<edge;i++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use pre-increment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also use pre-increment operator now
@quantum08 Waiting for your changes! |
Change spacing around angle bracket and type of variable
} | ||
} | ||
if( !flag ) | ||
std::cout << "Graph is bipartite"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a newline to the end of all output using \n
.
update to print output in newline
int main() | ||
{ | ||
long int vertex , edge , u , v , c ; | ||
bool flag=false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you format your code please. Please follow our C++ style guide, located in guides/coding_style/C++/README.md
I believe.
Spacing after conditional statement and naming variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add space around the '=', inside '()', after ';' etc.
Fixes issue:
Changes: