Function iteration

I wrote a function in Mathematica that applies certain construction steps on the "incidence matrix" of a graph in order to obtain a new graph with certain properties. These construction steps can be iterated and here is the point where I fail. If I write something like

Henneberg1[Henneberg1[{{{1,1,1,1}}},a,b],c,d]

I get a weird error of the following form: Now to the implementation:

Henneberg1[mats_, a_, b_] := ...

The first parameter mats_ describes a set of (incidence) matrices where a and b are only placeholders for variables to be added. If I evaluate Henneberg1[{{{1,1,1,1}}},a,b] I retrieve

$$\{\begin{pmatrix} 1 & 1 & 1 & 1 & 0 & 0 \\ a & 1 & 0 & 0 & -a & -1 \\ 0 & 0 & b & 1 & -b & -1 \end{pmatrix}\}$$

Directly passing the result as argument for Henneberg1 then works as desired, but I am not able to iterate in the way described above.

The actual implementation of Henneberg1 can be found here, but is quite a mess, so sorry for that. (What it actually does can be found here (1.))

If someone knows where the problem lies I would really appreciate that.

• Henneberg1 get List as the input and outputs MatrixForm. you may want to do Henneberg1[List @@ First@Henneberg1[{{{1, 1, 1, 1}}}, a, b], c, d] – Xminer Jun 26 at 11:56
• This solves my problem. Thank you very much @Xminer! – bohnanza Jun 26 at 12:10
• you're welcome. – Xminer Jun 26 at 12:19
• General tip: never use MatrixForm in functions that do computations. Only use it as an afterthought (//) to print matrices to your notebook. E.g., Henneberg1[{{{1,1,1,1}}},a,b] // MatrixForm. All functions that end in Form are meant for output formatting only, not for use in intermediate results. – Sjoerd Smit Jun 26 at 12:58