ó ŸÃÒYc@s|dZdjddgƒZddgZddlZdd „Zd „Zdd „Z d „Z d „Z d„Z d„Z dS(s Implementation of the Wright, Richmond, Odlyzko and McKay (WROM) algorithm for the enumeration of all non-isomorphic free trees of a given order. Rooted trees are represented by level sequences, i.e., lists in which the i-th element specifies the distance of vertex i to the root. s sAric Hagberg (hagberg@lanl.gov)s#Mridul Seth (seth.mridul@gmail.com)tnonisomorphic_treestnumber_of_nonisomorphic_treesiÿÿÿÿNtgraphccs¼|dkrt‚ntt|ddƒƒttd|ddƒƒ}xk|dk r·t|ƒ}|dk rM|dkr‹t|ƒVn|dkr¥t|ƒVnt|ƒ}qMqMWdS(sµReturns a list of nonisomporphic trees Parameters ---------- order : int order of the desired tree(s) create : graph or matrix (default="Graph) If graph is selected a list of trees will be returned, if matrix is selected a list of adjancency matrix will be returned Returns ------- G : List of NetworkX Graphs M : List of Adjacency matrices References ---------- iiRtmatrixN(t ValueErrortlisttrangetNonet _next_treet_layout_to_grapht_layout_to_matrixt_next_rooted_tree(tordertcreatetlayout((s}/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/generators/nonisomorphic_trees.pyRs  5    cCstd„t|ƒDƒƒS(sùReturns the number of nonisomorphic trees Parameters ---------- order : int order of the desired tree(s) Returns ------- length : Number of nonisomorphic graphs for the given order References ---------- css|] }dVqdS(iN((t.0t_((s}/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/generators/nonisomorphic_trees.pys Os(tsumR(R ((s}/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/generators/nonisomorphic_trees.pyR?scCsÉ|dkr@t|ƒd}x!||dkr<|d8}qWn|dkrPdS|d}x&||||dkr‚|d8}q]Wt|ƒ}x3t|t|ƒƒD]}||||||s     '   '