5 Nisan 2017 Çarşamba

graph in_edge_at metodu

Giriş
İmzası şöyle
// Get the out-edge associated with vertex and in_edge_index
Traits::edge_descriptor
in_edge_at(Traits::vertex_descriptor vertex,
           Traits::degree_size_type in_edge_index,
           const Graph& graph);
Örnek
Elimizde şöyle 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;
Grid'i ilklendirelim
Grid grid({ { 4, 4, 4 } }, false);
Şöyle yaparız.
void print_in_edges(vertex_descriptor vd, Grid const& grid) {
    for (Traits::degree_size_type ei = 0; ei < in_degree(vd, grid); ++ei) {
        auto ed_left = in_edge_at(vd, ei, grid);
        std::cout << "Detected in edge: " << ed_left.first << " -> "
                  << ed_left.second << "\n";
    }
}


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

Hiç yorum yok:

Yorum Gönder