I'm looking for code that produces all possible trees with no self edges (or their adjacent matrices) with n nodes, anyone have any idea if this is written anywhere?
closed as off topic by Harry Gindi, Igor Pak, Felipe Voloch, Mark Sapir, Andy Putman Jan 18 '11 at 17:14Questions on MathOverflow are expected to relate to research level mathematics within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here. If this question can be reworded to fit the rules in the help center, please edit the question. 


In sage the command list(graphs.trees(9)) produces a list of all trees on 9 vertices. As sage is open source, the code is available for inspection. The command [tt.am() for tt in graphs.trees(9)] will provide the adjacency matrices. 


It is well known that there is a bijection between the set of trees on $n$ nodes and sequences of length $n2$ with values in $[n]$. These sequences are called Prüfer sequences. Indeed, the wikipedia page has code which will convert any Prüfer sequence into a tree. So a naïve algorithm would be to run the wikipedia algorithm over all Prüfer sequences. 

