3x3 Connected Components The Challenge

Consider the 3x3 king grid, as shown in the following ASCII graphic:

A--B--C
|\/|\/|
|/\|/\|
D--E--F
|\/|\/|
|/\|/\|
G--H--I


You are given as input a length-9 list of integers that represent a labeling of the nodes. For example, the input [0,1,1,2,1,0,5,5,1] represents the following labeling:

0--1--1
|\/|\/|
|/\|/\|
2--1--0
|\/|\/|
|/\|/\|
5--5--1


Your output is the set of integers in the input that form connected sets of nodes. More explicitly, the output should contain an integer n from the input if and only if the set of nodes with label n is connected. In this example, an acceptable output would be [1,2,5], since the two 0s are not connected. The lowest byte count wins.

Detailed rules


You can choose a fixed ordering for the nodes in your input list, and you should state this in your answer. In the order EFBDHCAGI, the above labeling would be given as [1,0,1,2,5,1,0,5,1].
You can write either a full program or a function. In the latter case, the output can be a set of integers if your language supports those.
The output list may contain duplicates, but its length must not exceed 9.
Standard loopholes are disallowed.


Test cases

These have single-digit numbers aligned to the grid; adjust them to your chosen order.

011
210 =&gt; 1 2 5
551

010
202 =&gt; 0 2
221

110
123 =&gt; 0 2 3
221

111
111 =&gt; 1
111

111
141 =&gt; 1 4
111
J, 54 bytes

#~3 :'0&lt;*/,+/ .*/^:8~y#|:y#,/,"1/({0&amp;,:)3 3$#:13'"1@e.


A function taking a list in the order ABCDEFGHI.



Given an adjacency matrix A of a graph of order n, the graph is connected if and only if all the entries of (A + I)n are nonzero, where I is the n×n identity matrix.

We start with the (fixed) adjacency-plus-identity matrix of the 3×3 king grid (in the order ABCDEFGHI,) namely:

1 1 0 1 1 0 0 0 0
1 1 1 1 1 1 0 0 0
0 1 1 0 1 1 0 0 0
1 1 0 1 1 0 1 1 0
1 1 1 1 1 1 1 1 1
0 1 1 0 1 1 0 1 1
0 0 0 1 1 0 1 1 0
0 0 0 1 1 1 1 1 1
0 0 0 0 1 1 0 1 1


.
For each label l, we select the rows and columns corresponding to the nodes of label l.
This gives us the adjacency-plus-identity matrix of the subgraph of l-labeled nodes.
We then use this matrix to test if the subgraph is connected, as described above.

We construct the above matrix by noting that if we let

    0 0 0
Z = 0 0 0
    0 0 0


and

    1 1 0
O = 1 1 1
    0 1 1


, then the matrix can be seen as the 3×3 block matrix

O O Z
O O O
Z O O


, which has the same pattern as O!
O is produced by repeating the pattern 1 1 0 1 in a 3×3 block.