As I said in my comment, the mathematical way to solve this kind of problem relies on Graph Theory. This article (Applications of Graph Theory in Chemistry, preprint) reviews the problem and further more.
If you google 'isomer' and 'graph theory' you will find anything you want about this exciting topic. But for generic question, there is no generic answer. It is about building all possible graphs or find out inherent properties inside them. You cannot answer to this question unless it is well-defined and properly bounded.
If you have such question, please rewords it and post it on Mathematical Exchange. This should give you fine grained answer. If you just wanted to understand how it works, welcome to the fabulous world of Graph Theory, you will have to learn a bit to answer it by yourself.