Question: Please code this in C + + . Please be sure all of these functions have circumstances where they return true, and some where they

Please code this in C++. Please be sure all of these functions have circumstances where they return true, and some where they return false. THis should be based on the name of each function. a.(25 pts) Implement the bool isTwoColorable() method. This method should return true if the vertices of the graph can each be assigned one of two colors such that no pair of adjacent nodes have the same color and false otherwise. Graph coloring is a very interesting question in general with important connections to a variety of applications including scheduling and resource allocation. b.(25 pts) Implement the bool isConnected() method. This method should return true if the graph is connected and false otherwise. Recall that an undirected graph G =(V, E) is connected if, for all pairs of vertices u, v in V , there is at least one path between u and v. c.(25 pts) Implement the bool hasCycle() method. This method should return true if the graph has at least one cycle and false otherwise. Recall that an undirected graph G =(V, E) has a cycle if there exist vertices u, v in V such that there are at least two distinct paths between u and v. The method bool has CycleRecur(int s) might be helpful here. You are not required to implement this method. It is intended to serve a similar purpose as DFSVisit. 4.(25 pts) Implement the bool isReachable(int u, int v) method. This method should return true if node v is reachable from node u. Note that, since we are dealing with undirected graphs, if v is reachable from u, u is reachable from v as well. In general, v is reachable from u if there is a path from u to v in the graph. Here is the code to be modified: bool Graph::isTwoColorable(){ return false; } bool Graph::isConnected(){ return false; } bool Graph::hasCycle(){ return false; } bool Graph::hasCycleRecur(int s){ return false; } bool Graph::isReachable(int u, int v){ return false; } Here are some header files you will need: Graph.h: #ifndef GRAPH_H #define GRAPH_H #include #include #include "Node.h" class Graph{ public: std::vector> nodes; Graph(); void printAdjList(); bool isNeighbor(int, int); void DFS(); int DFSVisit(int, int); void BFS(int); std::vector distancesFrom(int); bool isTwoColorable(); bool isConnected(); bool hasCycle(); bool hasCycleRecur(int); bool isReachable(int, int); }; #endif Node.h: #ifndef NODE_H #define NODE_H #include #include #include class Node{ public: int id; int dist; int discovered; int finished; bool visited; std::shared_ptr predecessor; std::string color; std::vector> neighbors; Node(); Node(int); }; #endif Node.cpp: #include "Node.h" #include Node::Node(){ id =0; dist = INT_MAX; discovered =-1; finished =-1; visited = false; color =""; predecessor = nullptr; neighbors ={}; } Node::Node(int i){ id = i; dist = INT_MAX; discovered =-1; finished =-1; visited = false; color =""; predecessor = nullptr; neighbors ={}; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!