diff options
author | Andrew Reynolds <andrew.j.reynolds@gmail.com> | 2011-04-28 23:32:16 +0000 |
---|---|---|
committer | Andrew Reynolds <andrew.j.reynolds@gmail.com> | 2011-04-28 23:32:16 +0000 |
commit | 40449557777db2d1170cb86274f83b431b5fef04 (patch) | |
tree | 92fbf29e66bcce618cd61d1d88494fc8ed6c3d5b /src/util/trans_closure.cpp | |
parent | c21ca8353370eb44aa6318e6ee4bffee64197fd8 (diff) |
more fixes/improvements to datatypes theory and transitive closure
Diffstat (limited to 'src/util/trans_closure.cpp')
-rw-r--r-- | src/util/trans_closure.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/util/trans_closure.cpp b/src/util/trans_closure.cpp index a31dc3378..43c8735ad 100644 --- a/src/util/trans_closure.cpp +++ b/src/util/trans_closure.cpp @@ -74,6 +74,14 @@ bool TransitiveClosure::addEdge(unsigned i, unsigned j) return false; } +bool TransitiveClosure::isConnected(unsigned i, unsigned j) +{ + if( i>=adjMatrix.size() || j>adjMatrix.size() ){ + return false; + }else{ + return adjMatrix[i] != NULL && adjMatrix[i]->read(j); + } +} void TransitiveClosure::debugPrintMatrix() { @@ -89,16 +97,24 @@ void TransitiveClosure::debugPrintMatrix() } } -unsigned TransitiveClosureNode::d_counter = 0; - unsigned TransitiveClosureNode::getId( Node i ){ - std::map< Node, unsigned >::iterator it = nodeMap.find( i ); + context::CDMap< Node, unsigned, NodeHashFunction >::iterator it = nodeMap.find( i ); if( it==nodeMap.end() ){ - nodeMap[i] = d_counter; - d_counter++; - return d_counter-1; + unsigned c = d_counter.get(); + nodeMap[i] = c; + d_counter.set( c + 1 ); + return c; + } + return (*it).second; +} + +void TransitiveClosureNode::debugPrint(){ + for( int i=0; i<(int)currEdges.size(); i++ ){ + cout << "currEdges[ " << i << " ] = " + << currEdges[i].first << " -> " << currEdges[i].second; + //<< "(" << getId( currEdges[i].first ) << " -> " << getId( currEdges[i].second ) << ")"; + cout << std::endl; } - return it->second; } |