Difference between revisions of "Boost/BGL/RemoveEdge"
From ProgrammingExamples
Daviddoria (Talk | contribs) (Created page with '==RemoveEdge.cpp== <source lang="cpp"> #include <iostream> #include <boost/graph/graph_traits.hpp> #include <boost/graph/undirected_graph.hpp> typedef boost::undirected_graph<bo…') |
(No difference)
|
Revision as of 15:11, 11 June 2011
RemoveEdge.cpp
#include <iostream> #include <boost/graph/graph_traits.hpp> #include <boost/graph/undirected_graph.hpp> typedef boost::undirected_graph<boost::no_property> Graph; int main(int,char*[]) { // Create a graph object Graph g; // Add vertices Graph::vertex_descriptor v0 = g.add_vertex(); Graph::vertex_descriptor v1 = g.add_vertex(); Graph::vertex_descriptor v2 = g.add_vertex(); // Add edges // error: conversion from ‘std::pair<boost::detail::edge_desc_impl<boost::undirected_tag, void*>, bool>’ to non-scalar type ‘boost::undirected_graph<boost::no_property>::edge_descriptor’ requested Graph::edge_descriptor e0 = g.add_edge(v0, v1); Graph::edge_descriptor e1 = g.add_edge(v1, v2); std::cout << "There are " << g.num_edges() << " edges." << std::endl; g.remove_edge(e0); std::cout << "There are " << g.num_edges() << " edges." << std::endl; return 0; }
CMakeLists.txt
cmake_minimum_required(VERSION 2.6) Project(RemoveEdge) set(Boost_USE_MULTITHREADED ON) FIND_PACKAGE(Boost 1.38 COMPONENTS required) INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${Boost_INCLUDE_DIRS}) LINK_DIRECTORIES(${LINK_DIRECTORIES} ${Boost_LIBRARY_DIRS}) ADD_EXECUTABLE(RemoveEdge RemoveEdge.cpp)