Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I think I found another solution using Posets:

n=4
P=Posets(n)
U=[p for p in P if p.is_connected() and ((p.hasse_diagram()).to_undirected()).is_tree()]
UU=[p for p in U if max((p.hasse_diagram()).out_degree_sequence())<=2 and max((p.hasse_diagram()).in_degree_sequence())<=2]
[display(t) for t in UU]
display(len(U))
display(len(UU))

The list U answers the question (I hope) and the list UU is a sublist of U with all indegrees and outdegrees at most 2.