Skip to content
DeepForgeby svx
All problems
EasyGraph Algorithmsgraph-081

Random Walk Stationary Uniform Check

Problem

Decide whether the uniform distribution is stationary for the simple random walk on an undirected graph.

This happens exactly when the graph is regular: every node has the same degree, counting isolated nodes as degree 0. edges is a list of [u, v] pairs. Return a boolean.

Hint

Uniform stationarity means the degree sequence is constant.

Test cases

case 1
in: [4,[[0,1],[1,2],[2,3],[3,0]]]
expected: true
case 2
in: [4,[[0,1],[1,2],[2,3]]]
expected: false
case 3
in: [4,[[0,1],[0,2],[0,3],[1,2],[1,3],[2,3]]]
expected: true
case 4
in: [3,[]]
expected: true
case 5
in: [4,[[0,1],[0,2],[0,3]]]
expected: false
Starter codePython
def has_uniform_stationary(n, edges):
    # Your code here
    pass

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