Random Graph Generation with Erdos-Renyi Model

  • Share this:

Code introduction


This function generates a random graph with a specified number of nodes and edges using the Erdos_Renyi function from the Igraph library.


Technology Stack : Igraph

Code Type : Function

Code Difficulty : Intermediate


                
                    
import igraph as ig
import random

def generate_random_graph(num_nodes, num_edges):
    # Generate a random graph with a specified number of nodes and edges
    graph = ig.Graph.Erdos_Renyi(n=num_nodes, m=num_edges)
    return graph

# JSON representation of the code                
              
Tags: