Random Graph Properties Calculator

  • Share this:

Code introduction


This function takes a graph object as input and returns a dictionary containing various random properties of the graph, such as degree, diameter, eccentricity, etc.


Technology Stack : Igraph

Code Type : Python Function

Code Difficulty : Intermediate


                
                    
def random_graph_properties(graph):
    """
    This function returns a dictionary containing random properties of the given graph.
    """
    import igraph as ig

    properties = {
        "degree": graph.degree(),
        "diameter": graph.diameter(),
        "eccentricity": graph.eccentricity(),
        "average_path_length": graph.average_path_length(),
        "modularity": graph.modularity(),
        "triangle_count": graph.triangle_count()
    }
    
    return properties                
              
Tags: