I need to filter out nodes from a graph based on the value of links coming out of that node and the value of those nodes. And, I need to iterate in fashion where I start from one node and then go through each node going out, but, and this is very important, I need to be able to not go through some nodes if they don’t match my condition.
Example:
If I have the graph like this:
A -> B -> D -> E
A -> C
I want to start from A, then check if B and C match my link and node conditions and if they do, move forward to the either B, C or both. If none of them match my condition, I want to stop there and never visit that node again, even if I get to it form a different link.
Basically, I want to filter a graph by traversing each node/link once and checking if they match my conditions, but the thing is that my condition is related to the other sibling nodes (coming out of the node I’m analyzing). So, if I’m at node A, I want to only go through the biggest value node (be that B or C), so I need to know both B and C, compare them and only navigate forward with the biggest one.
Is there an easy way to do this? Or should I just iterate through all the nodes, get all the nodes coming out of each of them, do my comparison, remember the nodes that don’t match my condition, then when I get to them (cause I iterate through all of them) just ignore them. The problem with this approach is that I iterate through all the nodes, allthough I don’t need to, cause maybe I choose C instead of B, then I skip the nodes D and E.