concepts.benchmark.algorithm_env.graph.random_generate_graph_dnc#

random_generate_graph_dnc(n, p=None, directed=False)[source]#

Random graph generation method as in DNC, the Differentiable Neural Computer paper. Sample \(n\) nodes in a unit square. sample out-degree (\(m\)) of each nodes, connect to \(m\) nearest neighbors (Euclidean distance) in the unit square.

Parameters:
  • n – The number of nodes in the graph.

  • p

    Control the range of the sample of out-degree. Default: \([1, n // 3]\)

    • (float): \([1, int(n * p)]\)

    • (int): \([1, p]\)

    • (tuple): \([p[0], p[1]]\)

  • directed – Directed or Undirected graph. Default: False (undirected)

Returns:

A randomly generated graph.

Return type:

graph