Hi,
For the python code:
On comment I would have is that the children discovery could be done only once outside of the tree depth loop and then reused.
Also I am not sure how you know at the end that nodeVecs[root] actually contains what you want. Because the content of nodeVecs changes at every iteration of the loop. Or maybe I’m missing something here.
For c++ vs python:
I think it will greatly depend on the size of your embeddings, connectivity of your graph etc.
With big enough embeddings, the compute will be predominant over other runtime and there is no benefit to be expected from moving to cpp.
For very small embeddings, it might help.