On 01/10/2012 11:37 AM, Raymond N. Greenwell wrote:
Hello everyone!

I tried using the HasseDiagram and rank features of Sage as described
on
http://www.sagemath.org/doc/reference/sage/combinat/posets/hasse_diagram.html

 Things worked ok, but when I then tried: m=
Matrix([[0,1,1],[0,0,1],[0,0,0]]) g = DiGraph(m) h2 =
HasseDiagram(g) h2.rank(2)

I got the message:

...

Please tell me what this means and how I can get rank working
properly.

This is a bad error message. The code is doing this:

  self.rank_function()(element)

But the "rank_function" method can return None:

  def rank_function(self):
    r"""
    Returns a rank function of the poset, if it exists.
    ...

So, sage can't come up with a rank function, and the error you got is the result of trying to evaluate None(2).


Also, I have a complaint about HasseDiagram, in that for the matrix
above, it draws a link from 0 to 1, from 1 to 2, and from 0 to 2. In
the usual definition of a Hasse diagram, the link from 0 to 2
shouldn't show, since 0>  1>  2. (I'm referring to the nodes;
obviously the previous inequalities are nonsense numerically.) (For
example, see http://mathworld.wolfram.com/HasseDiagram.html
and http://mathworld.wolfram.com/CoverRelation.html.)

Sage is drawing the diagram correctly (this is why it can't find a rank function), you just don't have the DiGraph that you think you should have.

We could do a lot better here -- I had to read the source for DiGraph.__init__ -- but it looks like when you called DiGraph(m), it considered 'm' to be an adjacency matrix.

    [0,1,1]
m = [0,0,1]
    [0,0,0]

That means that there's an arrow from,

  row -> column
  -------------
  0   -> 1
  0   -> 2
  1   -> 2

So that explains why you have the Hasse diagram that you have. Getting the one that you actually want probably just requires a different matrix.

--
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

Reply via email to