Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 705205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:01:38+00:00 2026-05-14T04:01:38+00:00

How should I modify the bundled properties of a vertex from inside a visitor?

  • 0

How should I modify the bundled properties of a vertex from inside a visitor?

I would like to use the simple method of sub-scripting the graph, but the graph parameter passed into the visitor is const, so compiler disallows changes.

I can store a reference to the graph in the visitor, but this seems weird.

/**

  A visitor which identifies vertices as leafs or trees

*/
class bfs_vis_leaf_finder:public default_bfs_visitor {

public:
    /**

    Constructor

    @param[in] total reference to int variable to store total number of leaves
    @param[in] g reference to graph ( used to modify bundled properties )

    */
    bfs_vis_leaf_finder( int& total, graph_t& g ) :
      myTotal( total ), myGraph( g )
      {
          myTotal = 0;
      }

    /**

    Called when the search finds a new vertex

    If the vertex has no children, it is a leaf and the total leaf count is incremented

    */
    template <typename Vertex, typename Graph>
    void discover_vertex( Vertex u, Graph& g)
    {
        if( out_edges( u, g ).first == out_edges( u, g ).second ) {
            myTotal++;
            //g[u].myLevel = s3d::cV::leaf;
            myGraph[u].myLevel = s3d::cV::leaf;
        } else {
            //g[u].myLevel = s3d::cV::tree;
            myGraph[u].myLevel = s3d::cV::tree;
        }
    }

    int& myTotal;
    graph_t& myGraph;
};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:01:39+00:00Added an answer on May 14, 2026 at 4:01 am

    Your solution is right.

    To decouple the graph type from the visitor you could pass only the interesting property map to the visitor constructor and access its elements using boost::get(property, u) = s3d::cV::leaf;. This way you can pass any type-compatible vertex property to the visitor (the visitor will be more general and not sensible to name changes in the graph type).

    The type for the property map will be a template type-name for the visitor class and will be something like:

    typedef property_map<graph_t, s3d_cv3_leaf_t your_vertex_info::*>::type your_property_map;
    

    See here for a complete dissertation about bundled properties.

    HTH

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to count the access to a resource, but HTTP GET should
My Chrome Extension should modify a DOM element before the DOM is fully constructed,
should be simple right? but have not found any anwsers :
Should functions that act on and object, say to fill it out from xml,
Should a highly dynamic website that is constantly generating new pages use a sitemap
I am writing an Eclipse plug-in that should modify the source code in the
In android, I'm trying to create an simple activity allowing me to modify a
I am using GWT (and GWT-Plateform) and GAE, and I would like to have
Working with WCF how it should modify this DataContract or code: <DataContract()> Public Class
could any body explain what I should modify, how after hiding the image, still

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.