title: How to identify root nodes in a python dictionary?
body: <p>I have a python dictionary that is representing a graph. I wish to identify the root/independent nodes so that I can process them simultaneously and then the next nodes will become root/independent nodes. 
  I am confused about how to implement this technique in python.</p>
  
  <p>Below is a sample dictionary:</p>
  
  <pre><code>my_graph = {
              1:[4],
              2:[6],
              3:[9],
              4:[5,7],
              5:[8],
              6:[],
              7:[],
              8:[],
              9:[]
             }
  </code></pre>
  
  <p>I will divide the process into different frames. The expected result depending upon the above dictionary is given as:</p>
  
  <p>1- start:
   root/independent nodes are = 1,2,3</p>
  
  <p>2- after frame 1
   root/independent nodes are = 4,6,9</p>
  
  <p>3- after frame 2
   root/independent nodes are = 5,7</p>
  
  <p>4- after frame 3
   root/independent nodes are = 8</p>
  
  <p>Edit 1:
   I am trying to get sequence in any form e.g. a list, array or any other similar data-structure to a dependency graph of nodes in given dictionary, where each child node is dependent on its parent node so cannot be processed before parent. As a next step, I wish to get some parallelism i.e. I can process all root nodes at once. </p>
  
  <p>I have been reading about <a href="https://docs.dask.org/en/latest/" rel="nofollow noreferrer">Dask</a> and <a href="https://github.com/spotify/luigi" rel="nofollow noreferrer">luigui</a> but not sure if they are the ultimate solution or I can do it some simple way.</p>