<html><head><title>[xgap] 8.3 An Example</title></head> <body text="#000000" bgcolor="#ffffff"> [<a href = "C008S000.htm">Up</a>] [<a href ="C008S002.htm">Previous</a>] [<a href ="C009S000.htm">Next</a>] [<a href = "theindex.htm">Index</a>] <h1>8.3 An Example</h1><p> <p> 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. <p> This is the declaration part: <p> <pre> ############################################################################# ## #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]); </pre> <p> The code only declares a new filter and declares a constructor operation for posets that lie in this new filter. <p> The implementation: <p> <pre> ############################################################################# ## #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); </pre> <p> 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. <p> There is a C program in the MeatAxe that exports a poset to a <font face="Gill Sans,Helvetica,Arial">GAP</font> 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 <font face="Gill Sans,Helvetica,Arial">GAP</font> to use this feature. <p> Another nice little example is in the <code>examples</code> 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 <code>Read</code>ing the file <code>pkg/xgap/examples/puzzle.g</code>. You can do this by using <p> <pre> gap> ReadPkg("xgap","examples/puzzle.g"); gap> p := Puzzle(4,4); </pre> <p> <p> [<a href = "C008S000.htm">Up</a>] [<a href ="C008S002.htm">Previous</a>] [<a href ="C009S000.htm">Next</a>] [<a href = "theindex.htm">Index</a>] <P> <address>xgap manual<br>Mai 2003 </address></body></html>