Implmenting a complement graph function

63 Views Asked by At

I'm trying to implement an ! operator on Graph (complement operator) using - operator (difference operator). I'm getting the following error: Click here to view the image!

K is the complete graph. Here's the implemenation of the - operator:

Graph Graph::operator-(Graph& graph){
    std::set<std::string> diff_v = this->v;
    std::set<std::pair<std::string, std::string>> diff_e = this->e;
    for(auto it = v.begin(); it != v.end(); it++){
        if(graph.v.count(*it)){
            diff_v.erase(*it);
        }
    }
    for(auto it = e.begin(); it != e.end(); it++){
        if(graph.e.count(*it)){
            diff_e.erase(*it);
        }
    }
    Graph result(diff_v, diff_e);
    return result;
}

if anyone knows why i'm getting the above error message I'd be happy for some assistance. Thank you!!

0

There are 0 best solutions below