This is kind of tricky to explain but I’ll do my best to simplify it.

Basically I have created a flowchart creator, the flowchart is made up of nodes, each node contains a list of sprites, node paths are determined from any complete path beginning at the start node and finishing at the end node. That’s all good, that’s all working.

EDIT: image code isn’t working for some reason but here is a link to the image for a better understanding

!(http://)

So I have a list of node paths, that all works but let’s just imagine there is only one node path to make it simpler (The path on the left that has the male node for example). How would I iterate through the nodes and the sprites they contain to get a list of all possible combinations of all the sprites?

A node path is just made up of a list of nodes and the nodes are just a class that contains a list of sprites.

Any help would be massively appreciated, this is the final problem that needs to be solved in order to complete my advanced NFT generator.

EDIT:

Never mind I eventually figured it out.

Well, this is for future reference.

There are multiple approaches depending on the exact format of the tree.

In general, you might explore the tree depth first, and mark a decision that ended up with a leaf node, so that you can decide differently on your subsequent paths. Obviously the algorithms can turn quite complex depending on what kind of result you need, but that’s a short explanation. For this to work, the graph must be a ‘directed acyclic graph’. This topic belongs to a domain of topological sorting.

Here’s an article about it.

There are lighter ways to approach this as well, especially if your graph starts and ends at pole nodes (aka fixed start/end). Then you don’t have to view the result from multiple vantage points and you can simply traverse it like a pathfinder would, while making sure that the system is “rewarded” for visiting the unvisited nodes. One way to do this is to keep track of all nodes in a separate collection (open set), and then move them to closed set once they’re visited. During traversal, you obviously prefer only nodes that are in the open set. Once you exhaust this set, you just need to make sure you can identify identical paths. (Obviously I’m simplifying the actual algorithm to the point of making it sound trivial; in reality you also need to take into account the actual edges, and not just the nodes.)

This depends on how many different nodes you have, but the simplest way would be to assign a letter to each one and produce identity strings, because you can then abuse existing string comparison methods to robustly match (and differentiate) the combinations.

If the tree is binary and unconstrained in its connectivity paths, you can use the trick I showed here , by exhausting the combinatorial space simply by virtue of how integers are represented in binary system.

None of these solutions work if you allow your graphs to be cyclic or bidirectional because then a naive traversal can get stuck but also you can’t easily determine which paths are similar or even a cyclic clone of another. In that case I think it’s the best to find a minimum spanning tree for an undirected graph and find an algorithm that is good at terminating the graph in such a way to make exploration possible in reasonable time. Still, as far as I can tell, an attempt to unknot such a graph is officially NP complete.