Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Is the boruvka's implementation able to handle forests? #2

Open
Laksha-Prashanth opened this issue Nov 20, 2017 · 1 comment
Open

Comments

@Laksha-Prashanth
Copy link

Can you please mention what happens in case a vertex does not have any edges connecting to it. Will this implementation give a minimum spanning forest?

Or is that not a valid case?

@SethosII
Copy link
Owner

The implementation of boruvkas algorithm should be able to handle forests by design. Here is a quick test:

Example graph (maze.csv):

6 5
0 3 1
1 2 2
1 4 5
2 5 4
4 5 3

Looks like this:

+ +-+
| | |
+ +-+

Run it with this graph (mpirun -np 2 ./mst -c 3 -r 2 -a 3 -f mazeGraph.csv -m -v):

Starting
Graph:
0	3	1	
1	2	2	
1	4	5	
2	5	4	
4	5	3	
Time elapsed: 0.000794 s
MST:
0	3	1	
1	2	2	
4	5	3	
2	5	4	
0	0	0	
MST weight: 10
Maze:
+ +-+
|   |
+ +-+
Finished

Allthouh the MST weight given is the sum over the forest and the last edge in the output of the MST (0 0 0) doesn't belong to it. This is because the MST graph struct is created at the begining and there I assume that the MST will have as many edges as there are vertices - 1 (see https://github.com/SethosII/minimum-spanning-tree/blob/master/src/main.c#L207).

Does this answer your question?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants