5 Nisan 2017 Çarşamba

graph out_edge_at metodu

Giriş
İmzası şöyle
// Get the out-edge associated with vertex and out_edge_index
Traits::edge_descriptor
out_edge_at(Traits::vertex_descriptor vertex,
            Traits::degree_size_type out_edge_index,
            const Graph& graph);
Örnek
Elimizde bir grid olsun
using Grid = boost::grid_graph<3>;
using Traits = boost::graph_traits<Grid>;
using vertex_descriptor = Grid::vertex_descriptor;
using edge_descriptor = Grid::edge_descriptor;
Bu grid'i ilklendirelim.
Grid grid({ { 4, 4, 4 } }, false);
Şöyle yaparız.
void print_out_edges(vertex_descriptor vd, Grid const& grid) {
  for (Traits::degree_size_type ei = 0; ei < out_degree(vd, grid); ++ei) {
    auto ed_left = out_edge_at(vd, ei, grid);
    std::cout << "Detected out edge: " << ed_left.first << " -> "
              << ed_left.second << "\n";
    }
}

print_out_edges({{ 2, 2, 2 } }, grid);


Hiç yorum yok:

Yorum Gönder