parameters: (skeleton_id:Union[int,str])
return_statement: return nodes
docstring: Compute the synapse centrality of every node in a tree.
      Return the dictionary of node ID keys and Count values.
      This function is meant for TESTING.
docstring_summary: Compute the synapse centrality of every node in a tree.
      Return the dictionary of node ID keys and Count values.
      This function is meant for TESTING.
docstring_tokens: Compute the synapse centrality of every node in a tree . Return the dictionary of node ID keys and Count values . This function is meant for TESTING .
function: def _node_centrality_by_synapse_db(skeleton_id:Union[int,str]) -> Dict:
      """ Compute the synapse centrality of every node in a tree.
      Return the dictionary of node ID keys and Count values.
      This function is meant for TESTING. """
      cursor = connection.cursor()
      cursor.execute('''
      SELECT t.id, t.parent_id, r.relation_name
      FROM treenode t LEFT OUTER JOIN (treenode_connector tc INNER JOIN relation r ON tc.relation_id = r.id) ON t.skeleton_id = tc.skeleton_id
      WHERE t.skeleton_id = %s
      ''', (skeleton_id))
  
      nodes:Dict = {}  # node ID vs Counts
      tree = nx.DiGraph()
      root = None
      totalInputs = 0
      totalOutputs = 0
  
      for row in cursor.fetchall():
          counts = nodes.get(row[0])
          if not counts:
              counts = Counts()
              nodes[row[0]] = counts
          if row[2]:
              if 'presynaptic_to' == row[2]:
                  counts.outputs += 1
                  totalOutputs += 1
              elif 'postsynaptic_to' == row[2]:
                  counts.inputs += 1
                  totalInputs += 1
          if row[1]:
              tree.add_edge(row[0], row[1])
          else:
              root = row[0]
  
      _node_centrality_by_synapse(tree, nodes, totalOutputs, totalInputs)
  
      return nodes
function_tokens: def _node_centrality_by_synapse_db ( skeleton_id : Union [ int , str ] ) -> Dict : cursor = connection . cursor ( ) cursor . execute ( '''
      SELECT t.id, t.parent_id, r.relation_name
      FROM treenode t LEFT OUTER JOIN (treenode_connector tc INNER JOIN relation r ON tc.relation_id = r.id) ON t.skeleton_id = tc.skeleton_id
      WHERE t.skeleton_id = %s
      ''' , ( skeleton_id ) ) nodes : Dict = { } # node ID vs Counts tree = nx . DiGraph ( ) root = None totalInputs = 0 totalOutputs = 0 for row in cursor . fetchall ( ) : counts = nodes . get ( row [ 0 ] ) if not counts : counts = Counts ( ) nodes [ row [ 0 ] ] = counts if row [ 2 ] : if 'presynaptic_to' == row [ 2 ] : counts . outputs += 1 totalOutputs += 1 elif 'postsynaptic_to' == row [ 2 ] : counts . inputs += 1 totalInputs += 1 if row [ 1 ] : tree . add_edge ( row [ 0 ] , row [ 1 ] ) else : root = row [ 0 ] _node_centrality_by_synapse ( tree , nodes , totalOutputs , totalInputs ) return nodes