Boost/BGL/VertexProperties

From ProgrammingExamples
< Boost‎ | BGL
Revision as of 11:02, 27 January 2011 by Daviddoria (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

VertexProperties.cpp

#include <iostream>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
 
typedef boost::property<boost::vertex_property_tag, double> VertexProperty;
 
/*
adjacency_list<OutEdgeList, VertexList, Directed,
               VertexProperties, EdgeProperties,
               GraphProperties, EdgeList>
*/
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, VertexProperty> Graph;
 
int main(int,char*[])
{
  // Create a graph object
  Graph g(3);
 
  boost::property_map<Graph, VertexProperty>::type value = get(VertexProperty(), g);
 
  boost::put(value, 0, 1.2);
  boost::put(value, 1, 2.3);
  boost::put(value, 2, 3.4);
 
 
  return 0;
}

CMakeLists.txt

cmake_minimum_required(VERSION 2.6)
 
Project(VertexProperties)
 
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(VertexProperties VertexProperties.cpp)