// Then pick a neighbor for each, and use it to update the zero vector.
adjacent_nonzeros = adjacency_matrix.dot(
diags([nonzero_indices.astype(np.int8)], [0], format="csc"))
neighbors = np.argmax(adjacent_nonzeros[fringe, :], axis=1)
neighbors = neighbors.A[:, 0] // convert matrix to 1D ndarray
vectors[fringe, :] = vectors[neighbors, :]
n_old_plus_new_non_en = len(combined_index) - n_new_english
After Change
// Update each as the average of its nonzero neighbors
adjacent_nonzeros = adjacency_matrix[fringe, :].dot(
diags([nonzero_indices.astype(np.int8)], [0], format="csc"))
n_adjacent_nonzeros = adjacent_nonzeros.sum(axis=1).A[:, 0]
weights = 1.0 / n_adjacent_nonzeros
vectors[fringe, :] = adjacency_matrix[fringe, :].dot(vectors)
vectors[fringe, :] = diags([weights], [0], format="csr").dot(
vectors[fringe, :])
n_old_plus_new_non_en = len(combined_index) - n_new_english
result = pd.DataFrame(index=combined_index[0:n_old_plus_new_non_en],
data=vectors[0:n_old_plus_new_non_en, :])