# See Networkx's docuemntation -- https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.tree.coding.from_prufer_sequence.htmlimportnetworkxasnxfromsage.graphs.graph_inputimportfrom_networkx_graph
In [2]:
# Convert Prufer code to a treecode=[i-1foriin[6,6,4,3,1,4,3]]# In networkx, node-labeling starts with 0g_nx=nx.from_prufer_sequence(code)list(g_nx.edges())