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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:29:56+00:00 2026-05-28T03:29:56+00:00

I am confused about how to actually create a Graph using the boost library,

  • 0

I am confused about how to actually create a Graph using the boost library, I have looked at the example code and there are no comments explaining what it does.

How do you make a graph, and add vertices and edges as you go?

  • 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-28T03:29:56+00:00Added an answer on May 28, 2026 at 3:29 am

    Here’s a simple example, using an adjacency list and executing a topological sort:

    #include <iostream>
    #include <deque>
    #include <iterator>
    
    #include "boost/graph/adjacency_list.hpp"
    #include "boost/graph/topological_sort.hpp"
    
    int main()
    {
        // Create a n adjacency list, add some vertices.
        boost::adjacency_list<> g(num tasks);
        boost::add_vertex(0, g);
        boost::add_vertex(1, g);
        boost::add_vertex(2, g);
        boost::add_vertex(3, g);
        boost::add_vertex(4, g);
        boost::add_vertex(5, g);
        boost::add_vertex(6, g);
    
        // Add edges between vertices.
        boost::add_edge(0, 3, g);
        boost::add_edge(1, 3, g);
        boost::add_edge(1, 4, g);
        boost::add_edge(2, 1, g);
        boost::add_edge(3, 5, g);
        boost::add_edge(4, 6, g);
        boost::add_edge(5, 6, g);
    
        // Perform a topological sort.
        std::deque<int> topo_order;
        boost::topological_sort(g, std::front_inserter(topo_order));
    
        // Print the results.
        for(std::deque<int>::const_iterator i = topo_order.begin();
            i != topo_order.end();
            ++i)
        {
            cout << tasks[v] << endl;
        }
    
        return 0;
    }
    

    I agree that the boost::graph documentation can be intimidating, but it’s worth having a look.

    I can’t recall if the contents of the printed book is the same, I suspect it’s a bit easier on the eyes. I actually learnt to use boost:graph from the book. The learning curve can feel pretty steep though. The book I refer to and reviews can be found here.

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

Sidebar

Related Questions

I'm a bit confused about when using the IRepository pattern, when actually to load
I am confused about the @protocol----@end in iphone, what actually is it meant for.
I am a bit confused about socket programming in C. You create a socket,
I'm a little confused about how the standard library will behave now that Python
I am a little confused about the various methods' implementations. Actually, I was Learning
Does Microsoft Workflow Foundation keep all the workflow inside? Actually I am confused about
I'm a little confused about clean-up order when you're using PThreads with regard to
I'm currently using commons-net library for FTP client in my app. I have to
Actually i'm pretty confused about this terms and how they relate to each other.
I am kind of confused about how the below code works. In my head

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.