[Up] [Previous] [Next] [Index]

# 8.3 An Example

This section shows how to use the poset package to display posets. The code presented here is actually part of the XGAP library and makes up the link to the C MeatAxe.

This is the declaration part:

    #############################################################################
    ##
    #W  meataxe.gd                  XGAP library                  Max Neunhoeffer
    ##
    #Y  Copyright 1998,       Max Neunhoeffer,              Aachen,       Germany
    ##
    ##  This file contains declarations for MeatAxe posets
    ##

    DeclareFilter("IsMeatAxeLattice");

    #############################################################################
    ##
    #O  GraphicMeatAxeLattice(<name>, <width>, <height>)  . creates graphic poset
    ##
    ##  creates a new graphic MeatAxe lattice which is a specialization of a
    ##  graphic poset. Those posets have a new filter for method selection.
    ##
    DeclareOperation("GraphicMeatAxeLattice",[IsString, IsInt, IsInt]);

The code only declares a new filter and declares a constructor operation for posets that lie in this new filter.

The implementation:

    #############################################################################
    ##
    #W  meataxe.gi                  XGAP library                  Max Neunhoeffer
    ##
    #Y  Copyright 1998,       Max Neunhoeffer,              Aachen,       Germany
    ##
    ##  This file contains code for MeatAxe posets
    ##

    #############################################################################
    ##
    #M  GraphicMeatAxeLattice(<name>, <width>, <height>)  . creates graphic poset
    ##
    ##  creates a new graphic MeatAxe lattice which is a specialization of a
    ##  graphic poset. Those posets have a new filter for method selection.
    ##
    InstallMethod( GraphicMeatAxeLattice,
        "for a string, and two integers",
        true,
        [ IsString,
          IsInt,
          IsInt ],
        0,

    function( name, width, height )
      local P;

      P := GraphicPoset(name,width,height);
      SetFilterObj(P,IsMeatAxeLattice);
      return P;
    end);

    #############################################################################
    ##
    #M  CompareLevels(<poset>,<levelparam1>,<levelparam2>)  . . . . . . . . . . .
    ##  . . . . . . . . . . . . . . . . . . . . . . . .  compares two levelparams
    ##
    ##  Compare two level parameters. -1 means that <levelparam1> is "higher",
    ##  1 means that <levelparam2> is "higher", 0 means that they are equal.
    ##  fail means that they are not comparable. This method is for the case
    ##  if level parameters are integers and lower values mean lower levels
    ##  like in the case of MeatAxe lattices of Michael Ringe.
    ##
    InstallMethod( CompareLevels,
        "for a graphic MeatAxe lattice, and two integers",
        true,
        [ IsGraphicPosetRep and IsMeatAxeLattice, IsInt, IsInt ],
        0,
    function( poset, l1, l2 )
      if l1 < l2 then
        return 1;
      elif l1 > l2 then
        return -1;
      else
        return 0;
      fi;
    end);

Besides the new constructor (which only adds a new filter) we only have to supply a new method for comparison of level parameters for such posets. The levels are numbered with integer numbers such that lower numbers are lower in the lattice.

There is a C program in the MeatAxe that exports a poset to a GAP program which generates the lattice in a graphic poset sheet. The user can then interactively move around vertices and shrink or magnify levels. He can then export the resulting lattice to an encapsulated postscript file. Note that you need a full installation of the C MeatAxe apart from GAP to use this feature.

Another nice little example is in the `examples` subdirectory in the XGAP distribution. It was written by Thomas Breuer (Aachen) to demonstrate the features of XGAP. The user gets a small window with a puzzle and can solve it using the mouse. You can test this example by starting XGAP and `Read`ing the file `pkg/xgap/examples/puzzle.g`. You can do this by using

    gap> ReadPkg("xgap","examples/puzzle.g");
    gap> p := Puzzle(4,4);

[Up] [Previous] [Next] [Index]