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

  • Home
  • SEARCH
  • 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 8702279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:36:49+00:00 2026-06-13T02:36:49+00:00

I have a small problem where I need to find all possible paths given

  • 0

I have a small problem where I need to find all possible paths given a set of numbers. For example, lets say we have numbers 1, 2 and 3. I need to find all the possible combinations. The result for this simple case is:
path_1 = 1
path_2 = 2
path_3 = 3
path_4 = 1, 2
path_5 = 1, 3
path_6 = 2, 3
path_7 = 1, 2, 3

It is simple to see that the number of paths is (2^n)-1, so for 3 elements, it is 7, and so on. It is quite simple to do this by hand for a small number of elements, but as the numbers get big, it gets harder and harder.

Someone has suggested that I can use the boost graph library for this problem, but am not quite sure how to do as I do not have enough experience with it. Any help would be much appreciated.

Thanks in advance

  • 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-13T02:36:51+00:00Added an answer on June 13, 2026 at 2:36 am
    template< class It >
    void compute_all_possible_paths( path_collection_t& res, It b, It e ) {
        std::size_t curVecSize = res.size();
        for( std::size_t i = 0; i < curVecSize; i++ ) {
            path_t p;
            p.reserve( res[i].size() + 1 );
            std::copy( res[i].begin(), res[i].end(), std::back_inserter(p) );
            p.push_back( *b );
            res.push_back( p );
        }
        path_t p;
        p.push_back( *b );
        res.push_back( p );
        if( ++b == e ) return ;
        compute_all_possible_paths( res, b, e );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OSX 10.7, XCode 4. I have a small problem: I need to push back
I have a small problem where I want to find the next active item
Given a large sparse matrix (say 10k+ by 1M+) I need to find a
SQL to find duplicate entries (within a group) I have a small problem and
I have a small problem, looked here & other forums, but could not find
have small problem, and would very much appreciate help :) I should convert byte
I have small problem with Spring MVC. Basically what I'm trying to do is
I have a small problem and I've figured out where when and why it
I have a small problem which i can't seem to figure out. I tried
I have a small problem which i can't seem to solve myself. Look at

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.