Buggy python submission (verdict: Runtime Error):
# D

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import breadth_first_order

N, M = list(map(int, input().split()))
ABs = np.array([list(map(int, input().split())) for i in range(M)])

row = ABs.T[0]
col = ABs.T[1]
data = [1] * (M)

csr = csr_matrix((data, (row, col)), shape=(N, N))
_, proc = breadth_first_order(csr, 0, directed=False)

if -9999 in proc[1:]:
  print('No')
else:
  print('Yes')
  print('\n'.join((proc[1:]+1).astype('str')))

Fixed submission:
# D

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import breadth_first_order

N, M = list(map(int, input().split()))

row = []
col = []
for i in range(M):
    r, c = list(map(int, input().split()))
    row.append(c-1)
    col.append(r-1)

data = [1] * (M)

csr = csr_matrix((data, (row, col)), shape=(N, N))
_, proc = breadth_first_order(csr, 0, directed=False)

if -9999 in proc[1:]:
  print('No')
else:
  print('Yes')
  print('\n'.join((proc[1:]+1).astype('str')))

Buggy python submission (verdict: Runtime Error):
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
import numpy as np
# D

N, M = list(map(int, input().split()))
ABs = np.array([list(map(int, input().split())) for i in range(M)])

ABsT = ABs.T
row = list(ABsT[0]-1) + list(ABsT[1]-1)
col = list(ABsT[1]-1) + list(ABsT[0]-1)
data = [1] * (2 * M)

csr = csr_matrix((data, (row, col)), shape=(N, N))
from_starts, procs = dijkstra(csr, indices=[0], return_predecessors=True)
proc = procs[0]
 
print(csr.toarray())
print(proc)
if -9999 in proc[1:]:
  print('No')
else:
  print('Yes')
  for i in range(N-1):
    print(int(proc[i+1]) + 1)

Fixed submission:
# D

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import breadth_first_order

N, M = list(map(int, input().split()))

row = []
col = []
for i in range(M):
    r, c = list(map(int, input().split()))
    row.append(c-1)
    col.append(r-1)

data = [1] * (M)

csr = csr_matrix((data, (row, col)), shape=(N, N))
_, proc = breadth_first_order(csr, 0, directed=False)

if -9999 in proc[1:]:
  print('No')
else:
  print('Yes')
  print('\n'.join((proc[1:]+1).astype('str')))

Buggy python submission (verdict: Time Limit Exceeded):
# D

N, M = list(map(int, input().split()))
# ABs = [list(map(int, input().split())) for i in range(M)]

adj_matrix = [[10**9] * N for i in range(N)]
for i in range(M):
    ab = list(map(int, input().split()))
    adj_matrix[ab[0]-1][ab[1]-1] = 1
    adj_matrix[ab[1]-1][ab[0]-1] = 1
 
from scipy.sparse.csgraph import dijkstra, csgraph_from_dense
import numpy as np
 
csr = csgraph_from_dense(adj_matrix, null_value=10**9)
from_starts, procs = dijkstra(csr, indices=[0], return_predecessors =True)
from_start = from_starts[0]
proc = procs[0]
 
if -9999 in proc[1:]:
  print('No')
else:
  print('Yes')
  for i in range(N-1):
    print(int(proc[i+1]) + 1)

Fixed submission:
# D

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import breadth_first_order

N, M = list(map(int, input().split()))

row = []
col = []
for i in range(M):
    r, c = list(map(int, input().split()))
    row.append(c-1)
    col.append(r-1)

data = [1] * (M)

csr = csr_matrix((data, (row, col)), shape=(N, N))
_, proc = breadth_first_order(csr, 0, directed=False)

if -9999 in proc[1:]:
  print('No')
else:
  print('Yes')
  print('\n'.join((proc[1:]+1).astype('str')))

Buggy python submission (verdict: Time Limit Exceeded):
# D

N, M = list(map(int, input().split()))
ABs = [list(map(int, input().split())) for i in range(M)]

 
from scipy.sparse.csgraph import dijkstra, csgraph_from_dense
import numpy as np
 
adj_matrix = [[10**9] * N for i in range(N)]
for ab in ABs:
    adj_matrix[ab[0]-1][ab[1]-1] = adj_matrix[ab[1]-1][ab[0]-1] = 1
 
csr = csgraph_from_dense(adj_matrix, null_value=10**9)
from_starts, procs = dijkstra(csr, indices=[0], return_predecessors =True)
from_start = from_starts[0]
proc = procs[0]
 
if -9999 in proc[1:]:
  print('No')
else:
  print('Yes')
  for i in range(N-1):
    print(int(proc[i+1]) + 1)

Fixed submission:
# D

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import breadth_first_order

N, M = list(map(int, input().split()))

row = []
col = []
for i in range(M):
    r, c = list(map(int, input().split()))
    row.append(c-1)
    col.append(r-1)

data = [1] * (M)

csr = csr_matrix((data, (row, col)), shape=(N, N))
_, proc = breadth_first_order(csr, 0, directed=False)

if -9999 in proc[1:]:
  print('No')
else:
  print('Yes')
  print('\n'.join((proc[1:]+1).astype('str')))