On 01/11/2012 03:25 PM, Raymond N. Greenwell wrote:
Adding "format='adjacency_matrix') doesn't change anything.
I still don't understand why the rank function isn't working on this
Hasse diagram and how to make it work. It works fine in the example on
the page I quoted.
I disagree about the arrow from 0 to 2. Yes, there is such an arrow in
the digraph, but this should not appear in the Hasse diagram because 0
does not cover 2 since there is an arrow from 0 to 1 and from 1 to 2.
Ok, I see what you mean. HasseDiagram() isn't creating a Hasse diagram
for the DiGraph you give it; rather, when you call HasseDiagram(d)
you're saying "create me a HasseDiagram object with the underlying data d."
And you can create a HasseDiagram object from any old DiGraph, the input
isn't checked. In this case, the data that you're giving it isn't really
a Hasse diagram: as you say, it's got an arrow from 0 to 2 where it
shouldn't. That's why the rank function doesn't work -- there can be no
rank function defined for the underlying DiGraph.
I think what you want is to call hasse_diagram() on a Poset object:
sage: m = Matrix([[0,1,1],[0,0,1],[0,0,0]])
sage: d = DiGraph(m)
sage: p = Poset(d)
sage: h = p.hasse_diagram()
sage: h.cover_relations()
[(1, 2), (0, 1)]
However I'm not having much luck beyond that! I hit problems right away
trying to skip the DiGraph(m) step:
sage: p = Poset(m)
...
TypeError: BUG: D should be a digraph.
and the resulting diagram doesn't let me do much with it:
sage: h.show()
...
AttributeError: 'int' object has no attribute 'parent'
sage: h.rank(0)
...
KeyError: 0
sage: h.rank(1)
...
KeyError: 1
sage: h.rank(2)
...
KeyError: 2
I'm figuring this out as I go, so I might have done something wrong.
These could be bugs though. Any combinat people know?
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org