How to fix the “invalid comparator” logic problem in this f How to fix the “invalid comparator” logic problem in this file?… How to fix the “invalid comparator” logic problem in this file?Image transcription texth Solution Explorer (Ctrl+;) Solution ‘Graph’ (1 of 1 project) Microsoft Visual C+ + Runtime Library X + + Graph0-0 References X Debug Assertion Failed! External Dependencies Header Files Program: D:C++Assignment3 DP Ax64DebugGraph.exe Resource Files File: C:Program FilesMicrosoft Visual Source Files… Show more… Show more #include “DirectedGraph.h”#include “set”#include using namespace std;bool DirectedGraph::addVertex(Vertex& v) { if (find(vertexVector.begin(), vertexVector.end(), v) == vertexVector.end()) { vertexVector.push_back(v); return true; } return false;}DirectedGraph::DirectedGraph() {}DirectedGraph::~DirectedGraph() {}bool DirectedGraph::removeVertex(Vertex& v) { auto i = find(vertexVector.begin(), vertexVector.end(), v); if (i == vertexVector.end()) { return false; } auto it = remove_if(edgeVector.begin(), edgeVector.end(), [=](Edge& e1) { return e1.getStart() == v || e1.getEnd() == v; }); for (auto i = edgeVector.end() – 1; i >= it; i–) { edgeVector.erase(i); } vertexVector.erase(i); return true;} bool DirectedGraph::addEdge(Edge& e) { if (find(edgeVector.begin(), edgeVector.end(), e) == edgeVector.end()) { edgeVector.push_back(e); auto s = e.getStart(); addVertex(s); addVertex(e.getEnd()); return true; } return false;}bool DirectedGraph::remove(Edge& e) { auto i = find(edgeVector.begin(), edgeVector.end(), e); if (i == edgeVector.end()) { return false; } edgeVector.erase(i); return true;}bool DirectedGraph::searchVertex(const Vertex& v) { return find(vertexVector.begin(), vertexVector.end(), v) != vertexVector.end();}void DirectedGraph::display() const { cout << toString();}string DirectedGraph::toString() const { string result; set vertexs; for (auto e : edgeVector) { auto start = e.getStart(); auto& end = e.getEnd(); vertexs.insert(start); vertexs.insert(end); result.append(“edge: ” + to_string(start.getId()) + “->” + to_string(end.getId()) + “, weight: ” + to_string(e.getWeight()) + “n”); } result.append(“oraphen node:n”); for (Vertex v : vertexVector) { if (find(vertexs.begin(), vertexs.end(), v) == vertexs.end()) { result.append(“id: ” + to_string(v.getId()) + “,value: ” + to_string(v.getValue()) + “n”); } } return result;}bool DirectedGraph::clean() { vertexVector.clear(); edgeVector.clear(); return true;}void DirectedGraph::display(Vertex& v) const { if (find(vertexVector.begin(), vertexVector.end(), v) == vertexVector.end()) { return; } vector history; this->displayHelper(v, history);}void DirectedGraph::display(Edge& e) const { if (find(edgeVector.begin(), edgeVector.end(), e) == edgeVector.end()) { return; } vector history = { e.getEnd() }; displayHelper(e.getStart(), history);}bool DirectedGraph::searchEdge(const Edge& e) { return find(edgeVector.begin(), edgeVector.end(), e) != edgeVector.end();}bool DirectedGraph::addVertices(Vertex* vArray, int size) { for (int i = 0; i < size; i++) { addVertex(*(vArray + i)); } return true;}bool DirectedGraph::addVertices(Vertex* vArray) { return true;}void DirectedGraph::displayHelper(const Vertex& v, vector history) const { history.insert(history.begin(), v); auto compare = [=](auto e) { return e.getEnd() == v; }; auto it = find_if(edgeVector.begin(), edgeVector.end(), compare); if (it == edgeVector.end()) { // it’s the head, print displayPath(history); return; } while (it != edgeVector.end()) { auto vt = it->getStart(); displayHelper(vt, history); it = find_if(it + 1, edgeVector.end(), compare); }}void DirectedGraph::displayPath(vector& vv) { if (vv.empty()) { return; } for (auto it = vv.begin(); it < vv.end() - 1; it++) { cout << it->getId() << " -> “; } cout << (vv.end() - 1)->getId() << endl;}DirectedGraph::DirectedGraph(const DirectedGraph& d) { edgeVector = d.edgeVector; vertexVector = d.vertexVector;}bool DirectedGraph::operator==(const DirectedGraph& dg) const { if ((vertexVector.size() == dg.vertexVector.size()) && (edgeVector.size() == dg.edgeVector.size())) { for (auto v : dg.vertexVector) { if (find(vertexVector.begin(), vertexVector.end(), v) == vertexVector.end()) { return false; } } for (auto &v : dg.edgeVector) { if (find(edgeVector.begin(), edgeVector.end(), v) == edgeVector.end()) { return false; } } return true; } return false;}DirectedGraph& DirectedGraph::operator=(const DirectedGraph& d) { if (&d != this) { this->edgeVector.clear(); for (auto &e : d.edgeVector) { edgeVector.push_back(e); } this->vertexVector.clear(); for (auto v : d.vertexVector) { vertexVector.push_back(v); } } return *this;}int DirectedGraph::getTotalWeight(const vector& e) { int count = 0; for (auto &e1 : e) { count += e1.getWeight(); } return count;}bool DirectedGraph::operator>(const DirectedGraph& dg) const { return getTotalWeight(edgeVector) > getTotalWeight(dg.edgeVector);}ostream& operator<<(ostream& out, const Graph& g) { out << g.toString(); return out;}DirectedGraph& DirectedGraph::operator++() { for (auto& e : edgeVector) { e.setWeight(e.getWeight() + 1); } return *this;}DirectedGraph DirectedGraph::operator++(int) { auto temp = *this; ++* this; return temp;}DirectedGraph operator+(const DirectedGraph& dg1, const DirectedGraph& dg2) { auto dg3 = dg1; for (auto v : dg2.vertexVector) { dg3.addVertex(v); } for (auto e : dg2.edgeVector) { dg3.addEdge(e); } return dg3;} Computer Science Engineering & Technology C++ Programming ENGINERING COEN 244
How it works
Paste your instructions in the instructions box. You can also attach an instructions file Select the writer category, deadline, education level and review the instructions Make a payment for the order to be assignment to a writer Download the paper after the writer uploads it
Will the writer plagiarize my essay?
You will get a plagiarism-free paper and you can get an originality report upon request.
Is this service safe?
All the personal information is confidential and we have 100% safe payment methods. We also guarantee good grades