Iam пытается сделать программу добычи график с помощью Boost, поэтому я начал по структуре графа, вот код тха я делаю:C++ библиотека BOOST и входящее в комплект свойства
#include <iostream>
#include <boost/graph/adjacency_list.hpp>
using namespace std;
using namespace boost;
//vertex
struct VertexProperties
{
int id;
int label;
VertexProperties()= default;
VertexProperties(unsigned i, unsigned l) : id(i), label(l) {}
};
//edge
struct EdgeProperties
{
unsigned id;
unsigned label;
EdgeProperties()= default;
EdgeProperties(unsigned i, unsigned l) : id(i), label(l) {}
};
//Graph
struct GraphProperties
{
unsigned id;
unsigned label;
GraphProperties()= default;
GraphProperties(unsigned i, unsigned l) : id(i), label(l) {}
};
//adjency list
typedef boost::adjacency_list<
boost::vecS, boost::vecS, boost::directedS,
VertexProperties,
EdgeProperties,
GraphProperties
> Graph;
//iterators
typedef boost::graph_traits<Graph>::vertex_descriptor vertex_t;
typedef boost::graph_traits<Graph>::edge_descriptor edge_t;
/***********************************************/
int main()
{
Graph g;
vertex_t v1 = boost::add_vertex(VertexProperties(1,10),g);
vertex_t v2 = boost::add_vertex(VertexProperties(2,20),g);
//edge_t e1= boost::add_edge(EdgeProperties(3,55),g);
std::cout << "Vertice: " <<num_vertices(g) << std::endl;
std::cout << "edges: " <<num_edges(g) << std::endl;
return 0;
}
есть проблема в этой строке:
edge_t e1= boost::add_edge(EdgeProperties(3,55),g);
Как я могу создать этот край? PS: скажите, является ли код правильным (я имею в виду концепцию pont vue)
Спасибо jjaguayo Это было идеально. проверьте этот пожалуйста. https://stackoverflow.com/questions/28780137/create-graphs-from-a-file-using-boost-library –