def RandomGraph(nodes=list(range(<NUM_LIT:10>)), min_links=<NUM_LIT:2>, width=<NUM_LIT>, height=<NUM_LIT>,<EOL>curvature=lambda: random.uniform(<NUM_LIT>, <NUM_LIT>)):
g = UndirectedGraph()<EOL>g.locations = {}<EOL>for node in nodes:<EOL><INDENT>g.locations[node] = (random.randrange(width), random.randrange(height))<EOL><DEDENT>for i in range(min_links):<EOL><INDENT>for node in nodes:<EOL><INDENT>if len(g.get(node)) < min_links:<EOL><INDENT>here = g.locations[node]<EOL>def distance_to_node(n):<EOL><INDENT>if n is node or g.get(node,n): return infinity<EOL>return distance(g.locations[n], here)<EOL><DEDENT>neighbor = argmin(nodes, distance_to_node)<EOL>d = distance(g.locations[neighbor], here) * curvature()<EOL>g.connect(node, neighbor, int(d))<EOL><DEDENT><DEDENT><DEDENT>return g<EOL>
Construct a random graph, with the specified nodes, and random links.
    The nodes are laid out randomly on a (width x height) rectangle.
    Then each node is connected to the min_links nearest neighbors.
    Because inverse links are added, some nodes will have more connections.
    The distance between nodes is the hypotenuse times curvature(),
    where curvature() defaults to a random number between 1.1 and 1.5.