Algorithmic inclusion relation

I have an algorithmic problem where I used to have an array with an index and now I want to have all of them

Here’s an example
Left: The input array originally contained index relationships
Right: New array index contains relationships (results regardless of the number order)

enter image description here
[[2],[],1]

[[2],[3],1,[]]

[[2],[],1,1]

[[2],[],1,[0]]