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 7726211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:09:28+00:00 2026-06-01T05:09:28+00:00

I am struggling to dump a graph in a stream, where said graph is

  • 0

I am struggling to dump a graph in a stream, where said graph is a constified version of a boost::subgraph.

I tried providing a property writer but basically it fails, because it seems to require a method boost::get(PropertyWriter, VertexDescriptor). Using the same methodology where the graph is not a subgraph works as expected.

As found here, I got to use a boost::dynamic_properties (see code below), but it fails when my graph is not writable (whereas the documentation indicates that the graph is taken as a constified reference).

Here is a simple example that I cannot get to work:

#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graphviz.hpp>
#include <boost/graph/subgraph.hpp>

struct VertexProperties
{
  std::string name;
};

int main()
{
  typedef boost::subgraph<
    boost::adjacency_list<
      boost::vecS, boost::vecS,
      boost::directedS,
      boost::property<boost::vertex_index_t, std::size_t, VertexProperties>,
      boost::property<boost::edge_index_t, std::size_t> > > Graph;

  Graph const g;

  boost::dynamic_properties dp;
  dp.property("name", boost::get(&VertexProperties::name, g));
  dp.property("node_id", boost::get(boost::vertex_index, g));
  boost::write_graphviz_dp(std::cout, g, dp);
}

Any hint is welcome! Thanks a lot,


EDIT

I forgot to mention what “failure” means in my case; here is the error when I try to compile:

error: passing ‘const std::basic_string’ as ‘this’ argument of ‘std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::operator=(const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits, _Alloc = std::allocator, std::basic_string<_CharT, _Traits, _Alloc> = std::basic_string]’ discards qualifiers [-fpermissive]

  • 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-06-01T05:09:29+00:00Added an answer on June 1, 2026 at 5:09 am

    As suggested, I reported this to be a bug in Boost.Graph (see the ticket).

    As a workaround, it appears that the underlying graph can be used instead of the subgraph, by accessing the member m_graph which is in the public scope.

    Here is how I got to workaround the problem, with a property writer:

    struct VertexProperties
    {
      std::string name;
    };
    
    template <typename Graph> struct prop_writer
    {
      prop_writer(Graph const& g): g_(g) {}
    
      template <typename Vertex> void operator()(std::ostream& out, Vertex v) const
      {
        out << g_[v].name;
      }
    
      Graph const& g_;
    }
    
    typedef boost::subgraph<
      boost::adjacency_list<
        boost::vecS, boost::vecS,
        boost::directedS,
        boost::property<boost::vertex_index_t, std::size_t, VertexProperties>,
        boost::property<boost::edge_index_t, std::size_t> > > Graph;
    
    Graph const g;
    
    // Note the use of g.m_graph here.
    boost::write_graphviz(std::cout, g.m_graph, prop_writer<Graph>(g));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Struggling with this tournament fixtures algorithm. The code is working perfectly but I need
Im struggling to create a functionality which keeps on incrementing css property of an
I'm struggling to find the right terminology here, but if you have jQuery object...
I'm struggling a bit with my simple console-dump-program. I connect to AD using DirectoryEntry
Struggling with styling the mouse over for a button ... I have managed to
Still struggling to understand what best practices are with respect to macros. I'm attempting
Iam struggling with NHibernate and its lazyload. I have a structure which I simplified
Been struggling with this simple selector problem a couple of hours now and must
im struggling with syntax here: hopefully this question is v simple, im just miising
been struggling with an issue now for a day or two. I have an

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.