From: Matthew Fernandez Date: Sat, 8 May 2021 03:42:36 +0000 (-0700) Subject: manage graph collection in VPSC::constraintGraphIsCyclic with smart pointers X-Git-Tag: 2.47.2~11^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=597daefeb6ed9aae91289b05cf231e8857705f57;p=graphviz manage graph collection in VPSC::constraintGraphIsCyclic with smart pointers Removes some manual memory management. --- diff --git a/lib/vpsc/solve_VPSC.cpp b/lib/vpsc/solve_VPSC.cpp index f683de8e0..80e73dfd4 100644 --- a/lib/vpsc/solve_VPSC.cpp +++ b/lib/vpsc/solve_VPSC.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include using std::ios; @@ -306,11 +307,10 @@ struct node { // useful in debugging - cycles would be BAD bool VPSC::constraintGraphIsCyclic(const unsigned n, Variable *vs[]) { map varmap; - vector graph; + vector> graph; for(unsigned i=0;iin) { @@ -325,9 +325,9 @@ bool VPSC::constraintGraphIsCyclic(const unsigned n, Variable *vs[]) { } while(!graph.empty()) { node *u=nullptr; - vector::iterator i=graph.begin(); + vector>::iterator i=graph.begin(); for(;i!=graph.end();i++) { - u=*i; + u=(*i).get(); if(u->in.empty()) { break; } @@ -340,12 +340,8 @@ bool VPSC::constraintGraphIsCyclic(const unsigned n, Variable *vs[]) { for(node *v : u->out) { v->in.erase(u); } - delete u; } } - for(unsigned i=0; i