Can anybody provide links to this?
I used something like this:
struct timeval time;
gettimeofday(&time,NULL);
srand((time.tv_sec * 1000) + (time.tv_usec / 1000));
const int maxN = 1000;
const int N = rand() % maxN + 1;
cout << N << endl;
vector<int> nodeIds;
for (int i = 1; i <= N; i++)
{
nodeIds.push_back(i);
}
random_shuffle(nodeIds.begin(), nodeIds.end());
vector<int> usedNodeIds = { nodeIds.back() };
nodeIds.pop_back();
for (int i = 0; i < N - 1; i++)
{
const int newNodeId = nodeIds.back();
const int oldNodeId = usedNodeIds[rand() % usedNodeIds.size()];
cout << newNodeId << " " << oldNodeId << endl;
usedNodeIds.push_back(newNodeId);
nodeIds.pop_back();
}
for the testcase generation for CHGORAM
4 Likes
I use this snippet (found from some quora answer)
you can vary depth by varying alpha valueβ¦
i.e. if alpha =0, then it will be deepest tree(path)
alpha = 3
print([ (randint(max(0,i-alpha), i), i+1) for i in range(N-1)])