Giriş
Şu satırları dahil
ederiz.
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/labeled_graph.hpp>
Açıklaması
şöyle
This file implements a utility for creating mappings from arbitrary identifiers to the vertices of a graph.
Yani id -> vertex_descriptor arasında ilişki tutmak gerekiyorsa
kullanılır.
Tanımlama
Örnek 1
Şöyle
yaparız.
typedef boost::labeled_graph<
boost::adjacency_list<>,
std::string
> Graph;
Örnek 2
Şöyle
yaparız.
typedef boost::adjacency_list<listS, vecS, undirectedS> AdjList;
typedef boost::labeled_graph<AdjList, size_t, mapS> Graph;
Constructor
Şöyle
yaparız.
Graph g;
Doldurmak
Aynı id'ye sahip iki tane vertex eklenemez. Şöyle
yaparız. Bunu denersek add_vertex bir öne eklenmiş olan nesnesi döndürür.
while (std::getline(infile, line)) {
std::istringstream iss(line);
size_t vid1, vid2;
if (iss >> vid1 >> vid2) {
auto v1 = add_vertex(vid1, g);
auto v2 = add_vertex(vid2, g);
add_edge(v1, v2, g);
}
}