code: def retrieve_adjacency_matrix(graph, order_nodes=None, weight=False):
      
      if isinstance(graph, np.ndarray):
          return graph
      elif isinstance(graph, nx.DiGraph):
          if order_nodes is None:
              order_nodes = graph.nodes()
          if not weight:
              return np.array(nx.adjacency_matrix(graph, order_nodes, weight=None).todense())
          else:
              return np.array(nx.adjacency_matrix(graph, order_nodes).todense())
      else:
          raise TypeError("Only networkx.DiGraph and np.ndarray (adjacency matrixes) are supported.")
docs: Retrieve the adjacency matrix from the nx.DiGraph or numpy array.