X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=cyclegraph.cc;h=321ebe9e2f242babe1adad4e233dd7fe51427e71;hb=f94de5b6daa067501562ed3047bfb6b4939f9435;hp=ecf8a781c2770ebd09766cff47030e3e094bd2d7;hpb=202074f941d19cef894068e7f79d76b2df598f4b;p=model-checker.git diff --git a/cyclegraph.cc b/cyclegraph.cc index ecf8a78..321ebe9 100644 --- a/cyclegraph.cc +++ b/cyclegraph.cc @@ -41,6 +41,7 @@ CycleNode * CycleGraph::getNode(const ModelAction *action) { void CycleGraph::addEdge(const ModelAction *from, const ModelAction *to) { ASSERT(from); ASSERT(to); + ASSERT(from != to); CycleNode *fromnode=getNode(from); CycleNode *tonode=getNode(to); @@ -82,6 +83,7 @@ void CycleGraph::addEdge(const ModelAction *from, const ModelAction *to) { void CycleGraph::addRMWEdge(const ModelAction *from, const ModelAction *rmw) { ASSERT(from); ASSERT(rmw); + ASSERT(from != rmw); CycleNode *fromnode=getNode(from); CycleNode *rmwnode=getNode(rmw); @@ -120,11 +122,7 @@ void CycleGraph::addRMWEdge(const ModelAction *from, const ModelAction *rmw) { } #if SUPPORT_MOD_ORDER_DUMP -void CycleGraph::dumpGraphToFile(const char *filename) { - char buffer[200]; - sprintf(buffer, "%s.dot",filename); - FILE *file=fopen(buffer, "w"); - fprintf(file, "digraph %s {\n",filename); +void CycleGraph::dumpNodes(FILE *file) { for(unsigned int i=0;i * edges=cn->getEdges(); @@ -139,6 +137,14 @@ void CycleGraph::dumpGraphToFile(const char *filename) { fprintf(file, "N%u -> N%u;\n", action->get_seq_number(), dstaction->get_seq_number()); } } +} + +void CycleGraph::dumpGraphToFile(const char *filename) { + char buffer[200]; + sprintf(buffer, "%s.dot",filename); + FILE *file=fopen(buffer, "w"); + fprintf(file, "digraph %s {\n",filename); + dumpNodes(file); fprintf(file,"}\n"); fclose(file); } @@ -168,7 +174,7 @@ bool CycleGraph::checkReachable(const ModelAction *from, const ModelAction *to) */ bool CycleGraph::checkReachable(CycleNode *from, CycleNode *to) { std::vector > queue; - HashTable discovered; + HashTable discovered; queue.push_back(from); discovered.put(from, from);