# 关于稀疏数据结构snode.deactivate_all()报错疑问

`b_snode=ti.root.dense(ti.i, 3).bitmasked(ti.j,20)`

``````RuntimeError: [D:/a/taichi/taichi/taichi/transforms/type_check.cpp:visit@192] [\$15] S5 has 1 indices. Indexed with 2.
``````

``````import taichi as ti
ti.init(arch=ti.cuda)

edg_cout=ti.field(dtype=ti.i32 )
b_snode.place(edg_cout)
b_snode.deactivate_all()
``````

``````b_snode=ti.root.pointer(ti.i, 3)
b_snode.deactivate_all()
``````

（另外这代码里用range-for loop而没用struct-for loop来遍历稀疏数据，主要是struct-for loop不支持嵌套，要报错啊

``````import taichi as ti
import numpy as np

ti.init(arch=ti.cuda)

vex_conn_field = ti.field(dtype=ti.i32)
ti.root.pointer(ti.ij, (10, 20)).place(vex_conn_field)
@ti.func
def vex_is_conn( v1id, v2id):
rst = False
for i in ti.static(range(20)):
# for i in range(20):
if  vex_conn_field[v2id - 1, i] == v1id:
rst = True
break
return rst
@ti.func
def getCommonVertexNum(u,v):
cnt = 0
for i in ti.static(range(20)):
it =vex_conn_field[u-1,i]
if  it>0 and vex_is_conn(it,v):
cnt += 1

return cnt

@ti.func
def calVAndDeltaV(v1,v2):
c=getCommonVertexNum(v1, v2)

if c==2:
print(v1,v2)

@ti.kernel
def cal_vdeltav( m:ti.i32):
for i  in range(m):
if vex_conn_field[i,0]>0:
for j  in range(20):
calVAndDeltaV(i+1, vex_conn_field[i,j])
@ti.kernel
def init(m:ti.i32,arr:ti.ext_arr()):
for i in range(m):
for j in ti.static(range(20)):
if arr[i,j]>0:
vex_conn_field[i,j]=arr[i,j]

conn_vals=np.array([[2, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 2, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 2, 3, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]])

init(6,conn_vals)
cal_vdeltav(6)``````

``````edg_cout=ti.field(dtype=ti.i32 )
b_snode=ti.root.pointer(ti.i, 3)