def _solve_bf(lap_sparse, B, return_full_prob=False):
 lap_sparse = lap_sparse.tocsc()
 solver = sparse.linalg.factorized(lap_sparse.astype(np.double))
 X = np.array([solver(np.array((- B[i]).todense()).ravel()) for i in range(len(B))])
 if (not return_full_prob):
  X = np.argmax(X, axis=0)
 return X

def _solve_bf ( lap_sparse , B , return_full_prob = False ) : lap_sparse = lap_sparse . tocsc ( ) solver = sparse . linalg . factorized ( lap_sparse . astype ( np . double ) ) X = np . array ( [ solver ( np . array ( ( - B [ i ] ) . todense ( ) ) . ravel ( ) ) for i in range ( len ( B ) ) ] ) if ( not return_full_prob ) : X = np . argmax ( X , axis = 0 ) return X
solves lap_sparse x_i = b_i for each phase i .