mercredi 1 novembre 2017

Make a subgraph of a boost graph by removing leaves

I have a BGL graph, of type vecS. I want to make a new graph of it by removing leaves. I need it mainly for visulization, becasue there are a lot of leaves that I don't need to visualize. According to this post c++ remove vertex from a graph and BGL page removing vertices from a vecS adjacencylist is not safe. So what is the solution in my case that I have a vecS graph? How I may make a new graph without leaves.

    /// vertex properties
struct VertexData
{
    std::string label;
    int num;
    bool is_leaf=false;
};

/// edges properties
struct EdgeData
{
    std::string edge_name;
    double edge_confidence;
};

/// define the boost-graph
typedef boost::adjacency_list<boost::vecS, boost::vecS,
        boost::bidirectionalS,
        boost::property<boost::edge_index_t , size_t , VertexData>,
        boost::property<boost::edge_weight_t, double, EdgeData> > Graph;

Thanks for your answer.

Aucun commentaire:

Enregistrer un commentaire