say I have an adjacency matrix in csr format:

```
row = np.array([0, 0, 1, 3, 2, 2,3,4,4])
col = np.array([0, 4, 2, 2, 3, 1,4,0,3])
data = np.array([1]*len(row))
X= sp.csr_matrix((data, (row, col)), shape=(5, 5))

print(X)
  (0, 0)    1
  (0, 4)    1
  (1, 2)    1
  (2, 1)    1
  (2, 3)    1
  (3, 2)    1
  (3, 4)    1
  (4, 0)    1
  (4, 3)    1

print(X.todense())
[[1 0 0 0 1]
 [0 0 1 0 0]
 [0 1 0 1 0]
 [0 0 1 0 1]
 [1 0 0 1 0]]

```

i have a list of the nodes i want to keep, say nodes 1 and 2 `keep = [1,2]`
how would i keep all the indices in X that are in the list "keep" ?
For example, I want to end up with all indices whose row or col is in the list keep:

```
  (1, 2)    1
  (2, 1)    1
  (2, 3)    1
  (3, 2)    1

```

`X[keep]` only returns the rows 1,2:

```
print(X[keep].todense())
[[0 0 1 0 0]
 [0 1 0 1 0]]

```

but i can see that node 2, interacts with nodes 1 and nodes 3; therefore, i want to return an adjacency matrix that reflects the bi-directional connections of the subset adjacency matrix:

```
[[0 0 1 0 0]
 [0 1 0 1 0]
 [0 0 1 0 0*]

```

The 0\* represents the fact that because i'm only interested in node 1 (only interacts with node 2) and node 2 (interacts with nodes 1 and 3), then despite in the original matrix we observe node 3 interacting with nodes 2 and 4, node 4 isn't in the list to keep so we ignore it. Hence want to end up with something like:

```
  (1, 2)    1
  (2, 1)    1
  (2, 3)    1
  (3, 2)    1

```

...I realize, after the edits to this question to try to clarify what i'm trying to do, it may not be so simple a solution, but i am still unsure on how to approach it.