Boost logo

Boost Users :

From: Eric Fowler (eric.fowler_at_[hidden])
Date: 2008-01-10 01:36:18


I have been fiddling with this library off and on for some time ... now am
getting this error:

/home/eric/boostplay/g0/src/g0.cpp:55: error: no matching function for call
to 'add_vertex(Graph (&)())'
/home/eric/boostplay/g0/src/g0.cpp:56: error: no matching function for call
to 'add_edge(Vertex&, Vertex&, Graph (&)())'

on this code:

<boost-users_at_[hidden]>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <iostream>
#include <cstdlib>

#include <boost/config.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/tuple/tuple.hpp>

using namespace std;
using namespace boost;

typedef adjacency_list<vecS, vecS, undirectedS> Graph;
typedef graph_traits<Graph>::vertex_descriptor Vertex;
typedef graph_traits<Graph>::edge_descriptor Edge;

int main(int argc, char *argv[])
{
  Graph g();

  Vertex v = 0;
  for(int iv = 0; iv < 10; ++iv)
      for(int iu = 0; iu < 5; ++iu)
      {
          Vertex u;
          Edge e;
          bool inserted;

          u = v;
          tie(v, inserted) = add_vertex(g);
          tie(e, inserted) = add_edge(u, v, g);
          if(inserted)
              cout << "Inserted edge " << e << " from vertex " << u << " to
vertex " << v << endl;
          else
              cout << "Failed to insert edge " << e << " from vertex " << u
<< " to vertex " << v << endl;

      }

  return EXIT_SUCCESS;
}

There was a thread on this a while back which suggested casting the call:
tie(e, inserted) = add_edge(u, v, g);

to

tie(e, inserted) = add_edge(std::size_t(u), std::size_t(v), g);

but that did not work.

Notice my graph has no properties .. usually I don't make 'em that way, but
that should be fine, right?

Thanks very much,

Eric



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net