What you ask for is an unsolvable problem, because it depends on the embedding of the graph in the plane (or space). Consider the following graphs:

     ![enter image description here][1]     
![enter image description here][2]

They are isomorphic, and described by the same node-edge incidence matrix, but you want different answers for them.

You need to specify a planar embedding (i.e., coordinates for the vertices) for this to work.


  [1]: https://i.sstatic.net/ESCt6.png
  [2]: https://i.sstatic.net/WX3NY.png