this post was submitted on 13 Dec 2025
129 points (99.2% liked)
Programming
24058 readers
799 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Similar to BFS?
No, BFS is ment to explore all nodes abd edges systematicaly, while ant algorithms may never explore a whole bunsh of nodes. They do they search not systematically but by walking paths randomly at the beginning and spreading pheromons while doing so. Finding shorter paths will result in a higher pheromon level remaining and thus direct next ants to these shorter paths instead of longer ones.
You wouldn't know, what they will do before executing the program and they will propably find shorter paths if you use 1000 ants instead of 100.
In my results I drew a graph the highlights the ant's paths by thicknes. I drew such a graph after (for example) 10, 100 and 1000 ants. You could see, that the first ants took a path randomly and after 100 iterations, some of the shorter edges became a bit thicker than others. At the end, only the shortest edges where drawn with high thickness while the longest one where rarely used if at all