X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=cyclegraph.cc;h=aa3d24548a554ab039074282f5bab3246e3d3ccd;hb=bbc3405aa23e6eafb3863738c4e203764694e9a4;hp=ecf8a781c2770ebd09766cff47030e3e094bd2d7;hpb=5485feb8f53f4fe816b08d854fc3e82b00c33b0b;p=model-checker.git diff --git a/cyclegraph.cc b/cyclegraph.cc index ecf8a78..aa3d245 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); } @@ -167,8 +173,8 @@ bool CycleGraph::checkReachable(const ModelAction *from, const ModelAction *to) * @return True, @a from can reach @a to; otherwise, false */ bool CycleGraph::checkReachable(CycleNode *from, CycleNode *to) { - std::vector > queue; - HashTable discovered; + std::vector > queue; + HashTable discovered; queue.push_back(from); discovered.put(from, from);