I have to combinatorially count all possible cases for a task. I want to make a tree for that purpose. There are several jobs and each job has several sub jobs. There are many agents available to do the jobs. Suppose Job1 Subjob1 can be done by Agent 1 or 2, then Job 1 Sub Job2 will be done by either of the agents. And then Job 2 will be started. and so on. Since nodes are varying and also the number of child nodes changes at different levels, my questions are:
what is the best data structure to implement the same?
what is the best way to traverse the tree using the data structure that you have recommended?
please give concrete C++/Java examples or web sources also rather than only abstract advise as I am green at coding.
EDIT:
Please refer to the flowchart for the tree that i have in mind.
Hmmm, I don't think a tree is the best data structure for your requirements. I suggest a std::vector
of Jobs
. Each Job
should have a container of subjobs
Your schedule can iterate through a vector much easier than a tree.
Edit 1: The code
class Subjob;
class Job
{
std::vector<Subjob> other_jobs;
};
std::vector<Job> task_container;