code: def get_edges_to_match(G, node_id, matched_nodes):
      # Find the edges in G with one end-point as node_id and other in matched_nodes or node_id
      incident_edges = np.array([], dtype=int)
      index = np.array([], dtype=int)
      direction = np.array([], dtype=int)
      if G.has_edge_between(node_id, node_id):
          self_edge_ids = G.edge_ids(
              node_id, node_id, return_array=True
          ).numpy()
          incident_edges = np.concatenate(
              (incident_edges, self_edge_ids)
          )
          index = np.concatenate((index, [-1] * len(self_edge_ids)))
          direction = np.concatenate(
              (direction, [0] * len(self_edge_ids))
          )
      # Find predecessors
      src, _, eid = G.in_edges([node_id], "all")
      eid = eid.numpy()
      src = src.numpy()
      filtered_indices = [
          (i, matched_nodes.index(src[i]))
          for i in range(len(src))
          if src[i] in matched_nodes
      ]
      matched_index = np.array(
          [_[1] for _ in filtered_indices], dtype=int
      )
      eid_index = np.array([_[0] for _ in filtered_indices], dtype=int)
      index = np.concatenate((index, matched_index))
      incident_edges = np.concatenate((incident_edges, eid[eid_index]))
      direction = np.concatenate(
          (direction, np.array([-1] * len(filtered_indices), dtype=int))
      )
      # Find successors
      _, dst, eid = G.out_edges([node_id], "all")
      eid = eid.numpy()
      dst = dst.numpy()
      filtered_indices = [
          (i, matched_nodes.index(dst[i]))
          for i in range(len(dst))
          if dst[i] in matched_nodes
      ]
      matched_index = np.array(
          [_[1] for _ in filtered_indices], dtype=int
      )
      eid_index = np.array([_[0] for _ in filtered_indices], dtype=int)
      index = np.concatenate((index, matched_index))
      incident_edges = np.concatenate((incident_edges, eid[eid_index]))
      direction = np.concatenate(
          (direction, np.array([1] * len(filtered_indices), dtype=int))
      )
      return incident_edges, index, direction
  
file_path: dgl/examples/pytorch/graph_matching/ged.py
imports: from copy import deepcopy
  from heapq import heapify, heappop, heappush, nsmallest
  import dgl
  import numpy
  from lapjv import lapjv
label_desc: Use image node_id 3 for calling a global function with example usage: get_edges_to_match(G, node_id, matched_nodes) and returns: incident_edges,  index,  direction