Minimun Spannig Tree

Blitz3D Forums/Blitz3D Programming/Minimun Spannig Tree

limdorn(Posted 2011) [#1]
Hi , I´m working a game like Master of Orion and I need help to connect all stars to create the starlines.
Exist a algorithm named "minimun spanning tree" to create this effect but I don´t understand it.
Somebody can help me?
Thanks


Ginger Tea(Posted 2011) [#2]
I had a quick look at the wiki page before my eyes crossed, do you really want all dot's (stars) connected in this fassion?

I ask for a few reasons
1> going from star to star should just be a straight line trip, where as this might take you "round the houses" so to speak depending on it's out come
2> more stars/dot's the more work it has to do to plot the route where each star is visited once only (atleast I think thats the plan).

I'm not familiar with Masters of Orion or how the star lines work and I'm assuming you are not looking for something like constelations as this is not the droid you are looking for, although the image does look like one. If its a road map between stars and it has to go via near by stars, why I don't know, then you wont need to plot the entire star map, just a local event between those two points and A* might be more suited.

edit:
eg you want to go from the top right point to the bottom right, which has a weight of 18 acording to the diagram, if you went via the other stars the total would be far greater, if that was read as distance, then going round the houses is not quicker (obviously) and would only benefit the ship if it had to make solar boosts inbetween and the single point trip would cause the ship to run out of juice.

Last edited 2011


Krischan(Posted 2011) [#3]
In the german community, "FirstDeathMaker" created a solution for this - if you don't understand german I put it all together in two single files ready to run. It creates 100 Stars, connects them and calculates / displays the shortest path between two random stars. But it is *very* complex, I don't understand exactly how it works so don't ask me :-D

You can move with mouse/arrows and Enter creates a new random route.



demo.bb


spanningtree.bb


Last edited 2011


limdorn(Posted 2011) [#4]
Thanks.
You help a lot.


Warpy(Posted 2011) [#5]
Aaar! I've just spent an hour or so writing a proper explanation of the algorithm in BlitzMax, and I've just noticed this is in the b3d forum! Eugh!

Anyway, here's the code, and here's an EXE file of the demo. It walks through the algorithm step by step, explaining what's going on.