It appears that you are looking for simple cycles in a bipartite graph.
I have no immediate solution, but you might find it useful to conduct a
search using these terms.
If you are only concerned with situations where every microphone is
collected to every speaker then the problem is much simpler. Each simple
cycle of length n from a given microphone can be specified as a list of
n/2 + 1 microphones and a list of n/2 speakers. The first and last
microphones are the same, so the number of distinct cycles of length n
is equal to the number of ways you can list n/2 (of say M) microphones
and n/2 (of say S) speakers.
C(M,n/2) * (n/2)! * C(S,n/2) * (n/2)!
# with a little Python / gmpy
>>> import gmpy
>>> def numcycles(n, M, S):
if n % 2 == 1:
return 0
return gmpy.comb(M,n/2) * gmpy.fac(n/2) * gmpy.comb(S,n/2) * gmpy.fac(n/2)
>>> cycles = [int(numcycles(n,8,8)) for n in range(20)]
>>> cycles
[1, 0, 64, 0, 3136, 0, 112896, 0, 2822400, 0, 45158400, 0, 406425600, 0,
1625702400, 0, 1625702400, 0, 0, 0]
How you want to interpret the single path for n = 0 is up to you
(range(20) is a list of integers from 0 to 19).
Other questions can be answered in a similar fashion (i.e. with
reference to 2 lists and the number of choices available for them given
any constraints).
Duncan