All problems
Core-Periphery Check
Problem
Check whether a labeled partition matches the idealized core-periphery model.
The core nodes must form a clique, the periphery nodes must be independent (no edges among them), and every periphery node must have at least one core neighbor. Return a boolean. edges is a list of [u, v] pairs and core is a 0/1 list marking core nodes.
Hint
The idealized model has a dense core and a star-like periphery.
Test cases
case 1
in: [4,[[0,1],[0,2],[0,3]],[1,0,0,0]]
expected: true
case 2
in: [4,[[0,1],[1,2],[2,0],[2,3]],[1,1,1,0]]
expected: true
case 3
in: [4,[[0,1],[1,2],[2,0],[2,3]],[0,0,0,1]]
expected: false
case 4
in: [3,[[0,1],[1,2]],[1,0,1]]
expected: false
case 5
in: [4,[[0,1],[0,2],[0,3],[1,2],[1,3],[2,3]],[1,1,0,0]]
expected: false
Starter codePython
def core_periphery_check(n, edges, core):
# Your code here
pass5 test cases · run your code against them in the editor