Ask Your Question

Revision history [back]

Plotting a LabelledOrderedTree with duplicate labels

I'm attempting to plot a labelled, ordered, rooted tree in Sage using the LabelledOrderedTree class. Here is what I have so far:

sage: n2 = LabelledOrderedTree([], label=2)
sage: n1 = LabelledOrderedTree([], label=1)
sage: root = LabelledOrderedTree([n2, n1], label=1)
sage: root
1[2[], 1[]]

At this point, I've created the tree I'm attempting to build, but here is where I run into problems:

sage: P = root.plot()
...
sage/graphs/base/sparse_graph.pyx in sage.graphs.base.sparse_graph.SparseGraphBackend.add_edge (build/cythonized/sage/graphs/base/sparse_graph.c:17158)()

ValueError: cannot add edge from 1 to 1 in graph without loops

Is there a way to plot a LabelledOrderedTree object when multiple nodes share the same label?

click to hide/show revision 2
retagged

Plotting a LabelledOrderedTree with duplicate labels

I'm attempting to plot a labelled, ordered, rooted tree in Sage using the LabelledOrderedTree class. Here is what I have so far:

sage: n2 = LabelledOrderedTree([], label=2)
sage: n1 = LabelledOrderedTree([], label=1)
sage: root = LabelledOrderedTree([n2, n1], label=1)
sage: root
1[2[], 1[]]

At this point, I've created the tree I'm attempting to build, but here is where I run into problems:

sage: P = root.plot()
...
sage/graphs/base/sparse_graph.pyx in sage.graphs.base.sparse_graph.SparseGraphBackend.add_edge (build/cythonized/sage/graphs/base/sparse_graph.c:17158)()

ValueError: cannot add edge from 1 to 1 in graph without loops

Is there a way to plot a LabelledOrderedTree object when multiple nodes share the same label?