Mathematical Structures: Display a poset or graph using a Java applet

# Display a poset or graph using a Java applet

### Examples of how to use the graph drawing applet for posets and digraphs

The description for a poset is as follows:

```<applet codebase="/" code="Graph.class" width=300 height=150>
<param name=showControls value='true'>
<param name=poset value='true'>
<param name=structure value='
<structure name="Lat_6_1" size="6">
<label x="1.5" y="-.5">M_4</label>
<element name="0" x="1.5" y="0"/>
<element name="1" x="0" y="1"/>
<element name="2" x="1" y="1"/>
<element name="3" x="2" y="1"/>
<element name="4" x="3" y="1"/>
<element name="5" x="1.5" y="2"/>
<relation name="uppercovers" arity="2" type="list">
<set id="0"> 1 2 3 4 </set>
<set id="1"> 5 </set>
<set id="2"> 5 </set>
<set id="3"> 5 </set>
<set id="4"> 5 </set>
<set id="5"> </set>
</relation>
</structure>
'>
</applet>

```

Below you can see what the applet shows. To change the appearance, click on some of the elements and drag them to new positions.

Click on start to have elements rearrange themselves dynamically.

Click on an element to fix it in place (indicated by a red circle around the element). Click again to release it.

<applet codebase="/" code="Graph.class" width=300 height=300> <param name=showControls value='true'> <param name=poset value='true'> <param name=structure value=' <structure name="Lat_6_1" size="6"> <label x="1.5" y="-.5">M_4</label> <element name="0" x="1.5" y="0"/> <element name="1" x="0" y="1"/> <element name="2" x="1" y="1"/> <element name="3" x="2" y="1"/> <element name="4" x="3" y="1"/> <element name="5" x="1.5" y="2"/> <relation name="uppercovers" arity="2" type="list"> <set id="0"> 1 2 3 4 </set> <set id="1"> 5 </set> <set id="2"> 5 </set> <set id="3"> 5 </set> <set id="4"> 5 </set> <set id="5"> </set> </relation> </structure> '> </applet>

The description for a digraph is as follows:

```<structure name="Chain_4">
<element id="0" x="0" y="1"/>
<element id="1" x="1" y="1"/>
<element id="2" x="1" y="0" color="red"/>
<element id="3" x="0" y="0"/>
<relation arrows="true">
<edge s="0" t="1 2 3"/>
<edge s="1" t="2 3"/>
<edge s="2" t="3"/>
<edge s="3" t=""/>
</relation>
</structure>
```
The attribute arrows="true" in the <relation> tag makes the arrow heads appear on all edges.

If you only want arrows on some edges, put the attribute in the <edge> tag.

At the moment edges are always drawn as straight lines. To indicate reflexive edges (loops), add a color attribute to the elements that should have loops.

<applet codebase="/" code="Graph.class" width=300 height=300> <param name=showControls value='true'> <param name=structure value=' <structure name="Chain_4"> <element id="0" x="0" y="1"/> <element id="1" x="1" y="1"/> <element id="2" x="1" y="0" color="red"/> <element id="3" x="0" y="0"/> <relation arrows="true"> <edge s="0" t="1 2 3"/> <edge s="1" t="2 3"/> <edge s="2" t="3"/> <edge s="3" t=""/> </relation> </structure> '> </applet>