# HG changeset patch
# User YLC <y@l.c>
# Date 1299782259 3600
# Node ID 407ddcc93ce72baa181c453fd219d6992158f23c
# Parent 1202db4df8c225b23a9cee751f544671389540fc
#10905 reviewer efficiency improvment
diff r 1202db4df8c2 r 407ddcc93ce7 sage/graphs/base/c_graph.pyx
a

b


2723  2723  # The vertices which have already been visited 
2724  2724  cdef bitset_t seen 
2725  2725  bitset_init(seen, cg.active_vertices.size) 
2726   
 2726  
2727  2727  # The list of waiting vertices, the beginning and the end of the list 
2728  2728  
2729  2729  cdef unsigned short * waiting_list = <unsigned short *> sage_malloc(n*sizeof(short)) 
… 
… 

2745  2745  cdef unsigned short * v_distances = <unsigned short *> sage_malloc(n*sizeof(short)) 
2746  2746  cdef unsigned short * v_prec = <unsigned short *> sage_malloc(n*sizeof(short)) 
2747  2747  
 2748  cdef dict ggbvi = gg._backend.vertex_ints 
 2749  cdef dict ggbvl = gg._backend.vertex_labels 
 2750  
 2751  cdef list outneighbors 
2748  2752  for source in vertices: 
2749  2753  bitset_set_first_n(seen, 0) 
2750  2754  bitset_add(seen, source) 
… 
… 

2757  2761  
2758  2762  while waiting_beginning <= waiting_end: 
2759  2763  v = waiting_list[waiting_beginning] 
2760   
2761   for u in cg.out_neighbors(v): 
 2764  outneighbors = cg.out_neighbors(v) 
 2765  for u in outneighbors: 
2762  2766  if not bitset_in(seen, u): 
2763  2767  v_distances[u] = v_distances[v]+1 
2764  2768  v_prec[u] = v 
… 
… 

2771  2775  tmp_distances = dict() 
2772  2776  tmp_prec = dict() 
2773  2777  for v in vertices: 
2774   vv = vertex_label(v, gg._backend.vertex_ints, gg._backend.vertex_labels, gg._backend._cg) 
 2778  vv = vertex_label(v, ggbvi, ggbvl, cg) 
2775  2779  
2776  2780  if bitset_in(seen, v): 
2777   tmp_prec[vv] = vertex_label(v_prec[v], gg._backend.vertex_ints, gg._backend.vertex_labels, gg._backend._cg) 
 2781  tmp_prec[vv] = vertex_label(v_prec[v], ggbvi, ggbvl, cg) 
2778  2782  tmp_distances[vv] = v_distances[v] 
2779  2783  else: 
2780  2784  tmp_prec[vv] = None 
2781  2785  tmp_distances[vv] = Infinity 
2782  2786  
2783   vv = vertex_label(source, gg._backend.vertex_ints, gg._backend.vertex_labels, gg._backend._cg) 
 2787  vv = vertex_label(source, ggbvi, ggbvl, cg) 
2784  2788  tmp_prec[vv] = None 
2785  2789  d_prec[vv] = tmp_prec 
2786  2790  d_distances[vv] = tmp_distances 