Created
September 11, 2015 06:22
-
-
Save Zia-/300c9d1aff476953c045 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <boost/graph/adjacency_list.hpp> | |
template <typename UndirectedGraph> | |
void undirected_graph_demo1(){ | |
/*The value of V is not imp, we need it just to pass into constructor at "UndirectedGraph undigraph(V);" to initialize it. | |
Later on we can add as many vertices as we want*/ | |
const int V = 0; | |
UndirectedGraph undigraph(V); | |
typename boost::graph_traits<UndirectedGraph>::vertex_descriptor zero, one, two; | |
typename boost::graph_traits<UndirectedGraph>::out_edge_iterator out, out_end; | |
typename boost::graph_traits<UndirectedGraph>::in_edge_iterator in, in_end; | |
zero = vertex(0, undigraph); | |
one = vertex(1, undigraph); | |
two = vertex(2, undigraph); | |
add_edge(zero, one, undigraph); | |
add_edge(one, two, undigraph); | |
add_edge(zero, two, undigraph); | |
for (tie(out, out_end) = out_edges(zero, undigraph); out != out_end; ++out){ | |
std::cout<< *out; | |
} | |
std::cout<< std::endl; | |
for (tie(in, in_end) = in_edges(zero, undigraph); in != in_end; ++in){ | |
std::cout<< *in; | |
} | |
} | |
int main(){ | |
typedef boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS, | |
boost::no_property, boost::no_property> UndirectedGraph; | |
undirected_graph_demo1<UndirectedGraph>(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment