diff options
author | Derick Huth <derickhuth@gmail.com> | 2015-09-24 12:22:41 -0600 |
---|---|---|
committer | Derick Huth <derickhuth@gmail.com> | 2015-09-24 12:22:41 -0600 |
commit | 4631ad76927d433da5d55c3c373a1dfd0f74c9d4 (patch) | |
tree | f8dcba88576ec95e403f0c14efd80e970f30a260 /graph-test.cc | |
parent | 6eb2b89896da66a77d0dcdf2d72b98c122826949 (diff) | |
parent | 0cff3f9a3c4ccd434900162ebef4bd814850f481 (diff) | |
download | chill-4631ad76927d433da5d55c3c373a1dfd0f74c9d4.tar.gz chill-4631ad76927d433da5d55c3c373a1dfd0f74c9d4.tar.bz2 chill-4631ad76927d433da5d55c3c373a1dfd0f74c9d4.zip |
Merge pull request #7 from dhuth/master
V0.2.1
Diffstat (limited to 'graph-test.cc')
-rw-r--r-- | graph-test.cc | 148 |
1 files changed, 0 insertions, 148 deletions
diff --git a/graph-test.cc b/graph-test.cc deleted file mode 100644 index 3cdcbee..0000000 --- a/graph-test.cc +++ /dev/null @@ -1,148 +0,0 @@ -#include "graph.hh" - -using std::cout; -using std::endl; -template<typename T> -struct A { -}; - -template struct Graph<Empty,Empty>; - -int main() { - Graph<> g; - - for (int i = 0; i < 8; i++) - g.insert(); - - std::vector<Empty> t; - t.push_back(Empty()); - t.push_back(Empty()); - - g.connect(0,1); - g.connect(1,4); - g.connect(4,0); - g.connect(4,5); - g.connect(1,5); - g.connect(1,2); - g.connect(2,3); - g.connect(3,2); - g.connect(2,6); - g.connect(5,6); - g.connect(6,5); - g.connect(6,7); - g.connect(3,7); - g.connect(7,7,t); - - g.insert(); - g.insert(); - g.connect(9,8); - g.connect(8,0); - - cout << "Graph #1:" << endl; - cout << g; - - std::vector<std::set<int> > r = g.topoSort(); - - cout << "topological order: "; - int num_scc = 0; - for (int i = 0; i < r.size(); i++) { - if (i != 0) - cout << ' '; - if (r[i].size() > 1) { - cout << '('; - num_scc++; - } - for (std::set<int>::iterator j = r[i].begin(); j != r[i].end(); j++) { - if (j != r[i].begin()) - cout << ' '; - cout << (*j+1); - } - if (r[i].size() > 1) - cout << ')'; - } - cout << endl; - cout << "total number of SCC: " << num_scc << endl; - - Graph<> g2; - - for (int i = 0; i < 6; i++) - g2.insert(); - - g2.connect(0,1); - g2.connect(0,2); - g2.connect(3,4); - g2.connect(3,5); - g2.connect(3,2); - g2.connect(5,0); - - cout << endl << "Graph #2:" << endl; - cout << g2; - - std::vector<std::set<int> > r2 = g2.packed_topoSort(); - - cout << "packed topological order: "; - for (int i = 0; i < r2.size(); i++) { - if (i != 0) - cout << ' '; - if (r2[i].size() > 1) - cout << '('; - for (std::set<int>::iterator j = r2[i].begin(); j != r2[i].end(); j++) { - if (j != r2[i].begin()) - cout << ' '; - cout << (*j+1); - } - if (r2[i].size() > 1) - cout << ')'; - } - cout << endl; - - Graph<> g3; - - for (int i = 0; i < 6; i++) - g3.insert(); - - g3.connect(5,2); - g3.connect(5,3); - g3.connect(5,4); - g3.connect(3,1); - g3.connect(1,0); - - cout << endl << "Graph #3:" << endl; - cout << g3; - - std::vector<std::set<int> > r3 = g3.topoSort(); - - cout << "topological order: "; - for (int i = 0; i < r3.size(); i++) { - if (i != 0) - cout << ' '; - if (r3[i].size() > 1) - cout << '('; - for (std::set<int>::iterator j = r3[i].begin(); j != r3[i].end(); j++) { - if (j != r3[i].begin()) - cout << ' '; - cout << (*j+1); - } - if (r3[i].size() > 1) - cout << ')'; - } - cout << endl; - - r3 = g3.packed_topoSort(); - - cout << "packed topological order: "; - for (int i = 0; i < r3.size(); i++) { - if (i != 0) - cout << ' '; - if (r3[i].size() > 1) - cout << '('; - for (std::set<int>::iterator j = r3[i].begin(); j != r3[i].end(); j++) { - if (j != r3[i].begin()) - cout << ' '; - cout << (*j+1); - } - if (r3[i].size() > 1) - cout << ')'; - } - cout << endl; -} |