Is there a way to find if segments share boundaries using findCountours?

I’m using OpenCV to implement the algorithm proposed by HK Chu et al. in Camouflage Images and a big part of it is creating a graph that connects the segments of the background and foreground, for that I need to find segments that share boundaries, is it possible to find it using findCountours or not using an exhaustive method?