codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <iostream> #include <boost/graph/iteration_macros.hpp> #include <boost/graph/adjacency_list.hpp> #include <boost/graph/compressed_sparse_row_graph.hpp> using namespace std; using namespace boost; int main(int argc, char* argv[]) { typedef pair<unsigned int, unsigned int> E; E the_edges[] = { E(0, 1), E(0, 2), E(0, 3), E(1, 0), E(1, 3), E(1, 5), E(2, 0), E(2, 5), E(3, 1), E(3, 4), E(4, 1), E(5, 0), E(5, 2) }; list<E> v(&the_edges[0], &the_edges[0] + sizeof(the_edges)/sizeof(E)); adjacency_list<vecS, vecS, bidirectionalS> G(v.begin(), v.end(), 6); compressed_sparse_row_graph<bidirectionalS> B(G); typedef adjacency_list<vecS, vecS, bidirectionalS> adjGraph; BGL_FORALL_VERTICES(v, G, adjGraph) { int outDegree = out_degree(v, G); int inDegree = in_degree(v, G); cout << v << " " << outDegree << " " << inDegree << endl; } BGL_FORALL_VERTICES(v, B, compressed_sparse_row_graph<bidirectionalS>) { int outDegree = out_degree(v, B); int inDegree = in_degree(v, B); cout << v << " " << outDegree << " " << inDegree << endl; } }
Private
[
?
]
Run code
Submit