Function NetworKit::GraphTools::randomEdge

Function Documentation

std::pair<node, node> NetworKit::GraphTools::randomEdge(const Graph &G, bool uniformDistribution = false)

Returns a random edge. By default a random node u is chosen and then some random neighbor v. So the probability of choosing (u, v) highly depends on the degree of u. Setting uniformDistribution to true, will give you a real uniform distributed edge, but will be slower. Exp. time complexity: O(1) for uniformDistribution = false, O(n) otherwise.

Parameters:
  • Graph – G The input graph.

  • bool – uniformDistribution Whether the random edge should be extracted uniformly at random.

Returns:

std::pair<node, node> A random edge.