- Choose a walkable node.
- Flood-fill it. Any square not filled is not reachable from the chosen square.
- Repeat the above with another unfilled walkable node to find another separated region.
If you do this completely, you will have a list of connected regions of the map (a partition of it into connected components).
If your map is static, you only need to do this once. Otherwise, it's still not hard: If a node becomes unwalkable, rerun just on the component containing it and you may find you have two components. If a node becomes walkable, then if if it has immediate neighbors from two different components, combine them.