Recurrences and Algorithm for Counting and Generating Circuit Layouts