Anyone has the logic for the following puzzle
I have an n*n matrix. 
Each vertex has a degree associated with it. Degree is the number of lines that can be drawn to its neighbouring vertices. 
I am generating an array containing degrees of each vertex.
For example, array {1,2,2,1} implements the following two solutions.

![enter image description here][1]

solution 1

![solution 2][2]

solution 2

what i want is, when i get the array i want to know whether it has one solution or more than one solution.

This is another example {0, 3, 1, 2, 4, 2, 2, 1, 3} has more than one solutions.


  [1]: http://i.stack.imgur.com/NS8Lc.png
  [2]: http://i.stack.imgur.com/Ppckd.png
Anyone has the logic for the following puzzle
===

I have an n*n matrix. 
Each vertex has a degree associated with it. Degree is the number of lines that can be drawn to its neighbouring vertices. 
I am generating an array containing degrees of each vertex.
For example, array {1,2,2,1} implements the following two solutions.

![enter image description here][1]

solution 1

![solution 2][2]

solution 2

what i want is, when i get the array i want to know whether it has one solution or more than one solution.

This is another example {0, 3, 1, 2, 4, 2, 2, 1, 3} has more than one solutions.


  [1]: http://i.stack.imgur.com/NS8Lc.png
  [2]: http://i.stack.imgur.com/Ppckd.png