C++ Boost图形库:防止DFS访问未连接的节点

C++ Boost图形库:防止DFS访问未连接的节点,c++,boost,boost-graph,C++,Boost,Boost Graph,我有一个双向图。某些顶点未连接。我使用boost::depth\u first\u搜索遍历顶点。我还提供了起始源节点。我看到未连接的顶点也会在连接节点完成后进行处理。如何防止访问此类节点?事实上,我如何告诉DFS只访问那些可以从源节点访问到的节点,而不访问任何其他节点 我有以下代码: /// Define vertex properties. struct NodeProperty { unsigned id; /// Id. unsigned

我有一个双向图。某些顶点未连接。我使用boost::depth\u first\u搜索遍历顶点。我还提供了起始源节点。我看到未连接的顶点也会在连接节点完成后进行处理。如何防止访问此类节点?事实上,我如何告诉DFS只访问那些可以从源节点访问到的节点,而不访问任何其他节点

我有以下代码:

/// Define vertex properties.
struct NodeProperty
{
    unsigned     id;              /// Id.
    unsigned     kind;            /// Kind.
    unsigned     depth;           /// Depth.
    unsigned     layer_color;     /// Layer color.
    unsigned     signal_color;    /// Signal color.
    unsigned     sch_color;       /// Sch color.
    CBoundingBox bounds;          /// Bounds of polygon.

    NodeProperty()
        : id(0), kind(0), depth(0), layer_color(0), signal_color(0), sch_color(0), bounds(0,0,0,0)
    {
        ;
    }
};
/// Define net topology graph.
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, NodeProperty> Graph;

class receiver_visitor : public boost::default_dfs_visitor
{
    public:
        receiver_visitor(std::vector<Vertex>& r)
            : res(r)
        {
            ;
        }

        void discover_vertex(Vertex v, Graph const& g) const
        {
            std::cout << "Visit: " << v << std::endl;
            if (g[v].sch_color) {
                res.push_back(g[v].sch_color);
            }
        }

        std::vector<Vertex>& res;
 };

 std::vector<std::size_t>
 NetTopology::getReceivers(std::size_t src) const
 {
     std::vector<Vertex> r;
     receiver_visitor vis(r);
     boost::depth_first_search(data_->g, boost::visitor(vis).root_vertex(src));

     return r;
}
///定义顶点属性。
结构节点属性
{
未签名的id;///id。
未签名的种类;///种类。
无符号深度;///深度。
未签名的图层颜色;///图层颜色。
无符号信号颜色;///信号颜色。
无符号sch_color;///sch color。
CBoundingBox边界;///多边形的边界。
节点属性()
:id(0)、种类(0)、深度(0)、图层颜色(0)、信号颜色(0)、颜色(0)、边界(0,0,0,0)
{
;
}
};
///定义网络拓扑图。
typedef boost::邻接列表图;
类接收者\u访问者:public boost::default\u dfs\u访问者
{
公众:
接受者和来访者(标准::向量和r)
:res(r)
{
;
}
void discover_顶点(顶点v,图常数&g)常数
{

std::cout您想使用
深度优先访问
,而不是
深度优先搜索

我看到深度优先访问需要一些颜色映射属性。如何提供(默认)一个?