GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
% This file was created automatically from posetops.msk.1% DO NOT EDIT!2\Chapter{Graphic Posets}34This chapter describes the part of {\XGAP} that allows the user to5conveniently display posets graphically.67%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%8\Section{Introduction}910A poset is just a partially ordered set. To display posets11reasonably in a generic way we need additional structure. So for {\XGAP} a12poset comes in so called levels. At all times in the life of a graphic13poset there are only finitely many levels and they are totally ordered,14that is for two levels we can always say, which one is ``higher''. The15position within the graphic sheet reflects this ordering.1617The levels are parametrized by ``level parameters'', which can be any18{\GAP} object but must be unique within a graphic poset. A level is always19accessed by its level parameter and *not* by its number!2021The vertices in each level are grouped into classes. For example for22graphic subgroup lattices vertices in the same class correspond to conjugate23subgroups, vertices in the same level have the same size or index in the24whole group. The classes within each level are parametrized by ``class25parameters'', which can be any {\GAP} object but must be unique within a26level. A class within a level is always accessed by its class parameter and27*not* by its number!2829The user must supply a *partial order* for all of his levels. The mechanism30to achieve this is the operation `CompareLevels', which compares two level31parameters. The current *total order* of the levels is always a refinement32of the partial order. The user can permute levels, if that does not33contradict the partial order defined by `CompareLevels'.3435A vertex in the poset that is ``contained in'' another vertex in the poset36order (we speak of ``inclusion'' like in the case of subgroup lattices)37must always be in a level that is lower on the screen, because there38is only a connecting line representing the inclusion. This is achieved by39the fact, that inclusions of vertices are communicated to {\XGAP} just by40creating an ``edge'' between them. This means, that the vertex in the41``lower'' level lies in the vertex in the ``higher'' level. There must not42be edges between vertices in the same level!4344The terminology ``vertices'' and ``edges'' comes from the fact, that a45graphic poset is just a special case of a graphic graph, where vertices can46be placed anywhere in the sheet and edges have nothing to do with47inclusion. It is planned that also a graphic graph library is implemented48in {\XGAP} but it is not yet operational. However everything which could be49done not only for posets but at the same time for graphs is implemented50already within the poset package. This explains the usage of ``graph'' in51many places where you would otherwise expect ``poset''.5253What you have to do to use the graphic poset package is create a graphic54poset (a special instance of a graphic sheet), create some levels and55perhaps classes within them. Then you can create vertices and edges, to56encode the ordering. Everything else is done by the library. See the next57section for details about the available operations.5859Note that we chose a functional approach for certain decision60procedures. This means that for example if you create a vertex and do not61specify a position, an operation (`ChoosePosition') is called to determine62the actual position. You can use the generic routines or install your own63methods for all of those decisions. In this case you just set a new filter64for your posets and overload the generic methods by special routines for65objects with your new filter set. You can see this approach in the example66in "An Example".6768%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%69\Section{Operations}7071*Constructors:*7273\medskip%74\>GraphicPoset( <name>, <width>, <height> ) O7576creates a new graphic poset which is a specialization of a graphic graph77mainly because per definition a poset comes in ``levels'' or ``layers''.78This leads to some algorithms that are more efficient than the general79ones for graphs.808182\>CreateLevel( <poset>, <levelparam> ) O83\>CreateLevel( <poset>, <levelparam>, <lptext> ) O8485A level in a graphic poset can be thought of as a horizontal slice of86the poset. It has a y coordinate of the top of the level relatively to87the graphic sheet and a height. Every class of vertices in a graphic88poset is in a level. The levels are totally ordered by their y89coordinate. No two vertices which are included in each other are in the90same level. A vertex containing another one is always ``higher'' on the91screen, meaning in a ``higher'' level. Every level has a unique level92parameter, which can be any {\GAP} object. The user is responsible for all93methods where a level parameter occurs as parameter and is not just an94integer. There is NO {\GAP} object representing a level which is visible95for the user of posets. All communication about levels goes via the96level parameter. `CreateLevel' creates a new level with level parameter97<levelparam> in the graphic poset <poset>. It returns `fail' if there98is already a level with a level parameter which is considered ``equal''99to <levelparam> by `CompareLevels' or <levelparam> if everything went100well.101102The second method allows to specify which text appears for the level at103the right edge of the sheet.104105106\>CreateClass( <poset>, <levelparam>, <classparam> ) O107108A class in a graphic poset is a collection of vertices within a level109which belong together in some sense. Every vertex in a graphic poset110is in a class, which in turn belongs to a level. Every class in a level111has a unique class parameter, which can be any {\GAP} object. The user is112responsible for all methods where a class parameter occurs as parameter113and is not just an integer. There is NO {\GAP} object representing a class114which is visible to the user of posets. All communication about classes115goes via the class parameter. `CreateClass' creates a new class in the116level with level parameter <levelparam> in the graphic poset117<poset>. It returns `fail' if there is no level with level parameter118<levelparam> or there is already a class in this level with class119parameter <classparam>. `CreateClass' returns <classparam> otherwise.120121122\>`Vertex( <graph>, <data>[, <inf>] )'{Vertex![poset]}@{`Vertex'!`[poset]'} O123124Creates a new vertex. <inf> is a record in which additional info can be125supplied for the new vertex. For general graphic graphs only the126`label', `color', `shape', `x' and `y' components are applicable, they127contain a short label which will be attached to the vertex, the color,128the shape (`circle', `diamond', or `rectangle') and the coordinates129relative to the graphic sheet respectively. For graphic posets also the130components `levelparam' and `classparam' are evaluated. If the component131`hints' is bound in <inf> it must be a list of x coordinates which will be132delivered to `ChoosePosition' to help placement. Those x coordinates will133be the coordinates of other vertices related to the new one. All values of134record components which are not specified will be determined by calling135some methods for graphic graphs or posets. Those are:136`ChooseLabel' for the label,137`ChooseColor' for the color,138`ChooseShape' for the shape,139`ChoosePosition' for the position,140`ChooseLevel' for the level parameter,141`ChooseClass' for the class parameter, and142`ChooseWidth' for the line width of the vertex.143`Vertex' returns `fail' if no vertex was created. This happens only, if144one of the choose functions return `fail' or no possible value, for145example a non-existing level or class parameter. `Vertex' returns a146vertex object if everything went well.147148149\>Edge( <graph>, <vertex1>, <vertex2> ) O150\>Edge( <graph>, <vertex1>, <vertex2>, <defaults> ) O151152Adds a new edge from <vertex1> to <vertex2>. For posets this puts one153of the vertices into the other as a maximal subvertex. So either154<vertex1> must lie in a ``higher'' level than <vertex2> or the other way155round. There must be no vertex ``between'' <vertex1> and <vertex2>. If156the two vertices are in the same level or one is already indirectly157included in the other `fail' is returned, otherwise `true'. That means,158that in the case where one of the two vertices is already a maximal159subobject of the other, then the method does nothing and returns `true'.160The variation with a <defaults> record just hands this over to the lower161levels, meaning that the line width and color are modified.162163164165*Destructors:*166167\medskip%168\>Delete( <poset>, <vertex1>, <vertex2> )!{for edge in poset}169\>Delete( <poset>, <vertex1>)!{for vertex in poset}170\>Delete( <poset>, <levelparam>, <classparam> )!{for class in poset}171172These three variants of the `Delete' operation delete an edge, a vertex and173a class respectively.174175\>DeleteLevel( <poset>, <levelparam> ) O176177The following method applies to a level. It returns `fail' if no level178with level parameter <levelparam> is in the poset. Otherwise the level179is deleted and all classes within it are also deleted! `DeleteLevel'180returns `true' if the level is successfully deleted.181182183184\medskip%185*Operations to change a poset:*186\medskip%187\>ResizeLevel( <poset>, <levelparam>, <height> ) O188189Changes the height of a level. The y coordinate can only be changed by190permuting levels, see below.191Attention: This can increase the size of the sheet!192Returns `fail' if no level with level parameter <levelparam> exists and193`true' otherwise.194195196\>MoveLevel( <poset>, <levelparam>, <position> ) O197198Moves a level to another position. <position> is an absolute index in199the list of levels. The level with level parameter <levelparam> will be200at the position <position> after the operation. This is only allowed if201the new ordering is compatible with the partial order given by202`CompareLevels' and if there is no connection of a vertex in the moving203level with another level with which it is interchanged. So204<levelparam> is compared with all level parameters between the old and205the new position. If there is a contradiction, nothing happens and the206method returns `fail'. If everything works the operation returns207`true'.208209210\>`Relabel( <graph>, <vertex>, <label> )'{Relabel![poset]}@{`Relabel'!`[poset]'} O211\>`Relabel( <graph>, <vertex> )'{Relabel![poset]}@{`Relabel'!`[poset]'} O212\>`Relabel( <poset>, <vertex1>, <vertex2>, <label> )'{Relabel![poset]}@{`Relabel'!`[poset]'} O213\>`Relabel( <poset>, <vertex1>, <vertex2> )'{Relabel![poset]}@{`Relabel'!`[poset]'} O214215Changes the label of the vertex <vertex> or the edge between <vertex1>216and <vertex2>. This must be a short string. In the method where no217label is specified the new label is chosen functionally: the operation218`ChooseLabel' is called. Returns `fail' if an error occurs and `true'219otherwise. This operation already exists in {\XGAP} for graphic220objects.221222223\>`Move( <graph>, <vertex>, <x>, <y> )'{Move![poset]}@{`Move'!`[poset]'} O224\>`Move( <graph>, <vertex> )'{Move![poset]}@{`Move'!`[poset]'} O225226Moves vertex <vertex>. For posets coordinates are relative to the level227of the vertex. <vertex> must be a vertex object in <graph>. If no228coordinates are specified the operation `ChoosePosition' is229called. `Move' returns `fail' if an error occurs and `true' otherwise.230This operation already exists in {\XGAP} for graphic objects.231232233\>`Reshape( <graph>, <vertex> )'{Reshape![poset]}@{`Reshape'!`[poset]'} O234\>`Reshape( <graph>, <vertex>, <shape> )'{Reshape![poset]}@{`Reshape'!`[poset]'} O235236Changes the shape of the vertex <vertex>. <vertex> must be a vertex237object in the graph or poset <graph>. For the method where no shape is238specified the new shape is chosen functionally: `ChooseShape' is called239for the corresponding data. `Reshape' returns `fail' if an error240occurs and `true' otherwise. This operation already exists in {\XGAP}241for graphic objects.242243244\>`Recolor( <graph>, <vertex> )'{Recolor![poset]}@{`Recolor'!`[poset]'} O245\>`Recolor( <graph>, <vertex>, <color> )'{Recolor![poset]}@{`Recolor'!`[poset]'} O246\>`Recolor( <poset>, <vertex1>, <vertex2>, <color> )'{Recolor![poset]}@{`Recolor'!`[poset]'} O247\>`Recolor( <poset>, <vertex1>, <vertex2> )'{Recolor![poset]}@{`Recolor'!`[poset]'} O248249Changes the color of the vertex <vertex> or the edge between <vertex1>250and <vertex2>. <vertex> must be a vertex object in <graph>. For the251method where no color is specified the new color is chosen252functionally: `ChooseColor' is called for the corresponding253data. `Recolor' returns `fail' if an error occurs and `true'254otherwise. This operation already exists in {\XGAP} for graphic objects.255256257\>`SetWidth( <graph>, <vertex1>, <vertex2>, <width> )'{SetWidth![poset]}@{`SetWidth'!`[poset]'} O258\>`SetWidth( <graph>, <vertex1>, <vertex2> )'{SetWidth![poset]}@{`SetWidth'!`[poset]'} O259260Changes the line width of an edge. <vertex1> and <vertex2> must be261vertices in the graph <graph>. For the method where no line width is262specified the width is chosen functionally: `ChooseWidth' is called for263the corresponding data pair. Returns `fail' if an error occurs and264`true' otherwise. This operation already exists in {\XGAP} for graphic265objects.266267268\>`Highlight( <graph>, <vertex> )'{Highlight![poset]}@{`Highlight'!`[poset]'} O269\>`Highlight( <graph>, <vertex>, <flag> )'{Highlight![poset]}@{`Highlight'!`[poset]'} O270271Changes the highlighting status of the vertex <vertex>. <vertex> must272be a vertex object in <graph>. For the method where no flag is273specified the new status is chosen functionally: `ChooseHighlight' is274called for the corresponding data. Returns `fail' if an error occurs275and `true' otherwise. This operation already exists in {\XGAP} for276graphic objects.277278279\>Select( <graph>, <vertex>, <flag> ) O280\>Select( <graph>, <vertex> ) O281282Changes the selection state of the vertex <vertex>. <vertex> must be a283vertex object in <graph>. The flag determines whether the vertex284should be selected or deselected. This operation already exists in285{\XGAP} for graphic objects. The method without flags assumes `true'.286287288\>DeselectAll( <graph> ) O289290Deselects all vertices in the graph or poset <graph>.291292293\>Selected( <graph> ) O294295Returns a (shallow-)copy of the set of all selected vertices.296297298299\medskip%300*Operations for decisions:*301\medskip%302\>ChooseLabel( <graph>, <data> ) O303\>ChooseLabel( <graph>, <data>, <data> ) O304305This operation is called during vertex or edge creation, if the caller306didn't specify a label for the vertex or edge. It has to return a short307string which will be attached to the vertex. If it returns `fail' the308new vertex is not generated! The generic method just returns the empty309string, so no label is generated. This method is also called in the310`Relabel' method without label parameter.311312313\>ChooseLevel( <poset>, <data> ) O314315This operation is called during vertex creation, if the caller didn't316specify a level to which the vertex belongs. It has to return a level317parameter which exists in the poset. If it returns `fail' the new318vertex is not generated!319320321\>ChooseClass( <poset>, <data>, <levelparam> ) O322323This operation is called during vertex creation, if the caller didn't324specify a class to which the vertex belongs. It has to return a325class parameter which exists in the poset in the level with parameter326<levelparam>. If it returns `fail' the new vertex is not generated!327328329\>ChooseColor( <graph>, <data> ) O330\>ChooseColor( <graph>, <data1>, <data2> ) O331332This operation is called during vertex or edge creation. It has to return a333color. If it returns `fail' the new vertex is not generated!334It is also called in the `Recolor' method without color parameter.335336337\>ChooseHighlight( <graph>, <data> ) O338339This operation is called during vertex creation. It has to return a340flag which indicates, whether the vertex is highlighted or not. If it341returns `fail' the new vertex is not generated!342It is also called in the `Highlight' method without flag parameter.343344345\>ChoosePosition( <poset>, <data>, <levelparam>, <classparam>, <hints> ) O346\>ChoosePosition( <graph>, <data> ) O347348This operation is called during vertex creation. It has to return a349list with two integers: the coordinates. For posets those are relative350to the level the vertex resides in. If it returns `fail' the new351vertex is not generated! The parameters <levelparam> and <classparam>352are level and class parameters respectively.353354355\>ChooseShape( <graph>, <data> ) O356357This operation is called during vertex creation.358It has to return a string out of the following list:359`circle', `diamond', `rectangle'.360If it returns `fail' the new vertex is not generated!361362363\>ChooseWidth( <graph>, <data> ) O364\>ChooseWidth( <graph>, <data1>, <data2> ) O365366This operation is called during vertex or edge creation.367It has to return a line width.368If it returns `fail' the new vertex or edge is not generated!369This is also called by the `SetWidth' operation without width parameter.370371372\>CompareLevels( <poset>, <levelparam1>, <levelparam2> ) O373374375Compare two level parameters. -1 means that the level with parameter376<levelparam1> is ``higher'', 1 means that the one with parameter377<levelparam2> is ``higher'', 0 means that they are equal. `fail' means378that they are not comparable.379380381382\medskip%383*Operations to get information:*384\medskip%385\>WhichLevel( <poset>, <y> ) O386387Determines the level in which position <y> is. `WhichLevel' returns the388level parameter or `fail'.389390391\>WhichClass( <poset>, <x>, <y> ) O392393Determines a class with a vertex which contains the position394$(<x>,<y>)$. The first class found is taken. `WhichClass' returns a395list with the level parameter as first and the class parameter as396second element. `WhichClass' returns `fail' if no such class is found.397398399\>WhichVertex( <graph>, <x>, <y> ) O400\>WhichVertex( <graph>, <data> ) O401\>WhichVertex( <graph>, <data>, <func> ) O402403Determines a vertex which contains the position $(<x>,<y>)$.404`WhichVertex' returns a vertex. In the third form the function <func>405must take two parameters <data> and the data entry of a vertex in406question. It must return `true' or `false', according to the right407vertex being found or not. The function can for example consider just408one record component of data records. `WhichVertex' returns `fail' in409case no vertex is found.410411412\>WhichVertices( <graph>, <x>, <y> ) O413\>WhichVertices( <graph>, <data> ) O414\>WhichVertices( <graph>, <data>, <func> ) O415416Determines the list of vertices which contain the position417$(<x>,<y>)$. `WhichVertices' returns a list.418In the third form the function <func> must take two parameters <data> and419the data entry of a vertex in question. It must return `true' or `false',420according to the vertex belonging into the result or not.421The function can for example consider just one record component of422data records.423Returns the empty list in case no vertex is found.424425426\>Levels( <poset> ) O427428Returns the list of level parameters in descending order meaning429highest to lowest.430431432\>Classes( <poset>, <levelparam> ) O433434Returns the list of class parameters in the level with parameter435<levelparam>. `Classes' Returns `fail' if no level with parameter436<levelparam> exists.437438439\>Vertices( <poset>, <levelparam>, <classparam> ) O440441Returns the list of vertices in the class with parameter <classparam>442in the level with parameter <levelparam>. Returns `fail' if no level443with parameter <levelparam> or no class with parameter <classparam>444exists in the level.445446447\>Maximals( <poset>, <vertex> ) O448449Returns the list of maximal subvertices in <vertex>.450451452\>MaximalIn( <poset>, <vertex> ) O453454Returns the list of vertices, in which <vertex> is maximal.455456457\>PositionLevel( <poset>, <levelparam> ) O458459Returns the y position of the level relative to the graphic460sheet and the height. Returns `fail' if no level with parameter461<levelparam> exists.462463464465\medskip%466*Operations for user communication:*467\medskip%468\>`Menu( <graph>, <title>, <entrylist>, <typelist>, <functionslist> )'{Menu![poset]}@{`Menu'!`[poset]'} O469470This operation already exists in {\XGAP} for graphic sheets.471Builds a new menu with title <title> but with information about the472type of the menu entry.473This information describes the relation between the selection state of474the vertices and the parameters supplied to the functions. It is stored475in the list <typelist>, which consists of strings. The following476types are supported:477\beginitems478`forany' & always enabled, generic routines don't change anything479480`forone' & enabled iff exactly one vertex is selected481482`fortwo' & enabled iff exactly two vertices are selected483484`forthree'& enabled iff exactly three vertices are selected485486`forsubset'&enabled iff at least one vertex is selected487488`foredge' & enabled iff a connected pair of two vertices is selected489490`formin2' & enabled iff at least two vertices are selected491492`formin3' & enabled iff at least three vertices are selected493494\enditems495496<entrylist> and <functionslist> are like in the original operation for497graphic sheets.498The `IsMenu' object is returned. It is also stored in the sheet.499500501\>ModifyEnabled( <graph>, <from>, <to> ) O502503Modifies the ``Enabledness'' of menu entries according to their type and504number of selected vertices. This operation works on all menu entries505of some menus: <from> is the first menu to work on and506<to> the last one (indices). Only menus with the property `IsAlive' are507considered. `ModifyEnabled' returns nothing.508509510\>InstallPopup( <graph>, <func> ) O511512Installs a function that is called if the user clicks with the right513button on a vertex. The function gets as parameters:514<poset>,<vertex>,<x>,<y> (click position)515516517\>PosetLeftClick( <poset>, <x>, <y> ) O518519This operation is called when the user does a left click in the poset520<poset>. The current pointer position is supplied in the parameters <x>521and <y>. The generic method for `PosetLeftClick' lets the user move,522select and deselect vertices or edges. An edge is selected as pair of523vertices.524525526\>PosetCtrlLeftClick( <poset>, <x>, <y> ) O527528529This operation is called when the user does a left click in a poset530<poset> while holding down the control key. The current pointer531position is supplied in the parameters <x> and <y>. The generic method532for `PosetCtrlLeftClick' lets the user move, select and deselect533vertices or edges. The difference to the operation without the control534key is, that while selecting the old vertices are NOT deselected.535Moving does not move the whole class but only one vertex. This allows536for permuting the vertices within a class. An edge is selected as pair537of vertices.538539540\>PosetRightClick( <poset>, <x>, <y> ) O541542This operation is called when the user does a right click in the graph543<graph>. The generic method just finds the vertex under the mouse544pointer and calls the `rightclickfunction' of the poset or graph which545is a component in the {\GAP} object. Note that the `rightclickfunction'546can be called with `fail' if no vertex is hit.547548549550\medskip%551*Operations for user actions:*552\medskip%553\>UserDeleteVerticesOp( <sheet>, <menu>, <entry> ) O554555556This operation is called when the user selects `Delete vertices'.557The generic method actually deletes the selected vertices including all558their edges.559560561\>UserDeleteEdgeOp( <sheet>, <menu>, <entry> ) O562563564This operation is called when the user selects `Delete edge'.565The generic method deletes the edge with no further warning!566567568\>UserMergeClassesOp( <sheet>, <menu>, <entry> ) O569570571This operation is called when the user selects `Merge Classes'.572The generic method walks through all levels and merges all classes that573contain a selected vertex. Afterwards `UserRearrangeClasses' is called.574575576\>UserMagnifyLattice( <sheet>, <menu>, <entry> ) O577578579This operation is called when the user selects `Magnify Lattice'.580The generic method scales everything by $144/100$ including the sheet,581all heights of levels and positions of vertices.582583584\>UserShrinkLattice( <sheet>, <menu>, <entry> ) O585586587This operation is called when the user selects `Shrink Lattice'.588The generic method scales everything by 100/144 including the sheet,589all heights of levels and positions of vertices.590591592\>UserResizeLattice( <sheet>, <menu>, <entry> ) O593594595This operation is called when the user selects `Resize Lattice'.596The generic method asks the user for an x and a y factor and scales597everything including the sheet, all heights of levels and positions of598vertices.599600601\>UserResizeSheet( <sheet>, <menu>, <entry> ) O602603604This operation is called when the user selects `Resize Sheet'.605The generic method asks the user for an x and a y pixel number and606changes the width and height of the sheet. No positions of levels and607vertices are changed. If the user asks for trouble he gets it!608609610\>UserMoveLattice( <sheet>, <menu>, <entry> ) O611612613This operation is called when the user selects `Move Lattice'.614The generic method asks the user for a pixel number and615changes the position of all vertices horizontally. No positions of616levels are changed.617618619\>UserChangeLabels( <sheet>, <menu>, <entry> ) O620621622This operation is called when the user selects `Change Labels'.623The user is prompted for every selected vertex, which label it should624have.625626627\>UserAverageY( <sheet>, <menu>, <entry> ) O628629630This operation is called when the user selects `Average Y Positions'.631In all levels the average y coordinate is calculated and all vertices are632moved to this y position.633634635\>UserAverageX( <sheet>, <menu>, <entry> ) O636637638This operation is called when the user selects `Average X Positions'.639The average of all x coordinates of the selected vertices is calculated.640Then all classes with a selected vertex are moved such that the first641selected vertex in this class has the calculated position as x position.642643644\>UserRearrangeClasses( <sheet>, <menu>, <entry> ) O645646647This operation is called when the user selects `Rearrange Classes'.648All classes with a selected vertex are rearranged: The vertices are649lined up neatly one after the other, sorted according to their current650x position.651652653\>UserUseBlackWhite( <sheet>, <menu>, <entry> ) O654655656This is called if the user selects `Use Black and White' in the menu.657658659\>PosetShowLevels( <sheet>, <menu>, <entry> ) O660661662This operation is called when the user selects `Show Levels' in the menu.663Switches the display of the little boxes for level handling on and off.664665666\>PosetShowLevelparams( <sheet>, <menu>, <entry> ) O667668669This operation is called when the user selects `Show Level Parameters' in670the menu. Switches the display of the level parameters at the right of671the screen on and off.672673674\>DoRedraw( <graph> ) O675676Redraws all vertices and connections.677678679680681%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%682\Section{An Example}683684This section shows how to use the poset package to display posets. The code685presented here is actually part of the {\XGAP} library and makes up the686link to the C MeatAxe.687688This is the declaration part:689690\begintt691#############################################################################692##693#W meataxe.gd XGAP library Max Neunhoeffer694##695#Y Copyright 1998, Max Neunhoeffer, Aachen, Germany696##697## This file contains declarations for MeatAxe posets698##699700DeclareFilter("IsMeatAxeLattice");701702#############################################################################703##704#O GraphicMeatAxeLattice(<name>, <width>, <height>) . creates graphic poset705##706## creates a new graphic MeatAxe lattice which is a specialization of a707## graphic poset. Those posets have a new filter for method selection.708##709DeclareOperation("GraphicMeatAxeLattice",[IsString, IsInt, IsInt]);710\endtt711712The code only declares a new filter and declares a constructor operation713for posets that lie in this new filter.714715The implementation:716717\begintt718#############################################################################719##720#W meataxe.gi XGAP library Max Neunhoeffer721##722#Y Copyright 1998, Max Neunhoeffer, Aachen, Germany723##724## This file contains code for MeatAxe posets725##726727#############################################################################728##729#M GraphicMeatAxeLattice(<name>, <width>, <height>) . creates graphic poset730##731## creates a new graphic MeatAxe lattice which is a specialization of a732## graphic poset. Those posets have a new filter for method selection.733##734InstallMethod( GraphicMeatAxeLattice,735"for a string, and two integers",736true,737[ IsString,738IsInt,739IsInt ],7400,741742function( name, width, height )743local P;744745P := GraphicPoset(name,width,height);746SetFilterObj(P,IsMeatAxeLattice);747return P;748end);749750#############################################################################751##752#M CompareLevels(<poset>,<levelparam1>,<levelparam2>) . . . . . . . . . . .753## . . . . . . . . . . . . . . . . . . . . . . . . compares two levelparams754##755## Compare two level parameters. -1 means that <levelparam1> is "higher",756## 1 means that <levelparam2> is "higher", 0 means that they are equal.757## fail means that they are not comparable. This method is for the case758## if level parameters are integers and lower values mean lower levels759## like in the case of MeatAxe lattices of Michael Ringe.760##761InstallMethod( CompareLevels,762"for a graphic MeatAxe lattice, and two integers",763true,764[ IsGraphicPosetRep and IsMeatAxeLattice, IsInt, IsInt ],7650,766function( poset, l1, l2 )767if l1 < l2 then768return 1;769elif l1 > l2 then770return -1;771else772return 0;773fi;774end);775\endtt776777Besides the new constructor (which only adds a new filter) we only have to778supply a new method for comparison of level parameters for such posets. The779levels are numbered with integer numbers such that lower numbers are lower780in the lattice.781782There is a C program in the MeatAxe that exports a poset to a {\GAP}783program which generates the lattice in a graphic poset sheet. The user can784then interactively move around vertices and shrink or magnify levels. He785can then export the resulting lattice to an encapsulated postscript file.786Note that you need a full installation of the C MeatAxe apart from787{\GAP} to use this feature.788789Another nice little example is in the `examples' subdirectory in the790{\XGAP} distribution. It was written by Thomas Breuer (Aachen) to791demonstrate the features of {\XGAP}. The user gets a small window with a792puzzle and can solve it using the mouse. You can test this example by793starting {\XGAP} and `Read'ing the file `pkg/xgap/examples/puzzle.g'.794You can do this by using795796\begintt797gap> ReadPkg("xgap","examples/puzzle.g");798gap> p := Puzzle(4,4);799\endtt800801802803804805806