| Example Program Transitive Closure Transitive closure code example A tutorial about the transitive closure algorithm.
1 | #include <iostream>
| 2 | #include <seqan/graph_algorithms.h>
| 3 |
| 4 | using namespace seqan;
| 5 |
| 6 | int main() {
| 7 | typedef Graph<Directed<> > TGraph;
| 8 | typedef VertexDescriptor<TGraph>::Type TVertexDescriptor;
| 9 | typedef EdgeDescriptor<TGraph>::Type TEdgeDescriptor;
| 10 | typedef Size<TGraph>::Type TSize;
|
11 | TSize numEdges = 5;
| 12 | TVertexDescriptor edges[] = {3,0, 1,2, 2,1, 1,3, 3,2};
| 13 | TGraph g;
| 14 | addEdges(g, edges, numEdges);
| 15 | std::cout << g << std::endl;
|
17 | transitiveClosure(g,closure);
|
18 | TSize len = (TSize) std::sqrt((double) length(closure));
| 19 | for (TSize row=0;row < len;++row) {
| 20 | for (TSize col=0;col < len;++col) {
| 21 | std::cout << getValue(closure, row*len+col) << ",";
| 22 | }
| 23 | std::cout << std::endl;
| 24 | }
| 25 | return 0;
| 26 | }
|
|