Skip to content
DeepForgeby svx
All problems
EasyGraph Algorithmsgraph-237

Small-World Coefficient

Problem

Compute the small-world coefficient sigma = (C / C_rand) / (L / L_rand).

clustering and avg_path are the graph's clustering coefficient and average shortest path length; clustering_random and avg_path_random are the values of an equivalent random graph. Return sigma as a float.

Hint

A small world has much higher clustering than random while keeping short paths.

Test cases

case 1
in: [0.6,3,0.1,5]
expected: 10
case 2
in: [0.4,4,0.2,2]
expected: 1
case 3
in: [0.5,2,0.5,2]
expected: 1
Starter codePython
def small_world_coefficient(clustering, avg_path, clustering_random, avg_path_random):
    # Your code here
    pass

3 test cases · run your code against them in the editor