Skip to content
DeepForgeby svx
All problems
MediumLinear Algebrala-261

Fiedler Vector Sign Partition

Problem

Partition the vertices of a graph using the signs of its Fiedler vector v.

Return [part0, part1], where part0 contains the indices with v[i] >= 0 and part1 the indices with v[i] < 0, both sorted in ascending order.

Hint

The sign pattern of the Fiedler vector gives a good 2-way spectral partition.

Test cases

case 1
in: [[0.1,-0.2,0.3,-0.4]]
expected: [[0,2],[1,3]]
case 2
in: [[1,2,3]]
expected: [[0,1,2],[]]
case 3
in: [[-1,-2]]
expected: [[],[0,1]]
case 4
in: [[0,0]]
expected: [[0,1],[]]
Starter codePython
def fiedler_partition(v):
    # Your code here
    pass

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