The attached file has the source code. The purpose of the program is toIt compiles fine using GCC on Debain, GCC on Win XP, and Borland 5.02 on Win 2k.Purpose: This program is designed to create a list of sectors that randomily connect to other sectors.
Every sector needs to be accessible, either directly or via another sector, by the root sector (0).
Each sector can connect to 1-6 other sectors. It is not required that a sector connect to a sector that connects to it. To clarify: Sector 5 connects to sectors: 3, 100, 238, and 584. None of these sectors are required to connect to sector 5 but they still may.
The program will then go and verify that each sector is reachable from sector 0. If not it will randomily assign sectors to point to that those unreachable sectors. It will continue to do this until all zones are reachable.
The program will then go and make sure that each sector is able to reach sector 0. To save time if it reaches a sector that has been verified to be able to reach sector 0 it will conclude that sector in question is able to reach sector 0.
The problem lies in when you specify too many sectors I'll get segmentation faults. On the debain machine (which is a lot older and has less memory then the other two) I can specify 100,000 sectors and it will run fine.
I am thinking that there is a limit on how big of a block of memory you can assign. Can anyone find another reason for this?
Note: The formating got a little screwy when I loaded it into Borland. I tried to fix it and I hope it displays correctly on your IDE.
Note 2: Overall I'm happy with this code. On the 667 mhz debain machine doing 150,000 sectors it only took abot 3.5 mins.
Edit: made purpose a little more detailed.



LinkBack URL
About LinkBacks



