Check if all non-zero elements in a matrix are connected Input:

A matrix containing integers in the range [0 - 9].

Challenge:

Determine if all non-zero elements are connected to each other vertically and/or horizontally.

Output:

A truthy value if all are connected, and a falsy value if there are non-zero elements/groups that aren't connected to other elements/groups.

Test cases:

Test cases are separated by line. Test cases can be found in more convenient formats here (Kudos to Dada).

The following are all connected and should return a truthy value:

0
--- 
0 0
---
1 1 1
0 0 0
---
1 0 0
1 1 1
0 0 1
---
0 0 0 0 0 0
0 0 3 5 1 0
0 1 0 2 0 1
1 1 0 3 1 6
7 2 0 0 3 0
0 8 2 6 2 9
0 0 0 0 0 5


The following are all not-connected, and should return a falsy value:

0 1
1 0
---
1 1 1 0
0 0 0 2
0 0 0 5
---
0 0 5 2
1 2 0 0
5 3 2 1
5 7 3 2
---
1 2 3 0 0 5
1 5 3 0 1 1
9 0 0 4 2 1
9 9 9 0 1 4
0 1 0 1 0 0


This is code-golf, so the shortest submission in each language wins. Explanations are encouraged!



Inspired by this challenge.
Retina 0.8.2, 80 77 bytes

T`d`@1
1`1
_
+m`^((.)*)(1|_)( |.*¶(?&lt;-2&gt;.)*(?(2)(?!)))(?!\3)[1_]
$1_$4_
^\D+$


Try it online! Edit: Saved 1 byte thanks to @FryAmTheEggman. Explanation:

T`d`@1


Simplify to an array of @s and 1s.

1`1
_


Change one 1 to a _.

+m`^((.)*)(1|_)( |.*¶(?&lt;-2&gt;.)*(?(2)(?!)))(?!\3)[1_]
$1_$4_


Flood fill from the _ to adjacent 1s.

^\D+$


Test whether there are any 1s left.