Domanda

Ho creato una struttura, e lo ha utilizzato come parametro di modello per adjacency_list. Tuttavia, quando cerco di add_edge (vertex1, vertex2, proprietà, grafico), il compilatore si lamenta "non corrispondente chiamata di funzione". Chiunque può vedere dove ho sbagliato andato qui?

#include <iostream>
#include <boost/graph/adjacency_list.hpp>

// Create a struct to hold several properties
struct MyProperty
{
  int MyIntProperty;
};

// Define the type of the graph
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, MyProperty> Graph;

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

  // Add an edge between node 0 and node 1 with weight 1.2
  MyProperty p;
  p.MyIntProperty = 5;
  std::cout << p.MyIntProperty << std::endl;
  add_edge(0, 1, p, g);

  return 0;
}

Grazie,

David

È stato utile?

Soluzione

In this code, MyProperty is declared as a vertex property rather than an edge property, and so it doesn't make sense to insert edges with that property. Try adding boost::no_property before MyProperty in your adjacency_list typedef.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top