| Example Program Transitive Closure Transitive closure code example File "graph_algo_path_transitive.cpp" 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;
Graph creation: 5 directed edges (3,0), (1,2), ...
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;
Out-parameter: Closure matrix
16 | String<bool> closure;
Transitive-Closure
17 | transitiveClosure(g,closure);
Console output
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 | }
See Graph, transitiveClosure SeqAn - Sequence Analysis Library - www.seqan.de

Page built @2012/03/14 16:34:46