concepts.benchmark.algorithm_env.graph.random_generate_graph_dnc#

random_generate_graph_dnc(n, p=None, directed=False, np_random=None)[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 (int) – the number of nodes in the graph.

  • p (float | None) –

    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 (bool) – directed or Undirected graph. Default: False (undirected)

  • np_random (RandomState | None) – the random state.

Returns:

A randomly generated graph.

Return type:

graph