using namespace std;
typedef boost::property<boost::edge_weight_t, double> EdgeWeightProperty;
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, boost::no_property, EdgeWeightProperty, boost::hash_setS> Graph;
int main()
{
ifstream arquivo_in ("shrd150-3.dis");
ofstream arquivo_out ("matriz.txt");
int numero, j, i;
Graph g(15);
EdgeWeightProperty e;
enum { A, B, C, D, E, F, G, H, I, J, K, L, M, N, O };
const char name[] = "ABCDEFGHIJKLMNO";
boost::property_map<Graph, vertex_index_t>::type
vertex_id = get(vertex_index, g);
boost::property_map<Graph, edge_weight_t>::type
trans_delay = get(edge_weight, g);
j = 1;
for(i = 0; i < 15; ++i)
Graph::vertex_descriptor i = boost::add_vertex(g);
for(j = 1; !arquivo_in.eof(); ++j)
{
for(i = 0; i < j; ++i)
{
arquivo_in >> numero;
e = numero;
boost::add_edge(i, j, e, g);
}
}
我不确定是否存储为 hash_set,但我会尝试一种检查冲突的方法。再次感谢!