+ return addNodeEdge(fromnode, tonode);
+}
+/* Instantiate four forms of CycleGraph::addEdge */
+template bool CycleGraph::addEdge(const ModelAction *from, const ModelAction *to);
+template bool CycleGraph::addEdge(const ModelAction *from, const Promise *to);
+template bool CycleGraph::addEdge(const Promise *from, const ModelAction *to);
+template bool CycleGraph::addEdge(const Promise *from, const Promise *to);
+
+#if SUPPORT_MOD_ORDER_DUMP
+
+static void print_node(const CycleNode *node, FILE *file, int label)
+{
+ modelclock_t idx;
+ if (node->is_promise()) {
+ const Promise *promise = node->getPromise();
+ idx = promise->get_action()->get_seq_number();
+ fprintf(file, "P%u", idx);
+ if (label) {
+ int first = 1;
+ fprintf(file, " [label=\"P%u, T", idx);
+ for (unsigned int i = 0 ; i < model->get_num_threads(); i++)
+ if (promise->thread_is_available(int_to_id(i))) {
+ fprintf(file, "%s%u", first ? "": ",", i);
+ first = 0;
+ }
+ fprintf(file, "\"]");
+ }
+ } else {
+ const ModelAction *act = node->getAction();
+ idx = act->get_seq_number();
+ fprintf(file, "N%u", idx);
+ if (label)
+ fprintf(file, " [label=\"N%u, T%u\"]", idx, act->get_tid());
+ }
+}
+
+void CycleGraph::dumpNodes(FILE *file) const
+{
+ for (unsigned int i = 0; i < nodeList.size(); i++) {
+ CycleNode *n = nodeList[i];
+ print_node(n, file, 1);
+ fprintf(file, ";\n");
+ if (n->getRMW() != NULL) {
+ print_node(n, file, 0);
+ fprintf(file, " -> ");
+ print_node(n->getRMW(), file, 0);
+ fprintf(file, "[style=dotted];\n");
+ }
+ for (unsigned int j = 0; j < n->getNumEdges(); j++) {
+ print_node(n, file, 0);
+ fprintf(file, " -> ");
+ print_node(n->getEdge(j), file, 0);
+ fprintf(file, ";\n");
+ }
+ }
+}
+
+void CycleGraph::dumpGraphToFile(const char *filename) const
+{
+ 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);