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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:36:38+00:00 2026-05-26T06:36:38+00:00

I am trying to use the Prim algorithm with prim_minimum_spanning_tree function of the boost

  • 0

I am trying to use the Prim algorithm with prim_minimum_spanning_tree function of the boost library, using a file containing all my graph points. I successfuly created the graph I wanted with the kruskal_minimum_spanning_tree function of boost library.

But with the prim_minimum_spanning_tree I only get the direct parent of each points so my graph is not complete.

I used the examples given in the boost documentation :

for prim : http://www.boost.org/doc/libs/1_47_0/libs/graph/example/prim-example.cpp

and the kruskal one http://www.boost.org/doc/libs/1_47_0/libs/graph/example/kruskal-example.cpp

A concrete example : I have this file of points :

10
0 0.655171
0.304819 0.674978
0.106754 0.516587
0.489669 0.602466
0.369945 0.256661
0.374187 0.825587
0.172704 0.2978
0.643544 0.789666
0.987823 0.800592
0.464248 0.538987

with the krukal functions I get :

3 <--> 9
1 <--> 5
0 <--> 2
1 <--> 3
6 <--> 4
6 <--> 2
3 <--> 7
2 <--> 1
8 <--> 7

with the prim function I get :

1 <--> 5
2 <--> 0
3 <--> 9
4 <--> 6
5 <--> 1
6 <--> 4
7 <--> 3
8 <--> 7
9 <--> 3

I have the drawing of those graph but I can’t post images nor several linksl.
But as you can see I miss 3 links.

How can I get the same result as I have with kruskal with the prim function?

Thank you,

PS : I used the code of the example, as a base and tried a bunch of modifications without any success, couldn’t find any usefull information on the web or on the documentation.

  • 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-26T06:36:39+00:00Added an answer on May 26, 2026 at 6:36 am

    I have found the answer to my own question, might be usefull to someone else.

    I was linking the points twice, which work for the kruskal’s algorithm, but not for the prim’s one, for example in my edges I had :

    0 <--> 1
    1 <--> 0
    

    where I should have only linked the points once for the prim’s algorithm.

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

Sidebar

Related Questions

I have been trying use the edit_post_link() function to contain an image. All of
I am relatively new to CMake, and I'm trying use the boost asio library
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
Trying to use GnuPG with Delphi (Win32). I need to sign some file with
Trying to use php to get all files in a directory and save them
I am trying use MySql and Entity Framework, using Connector/Net 6.1 with this as
I'm trying use make a div's background transparent using a mixture of CSS3 rgba()
I'm trying different data structures for implementing Prim's algorithm. So I made a class
I am trying use the onClick() function in an activity for an android app.
I revieving the following error when trying use mysql_real_escape() function Fatal error: Call to

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.