code: def _revalidate_node_edges(rag, node, heap_list):
      """Handles validation and invalidation of edges incident to a node.
  
      This function invalidates all existing edges incident on `node` and inserts
      new items in `heap_list` updated with the valid weights.
  
      rag : RAG
          The Region Adjacency Graph.
      node : int
          The id of the node whose incident edges are to be validated/invalidated
          .
      heap_list : list
          The list containing the existing heap of edges.
      """
      # networkx updates data dictionary if edge exists
      # this would mean we have to reposition these edges in
      # heap if their weight is updated.
      # instead we invalidate them
  
      for nbr in rag.neighbors(node):
          data = rag[node][nbr]
          try:
              # invalidate edges incident on `dst`, they have new weights
              data["heap item"][3] = False
              _invalidate_edge(rag, node, nbr)
          except KeyError:
              # will handle the case where the edge did not exist in the existing
              # graph
              pass
  
          wt = data["weight"]
          heap_item = [wt, node, nbr, True]
          data["heap item"] = heap_item
          heapq.heappush(heap_list, heap_item)
  
imports: import numpy
  import heapq
label_desc: Use image node_id 1 for calling a global function with example usage: _revalidate_node_edges(rag, node, heap_list) without return types