[ create a new paste ] login | about

Link: http://codepad.org/ThR2i2FI    [ raw code | fork | 1 comment ]

C++, pasted on Jun 7:
#include <iostream>
#include <string>

#include <boost/graph/undirected_graph.hpp>

struct VertexProperty {
    std::string name;
};

typedef boost::adjacency_list<     boost::listS,             // out-edges stored in a std::list
                       boost::listS,             // vertex set stored here
                       boost::undirectedS,    // bidirectional graph.
                       VertexProperty,              // vertex properties
                       boost::no_property,       // edge properties
                       boost::no_property,       // graph properties
                       boost::listS              // edge storage
                       > Graph;


int main(int,char*[])
{
  // Create a graph object
  Graph g(3);

  // Assign "Vertex0" as the name of the 0th vertex
  typedef boost::graph_traits<Graph>::vertex_iterator VItr;
  VItr vitr, vend;
  boost::tie( vitr, vend) = boost::vertices(g);
  g[*vitr].name = "Vertex0";

  for ( ; vitr != vend ; ++vitr )
    std::cout << g[*vitr].name << "\n";
  return 0;
}


Create a new paste based on this one


Comments:
posted by raksha on Jan 7
Hey! In my code, line 29 gives an error. Any idea why?

Thank you so much!
reply