Download

Any examples of doing a breadth first search or queue in blueprints?

Hello,

I was wondering if anyone could provide some pointers on how to get something similar to a queue working in blueprints, since queue doesn’t exist in them. Specifically I’m trying to recreate a simple breadth first search and keep running into infinite loop errors when trying to use an array with while lastindex != 0, get index 0 ->set current ->remove index item at 0 -> continue with code. It also seems unreal really doesn’t like having a blueprint class call the same function within the function using a foreach loop or while loop. I’ve seem to hit a wall in trying to find examples online of doing a breadth first search without having queue functionality in blueprints.

Any help or links to getting a breadth first search example going would be much appreciated!

Scratch that! Turns out I was slamming my head into my desk over nothing. Replacing the Tqueue with an array using if lastindex < -1 whileloop -> getlastindex ->set current -> remove last index -> foreachloop blahblah current distance+insert index 0 worked great.

It’s just that since I was calling it directly on beginplay, all of the other actors weren’t able to set their adjacent actors using spherical rays before the whole sequence started from the initial actor. Simply adding in a delay fixed the whole thing!

Now to make it so it’s a bit more predictable and can reset so I can simulate electricity :smiley: