From 6152f84e7a7326643981e14884764f250fa13ea8 Mon Sep 17 00:00:00 2001
From: Brian Norris <banorris@uci.edu>
Date: Fri, 4 Jan 2013 11:05:10 -0800
Subject: [PATCH] cyclegraph: add back edges to CycleNode

---
 cyclegraph.cc | 11 +++++++++++
 cyclegraph.h  |  5 +++++
 2 files changed, 16 insertions(+)

diff --git a/cyclegraph.cc b/cyclegraph.cc
index 672a398..3949b6e 100644
--- a/cyclegraph.cc
+++ b/cyclegraph.cc
@@ -319,6 +319,16 @@ unsigned int CycleNode::getNumEdges() const
 	return edges.size();
 }
 
+CycleNode * CycleNode::getBackEdge(unsigned int i) const
+{
+	return back_edges[i];
+}
+
+unsigned int CycleNode::getNumBackEdges() const
+{
+	return back_edges.size();
+}
+
 /**
  * Adds an edge from this CycleNode to another CycleNode.
  * @param node The node to which we add a directed edge
@@ -329,6 +339,7 @@ bool CycleNode::addEdge(CycleNode *node)
 		if (edges[i] == node)
 			return false;
 	edges.push_back(node);
+	node->back_edges.push_back(this);
 	return true;
 }
 
diff --git a/cyclegraph.h b/cyclegraph.h
index 6b3d93e..f2f3032 100644
--- a/cyclegraph.h
+++ b/cyclegraph.h
@@ -70,6 +70,8 @@ class CycleNode {
 	bool addEdge(CycleNode *node);
 	CycleNode * getEdge(unsigned int i) const;
 	unsigned int getNumEdges() const;
+	CycleNode * getBackEdge(unsigned int i) const;
+	unsigned int getNumBackEdges() const;
 	bool setRMW(CycleNode *);
 	CycleNode * getRMW() const;
 	const ModelAction * getAction() const { return action; }
@@ -89,6 +91,9 @@ class CycleNode {
 	/** @brief The edges leading out from this node */
 	std::vector< CycleNode *, SnapshotAlloc<CycleNode *> > edges;
 
+	/** @brief The edges leading into this node */
+	std::vector< CycleNode *, SnapshotAlloc<CycleNode *> > back_edges;
+
 	/** Pointer to a RMW node that reads from this node, or NULL, if none
 	 * exists */
 	CycleNode *hasRMW;
-- 
2.34.1