cyclegraph: add public CycleGraph::checkReachable()
authorBrian Norris <banorris@uci.edu>
Fri, 17 Aug 2012 00:06:31 +0000 (17:06 -0700)
committerBrian Norris <banorris@uci.edu>
Thu, 23 Aug 2012 01:36:22 +0000 (18:36 -0700)
The private CycleGraph::checkReachable() function can be useful externally,
when provided with two ModelActions. This implements a small wrapper for public
usage.

cyclegraph.cc
cyclegraph.h

index b140ded1382c12cfc9fee46358bd36fc2720aa36..3168923a8c0f260c137755e7775f99a643ab96a5 100644 (file)
@@ -81,6 +81,21 @@ void CycleGraph::addRMWEdge(const ModelAction *from, const ModelAction *rmw) {
        fromnode->addEdge(rmwnode);
 }
 
        fromnode->addEdge(rmwnode);
 }
 
+/**
+ * Checks whether one ModelAction can reach another.
+ * @param from The ModelAction from which to begin exploration
+ * @param to The ModelAction to reach
+ * @return True, @a from can reach @a to; otherwise, false
+ */
+bool CycleGraph::checkReachable(const ModelAction *from, const ModelAction *to) {
+       CycleNode *fromnode = actionToNode.get(from);
+       CycleNode *tonode = actionToNode.get(to);
+
+       if (!fromnode || !tonode)
+               return false;
+
+       return checkReachable(fromnode, tonode);
+}
 
 /**
  * Checks whether one CycleNode can reach another.
 
 /**
  * Checks whether one CycleNode can reach another.
index c8ba531427f29a3edc5613d1ba1f50bf63067ed8..2e523d7950b28c5b91830217414eebbc459d2972 100644 (file)
@@ -21,6 +21,8 @@ class CycleGraph {
        bool checkForCycles();
        void addRMWEdge(const ModelAction *from, const ModelAction *rmw);
 
        bool checkForCycles();
        void addRMWEdge(const ModelAction *from, const ModelAction *rmw);
 
+       bool checkReachable(const ModelAction *from, const ModelAction *to);
+
  private:
        CycleNode * getNode(const ModelAction *);
 
  private:
        CycleNode * getNode(const ModelAction *);