Skip to content
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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

quantum08
Copy link

Fixes issue:

Changes:

code/graph_algorithms/src/Bipartite_check/bipartite.cpp Outdated Show resolved Hide resolved
code/graph_algorithms/src/Bipartite_check/bipartite.cpp Outdated Show resolved Hide resolved
code/graph_algorithms/src/Bipartite_check/bipartite.cpp Outdated Show resolved Hide resolved
cin>>n>>m;

// adj is 2-D vector to store edges between vertex
vector<vector<long int > >adj(n,vector<long int>());
Copy link
Member

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.

code/graph_algorithms/src/Bipartite_check/bipartite.cpp Outdated Show resolved Hide resolved
1.)  updating header File .

2.) removing extra spacing

3.) Better  declaration of variable
code/graph_algorithms/src/Bipartite_check/bipartite.cpp Outdated Show resolved Hide resolved
code/graph_algorithms/src/Bipartite_check/bipartite.cpp Outdated Show resolved Hide resolved
code/graph_algorithms/src/Bipartite_check/bipartite.cpp Outdated Show resolved Hide resolved
std::vector<long int> color(vertex,-1);
std::queue<long int>q;
//for number of edges times
for(int i=0;i<edge;i++)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use pre-increment.

Copy link
Author

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

@contactvaibhavi
Copy link
Member

@quantum08 Waiting for your changes!

Change spacing around angle bracket and type of variable
}
}
if( !flag )
std::cout << "Graph is bipartite";
Copy link
Member

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;
Copy link
Member

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
Copy link
Member

@contactvaibhavi contactvaibhavi left a 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.

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.

None yet

3 participants