skip to Main Content

While running some tests, I was looking for a way that can generate random nodes and edges with random values. I know in postgresql there are some helper functions like random() and generate_series() that can be used to fill in the table easily but what I’m looking for is a way I can create random nodes and edges between them.

2

Answers


  1. You can use the function create_complete_graph to generate the graph, it should look like this:

    SELECT * FROM create_complete_graph('graph_name', 5, 'edge_label', 'vertice');
    

    In this example, 5 represents the number of nodes you want in the graph.

    Login or Signup to reply.
  2. You can also use Python for this to generate random nodes and edges with random values. For this reason You can use utilise using Network X python library.

    Official Documentation here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search