Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/pkg/francy/notebooks/   (Algebra von RWTH Aachen Version 4.15.1©)  Datei vom 17.3.2023 mit Größe 26 kB image not shown  

Quelle  demo.ipynb   Sprache: unbekannt

 
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Francy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### A list of all Francy features, with examples, is available on the following notebook [Francy Features](francy-features.ipynb).\n",
    "### Francy can be used to create new interactive packages, for instance the [FrancyMonoids](francy-monoids.ipynb) or [SubgroupLattice](subgroup-lattice.ipynb) packages.\n",
    "### Francy has been extended and supports, apart from GAP, [Python](https://github.com/zerline/francy-widget) and [Julia](https://github.com/fieker/Francy) languages as backends.\n",
    "### Francy inspired projects such as [JupyterViz](https://github.com/nathancarter/jupyterviz)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# How to make an existing Package interactive? \n",
    "### Francy can be used to enhance existing packages by providing interactive visualizations.\n",
    "### As an example, lets use the package [Digraphs](https://www.gap-system.org/Packages/digraphs.html) from James Mitchell. This package already allows the creation of static images using GraphViz.\n",
    "### Lets start by loading GAP packages for the demo:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "LoadPackage(\"francy\");;\n",
    "LoadPackage(\"digraph\");;"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    " ### Imagine we want to represent the directed graph of all subgroups of the DihedralGroup $D_4$:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<pc group of size 4 with 2 generators>"
      ]
     },
     "execution_count": 3,
     "metadata": {
      "text/plain": ""
     },
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "[ Group([  ]), Group([ f1 ]), Group([ f2 ]), Group([ f1*f2 ]),   <pc group of size 4 with 2 generators> ]"
      ]
     },
     "execution_count": 4,
     "metadata": {
      "text/plain": ""
     },
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "<immutable digraph with 5 vertices, 12 edges>"
      ]
     },
     "execution_count": 5,
     "metadata": {
      "text/plain": ""
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "G            := DihedralGroup(4);\n",
    "allSubgroups := AllSubgroups(G);\n",
    "digraph      := Digraph(allSubgroups, {H, K} -> IsSubgroup(H, K));"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Display the Digraph:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"//dot\\ndigraph hgn{\\nnode [shape=circle]\\n1\\n2\\n3\\n4\\n5\\n1 -> 1\\n2 -> 1\\n2 ->\\ 2\\n3 -> 1\\n3 -> 3\\n4 -> 1\\n4 -> 4\\n5 -> 1\\n5 -> 2\\n5 -> 3\\n5 -> 4\\n5 -> 5\\n}\\\\n\""
      ]
     },
     "execution_count": 6,
     "metadata": {
      "text/plain": ""
     },
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Generated by graphviz version 2.43.0 (0)\n",
       " -->\n",
       "<!-- Title: hgn Pages: 1 -->\n",
       "<svg width=\"220pt\" height=\"188pt\"\n",
       " viewBox=\"0.00 0.00 220.06 188.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 184)\">\n",
       "<title>hgn</title>\n",
       "<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-184 216.06,-184 216.06,4 -4,4\"/>\n",
       "<!-- 1 -->\n",
       "<g id=\"node1\" class=\"node\">\n",
       "<title>1</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" cx=\"68.06\" cy=\"-18\" rx=\"18\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"68.06\" y=\"-14.3\" font-family=\"Times,serif\" font-size=\"14.00\">1</text>\n",
       "</g>\n",
       "<!-- 1->1 -->\n",
       "<g id=\"edge1\" class=\"edge\">\n",
       "<title>1->1</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M82.11,-29.76C92.98,-34.15 104.06,-30.23 104.06,-18 104.06,-9.59 98.82,-5.11 92.02,-4.56\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"91.38,-1.12 82.11,-6.24 92.55,-8.02 91.38,-1.12\"/>\n",
       "</g>\n",
       "<!-- 2 -->\n",
       "<g id=\"node2\" class=\"node\">\n",
       "<title>2</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" cx=\"32.06\" cy=\"-90\" rx=\"18\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"32.06\" y=\"-86.3\" font-family=\"Times,serif\" font-size=\"14.00\">2</text>\n",
       "</g>\n",
       "<!-- 2->1 -->\n",
       "<g id=\"edge2\" class=\"edge\">\n",
       "<title>2->1</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M40.05,-73.46C44.58,-64.67 50.33,-53.48 55.45,-43.53\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"58.64,-44.99 60.1,-34.49 52.41,-41.78 58.64,-44.99\"/>\n",
       "</g>\n",
       "<!-- 2->2 -->\n",
       "<g id=\"edge3\" class=\"edge\">\n",
       "<title>2->2</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M46.11,-101.76C56.98,-106.15 68.06,-102.23 68.06,-90 68.06,-81.59 62.82,-77.11 56.02,-76.56\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"55.38,-73.12 46.11,-78.24 56.55,-80.02 55.38,-73.12\"/>\n",
       "</g>\n",
       "<!-- 3 -->\n",
       "<g id=\"node3\" class=\"node\">\n",
       "<title>3</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" cx=\"104.06\" cy=\"-90\" rx=\"18\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"104.06\" y=\"-86.3\" font-family=\"Times,serif\" font-size=\"14.00\">3</text>\n",
       "</g>\n",
       "<!-- 3->1 -->\n",
       "<g id=\"edge4\" class=\"edge\">\n",
       "<title>3->1</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M96.07,-73.46C91.55,-64.67 85.8,-53.48 80.68,-43.53\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"83.72,-41.78 76.03,-34.49 77.49,-44.99 83.72,-41.78\"/>\n",
       "</g>\n",
       "<!-- 3->3 -->\n",
       "<g id=\"edge5\" class=\"edge\">\n",
       "<title>3->3</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M118.11,-101.76C128.98,-106.15 140.06,-102.23 140.06,-90 140.06,-81.59 134.82,-77.11 128.02,-76.56\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"127.38,-73.12 118.11,-78.24 128.55,-80.02 127.38,-73.12\"/>\n",
       "</g>\n",
       "<!-- 4 -->\n",
       "<g id=\"node4\" class=\"node\">\n",
       "<title>4</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" cx=\"176.06\" cy=\"-90\" rx=\"18\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"176.06\" y=\"-86.3\" font-family=\"Times,serif\" font-size=\"14.00\">4</text>\n",
       "</g>\n",
       "<!-- 4->1 -->\n",
       "<g id=\"edge6\" class=\"edge\">\n",
       "<title>4->1</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M161.05,-79.27C142.99,-67.56 112.49,-47.79 91.37,-34.1\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"93.25,-31.15 82.95,-28.65 89.44,-37.03 93.25,-31.15\"/>\n",
       "</g>\n",
       "<!-- 4->4 -->\n",
       "<g id=\"edge7\" class=\"edge\">\n",
       "<title>4->4</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M190.11,-101.76C200.98,-106.15 212.06,-102.23 212.06,-90 212.06,-81.59 206.82,-77.11 200.02,-76.56\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"199.38,-73.12 190.11,-78.24 200.55,-80.02 199.38,-73.12\"/>\n",
       "</g>\n",
       "<!-- 5 -->\n",
       "<g id=\"node5\" class=\"node\">\n",
       "<title>5</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" cx=\"68.06\" cy=\"-162\" rx=\"18\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"68.06\" y=\"-158.3\" font-family=\"Times,serif\" font-size=\"14.00\">5</text>\n",
       "</g>\n",
       "<!-- 5->1 -->\n",
       "<g id=\"edge8\" class=\"edge\">\n",
       "<title>5->1</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M52.2,-152.98C36.91,-144.25 14.72,-128.73 5.06,-108 -1.69,-93.49 -1.69,-86.51 5.06,-72 12.98,-54.99 29.34,-41.49 43.4,-32.38\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"45.48,-35.21 52.2,-27.02 41.84,-29.23 45.48,-35.21\"/>\n",
       "</g>\n",
       "<!-- 5->2 -->\n",
       "<g id=\"edge9\" class=\"edge\">\n",
       "<title>5->2</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M60.07,-145.46C55.55,-136.67 49.8,-125.48 44.68,-115.53\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"47.72,-113.78 40.03,-106.49 41.49,-116.99 47.72,-113.78\"/>\n",
       "</g>\n",
       "<!-- 5->3 -->\n",
       "<g id=\"edge10\" class=\"edge\">\n",
       "<title>5->3</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M76.05,-145.46C80.58,-136.67 86.33,-125.48 91.45,-115.53\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"94.64,-116.99 96.1,-106.49 88.41,-113.78 94.64,-116.99\"/>\n",
       "</g>\n",
       "<!-- 5->4 -->\n",
       "<g id=\"edge11\" class=\"edge\">\n",
       "<title>5->4</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M83.08,-151.27C101.14,-139.56 131.64,-119.79 152.76,-106.1\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"154.69,-109.03 161.18,-100.65 150.88,-103.15 154.69,-109.03\"/>\n",
       "</g>\n",
       "<!-- 5->5 -->\n",
       "<g id=\"edge12\" class=\"edge\">\n",
       "<title>5->5</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M82.11,-173.76C92.98,-178.15 104.06,-174.23 104.06,-162 104.06,-153.59 98.82,-149.11 92.02,-148.56\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"91.38,-145.12 82.11,-150.24 92.55,-152.02 91.38,-145.12\"/>\n",
       "</g>\n",
       "</g>\n",
       "</svg>\n"
      ]
     },
     "execution_count": 7,
     "metadata": {
      "image/svg+xml": {
       "height": 500,
       "width": 500
      }
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dot := DotDigraph(digraph);\n",
    "JupyterSplashDot(dot);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Now, we can obtain the same representation using Francy by:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.francy+json": "{\"canvas\" : {\"graph\" : {\"collapsed\" : true,\"id\" : \"F54CD4B05DD4246E92C0525D0F611334A\",\"links\" : {\"F0868DA228962428204E306E7BA02C0BF\" : {\"color\" : \"\",\"id\" : \"F0868DA228962428204E306E7BA02C0BF\",\"invisible\" : false,\"length\" : 0,\"source\" : \"FC957E285E0B14173EC9381C00B082970\",\"target\" : \"FC957E285E0B14173EC9381C00B082970\",\"weight\" : 0},\"F2ED844CBF82047CA8C0E59ECD1D25F6A\" : {\"color\" : \"\",\"id\" : \"F2ED844CBF82047CA8C0E59ECD1D25F6A\",\"invisible\" : false,\"length\" : 0,\"source\" : \"F2A6C37797BF9484A0470FE1CE5464A41\",\"target\" : \"FC957E285E0B14173EC9381C00B082970\",\"weight\" : 0},\"F36D7D8C8024E4D9B34DBDCE35F39E797\" : {\"color\" : \"\",\"id\" : \"F36D7D8C8024E4D9B34DBDCE35F39E797\",\"invisible\" : false,\"length\" : 0,\"source\" : \"FCC126CDF1E5242146C0BCE666332E9C4\",\"target\" : \"FC957E285E0B14173EC9381C00B082970\",\"weight\" : 0},\"F3A62027A90C14B2E64ADFBE598DCAB1F\" : {\"color\" : \"\",\"id\" : \"F3A62027A90C14B2E64ADFBE598DCAB1F\",\"invisible\" : false,\"length\" : 0,\"source\" : \"F1AB14F00715746C17C7A051F4C4D50D1\",\"target\" : \"F1AB14F00715746C17C7A051F4C4D50D1\",\"weight\" : 0},\"F40528265F01D48195C823DDF5A14D7CF\" : {\"color\" : \"\",\"id\" : \"F40528265F01D48195C823DDF5A14D7CF\",\"invisible\" : false,\"length\" : 0,\"source\" : \"F1AB14F00715746C17C7A051F4C4D50D1\",\"target\" : \"FC957E285E0B14173EC9381C00B082970\",\"weight\" : 0},\"F4F18DC8FBC08428664203B7254BEDCFC\" : {\"color\" : \"\",\"id\" : \"F4F18DC8FBC08428664203B7254BEDCFC\",\"invisible\" : false,\"length\" : 0,\"source\" : \"FCC126CDF1E5242146C0BCE666332E9C4\",\"target\" : \"F78F966D29C48478A349E56140B0752E8\",\"weight\" : 0},\"F793F564DFC7C41AD0C70B2CB648370C1\" : {\"color\" : \"\",\"id\" : \"F793F564DFC7C41AD0C70B2CB648370C1\",\"invisible\" : false,\"length\" : 0,\"source\" : \"F2A6C37797BF9484A0470FE1CE5464A41\",\"target\" : \"F2A6C37797BF9484A0470FE1CE5464A41\",\"weight\" : 0},\"F9A4E435F8A234BBD34DD34C838182A5C\" : {\"color\" : \"\",\"id\" : \"F9A4E435F8A234BBD34DD34C838182A5C\",\"invisible\" : false,\"length\" : 0,\"source\" : \"FCC126CDF1E5242146C0BCE666332E9C4\",\"target\" : \"FCC126CDF1E5242146C0BCE666332E9C4\",\"weight\" : 0},\"FB9F3D102AF6942D1348022740EF8E8ED\" : {\"color\" : \"\",\"id\" : \"FB9F3D102AF6942D1348022740EF8E8ED\",\"invisible\" : false,\"length\" : 0,\"source\" : \"F78F966D29C48478A349E56140B0752E8\",\"target\" : \"F78F966D29C48478A349E56140B0752E8\",\"weight\" : 0},\"FBADFB1FBB15143125C5771BF1E49AAAC\" : {\"color\" : \"\",\"id\" : \"FBADFB1FBB15143125C5771BF1E49AAAC\",\"invisible\" : false,\"length\" : 0,\"source\" : \"FCC126CDF1E5242146C0BCE666332E9C4\",\"target\" : \"F2A6C37797BF9484A0470FE1CE5464A41\",\"weight\" : 0},\"FBC3E1C907D124ABCB4D37AFC978D49C0\" : {\"color\" : \"\",\"id\" : \"FBC3E1C907D124ABCB4D37AFC978D49C0\",\"invisible\" : false,\"length\" : 0,\"source\" : \"FCC126CDF1E5242146C0BCE666332E9C4\",\"target\" : \"F1AB14F00715746C17C7A051F4C4D50D1\",\"weight\" : 0},\"FEF76FDF6550246224C26BEBD124862CC\" : {\"color\" : \"\",\"id\" : \"FEF76FDF6550246224C26BEBD124862CC\",\"invisible\" : false,\"length\" : 0,\"source\" : \"F78F966D29C48478A349E56140B0752E8\",\"target\" : \"FC957E285E0B14173EC9381C00B082970\",\"weight\" : 0}},\"nodes\" : {\"F1AB14F00715746C17C7A051F4C4D50D1\" : {\"callbacks\" : {},\"color\" : \"\",\"id\" : \"F1AB14F00715746C17C7A051F4C4D50D1\",\"layer\" : 0,\"menus\" : {},\"messages\" : {},\"parent\" : \"\",\"size\" : 10,\"title\" : \"4\",\"type\" : \"circle\",\"x\" : 0,\"y\" : 0},\"F2A6C37797BF9484A0470FE1CE5464A41\" : {\"callbacks\" : {},\"color\" : \"\",\"id\" : \"F2A6C37797BF9484A0470FE1CE5464A41\",\"layer\" : 0,\"menus\" : {},\"messages\" : {},\"parent\" : \"\",\"size\" : 10,\"title\" : \"3\",\"type\" : \"circle\",\"x\" : 0,\"y\" : 0},\"F78F966D29C48478A349E56140B0752E8\" : {\"callbacks\" : {},\"color\" : \"\",\"id\" : \"F78F966D29C48478A349E56140B0752E8\",\"layer\" : 0,\"menus\" : {},\"messages\" : {},\"parent\" : \"\",\"size\" : 10,\"title\" : \"2\",\"type\" : \"circle\",\"x\" : 0,\"y\" : 0},\"FC957E285E0B14173EC9381C00B082970\" : {\"callbacks\" : {},\"color\" : \"\",\"id\" : \"FC957E285E0B14173EC9381C00B082970\",\"layer\" : 0,\"menus\" : {},\"messages\" : {},\"parent\" : \"\",\"size\" : 10,\"title\" : \"1\",\"type\" : \"circle\",\"x\" : 0,\"y\" : 0},\"FCC126CDF1E5242146C0BCE666332E9C4\" : {\"callbacks\" : {},\"color\" : \"\",\"id\" : \"FCC126CDF1E5242146C0BCE666332E9C4\",\"layer\" : 0,\"menus\" : {},\"messages\" : {},\"parent\" : \"\",\"size\" : 10,\"title\" : \"5\",\"type\" : \"circle\",\"x\" : 0,\"y\" : 0}},\"simulation\" : true,\"type\" : \"directed\"},\"height\" : 600,\"id\" : \"F8F794C1FA828467404CA41218DCFC68D\",\"menus\" : {},\"messages\" : {},\"renderer\" : \"GraphViz-Renderer.dot\",\"texTypesetting\" : true,\"title\" : \"Subgroups Digraph of Group( [ f1, f2 ] )\",\"width\" : 800,\"zoomToFit\" : true},\"mime\" : \"application\\/vnd.francy+json\",\"version\" : \"1.2.4\"}"
     },
     "execution_count": 18,
     "metadata": {
      "application/vnd.francy+json": {}
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nodes    := [];;\n",
    "vertices := DigraphVertices(digraph);;\n",
    "edges    := DigraphEdges(digraph);;\n",
    "\n",
    "graph := Graph(GraphType.DIRECTED);;\n",
    "\n",
    "for i in vertices do\n",
    "    nodes[i] := Shape(ShapeType.CIRCLE, String(i));;\n",
    "    Add(graph, nodes[i]);;\n",
    "od;;\n",
    "\n",
    "for i in edges do\n",
    "    Add(graph, Link(nodes[i[1]], nodes[i[2]]));;\n",
    "od;;\n",
    "\n",
    "canvas := Canvas(Concatenation(\"Subgroups Digraph of \", String(G)));;\n",
    "Add(canvas, graph);;\n",
    "\n",
    "graphviz := FrancyRenderer(FrancyRendererType.GRAPHVIZ_DOT);;\n",
    "Add(canvas, graphviz);;\n",
    "\n",
    "Draw(canvas);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Now, if we wanted to make it interactive by checking whether a subgroup is simple or not, for instance, we could extend the previous code:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "function( G ) ... end"
      ]
     },
     "execution_count": 19,
     "metadata": {
      "text/plain": ""
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "FrancyDigraphs := function(G)\n",
    "    local as, d, v, e, graph, nodes, m, IsGroupSimple, canvas, i, graphviz;\n",
    "\n",
    "    as := AllSubgroups(G);\n",
    "\n",
    "    d := Digraph(as, {H, K} -> IsSubgroup(H, K));;\n",
    "    v := DigraphVertices(d);;\n",
    "    e := DigraphEdges(d);;\n",
    "\n",
    "    graph := Graph(GraphType.DIRECTED);;\n",
    "    canvas := Canvas(Concatenation(\"Subgroups Digraph of \", String(G)));;\n",
    "    Add(canvas, graph);;\n",
    "\n",
    "    nodes := [];;\n",
    "\n",
    "    # Explanatory message to show everytime\n",
    "    m := FrancyMessage(FrancyMessageType.INFO, \"Simple Groups\", \n",
    "    \"A group is simple if it is nontrivial and has no nontrivial normal subgroups.\");;\n",
    "    \n",
    "    # Add a new function to be invoked on click\n",
    "    IsGroupSimple := function(i)\n",
    "        Add(canvas, m);;\n",
    "        if IsSimpleGroup(as[i]) then\n",
    "            Add(canvas, FrancyMessage(\"Simple\", Concatenation(\"The vertex \", \n",
    "                String(i), \", representing the subgroup \", String(as[i]), \", is simple.\")));;\n",
    "        else\n",
    "            Add(canvas, FrancyMessage(\"Not Simple\", Concatenation(\"The vertex \", \n",
    "                String(i), \", representing the subgroup \", String(as[i]), \", is not simple.\")));;\n",
    "        fi;;\n",
    "        return Draw(canvas);\n",
    "    end;;\n",
    "\n",
    "    for i in v do\n",
    "        nodes[i] := Shape(ShapeType.CIRCLE, String(i));;\n",
    "        # Add a menu on each node with a callback to the function created before\n",
    "        Add(nodes[i], Menu(\"Simple\", Callback(IsGroupSimple, [i])));;\n",
    "        Add(graph, nodes[i]);;\n",
    "    od;;\n",
    "\n",
    "    for i in e do\n",
    "        Add(graph, Link(nodes[i[1]], nodes[i[2]]));;\n",
    "    od;;\n",
    "    \n",
    "    graphviz := FrancyRenderer(FrancyRendererType.GRAPHVIZ_DOT);;\n",
    "    Add(canvas, graphviz);;\n",
    "\n",
    "    return Draw(canvas);\n",
    "end;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.francy+json": "{\"canvas\" : {\"graph\" : {\"collapsed\" : true,\"id\" : \"F893471BC9EC94849B42DB8268A9D1AB6\",\"links\" : {\"F1B09C45784694781CC3D3E68AF1F5CFF\" : {\"color\" : \"\",\"id\" : \"F1B09C45784694781CC3D3E68AF1F5CFF\",\"invisible\" : false,\"length\" : 0,\"source\" : \"F8DD0CA00423F4D774CF0766011BCA30F\",\"target\" : \"F8DD0CA00423F4D774CF0766011BCA30F\",\"weight\" : 0},\"F26572242DF2F43D9AC72DA4D57B7AA81\" : {\"color\" : \"\",\"id\" : \"F26572242DF2F43D9AC72DA4D57B7AA81\",\"invisible\" : false,\"length\" : 0,\"source\" : \"F8DD0CA00423F4D774CF0766011BCA30F\",\"target\" : \"F49BDA1295C9445F6F4EC266BF0A82D84\",\"weight\" : 0},\"F2ACDFEAF7704468DD44BC4CFBDA98CDD\" : {\"color\" : \"\",\"id\" : \"F2ACDFEAF7704468DD44BC4CFBDA98CDD\",\"invisible\" : false,\"length\" : 0,\"source\" : \"F8DD0CA00423F4D774CF0766011BCA30F\",\"target\" : \"F9980C3AB1FE8467A0C39E0816714D39D\",\"weight\" : 0},\"F3513C9B110C7438B64E6A4A2EF887B49\" : {\"color\" : \"\",\"id\" : \"F3513C9B110C7438B64E6A4A2EF887B49\",\"invisible\" : false,\"length\" : 0,\"source\" : \"F55F63E4544B84A3F14A229612277EA64\",\"target\" : \"F55F63E4544B84A3F14A229612277EA64\",\"weight\" : 0},\"F360FDB11B96046EC64EACF2FF9DF2819\" : {\"color\" : \"\",\"id\" : \"F360FDB11B96046EC64EACF2FF9DF2819\",\"invisible\" : false,\"length\" : 0,\"source\" : \"F49BDA1295C9445F6F4EC266BF0A82D84\",\"target\" : \"F9980C3AB1FE8467A0C39E0816714D39D\",\"weight\" : 0},\"F37407350D8344221FCDF6B0C4FACDF6E\" : {\"color\" : \"\",\"id\" : \"F37407350D8344221FCDF6B0C4FACDF6E\",\"invisible\" : false,\"length\" : 0,\"source\" : \"F55F63E4544B84A3F14A229612277EA64\",\"target\" : \"F9980C3AB1FE8467A0C39E0816714D39D\",\"weight\" : 0},\"F70C0C02B07B84DB34C05ECEED45E49C0\" : {\"color\" : \"\",\"id\" : \"F70C0C02B07B84DB34C05ECEED45E49C0\",\"invisible\" : false,\"length\" : 0,\"source\" : \"F8DD0CA00423F4D774CF0766011BCA30F\",\"target\" : \"F55F63E4544B84A3F14A229612277EA64\",\"weight\" : 0},\"F8DCD5BBDED624AE18C514461B4AAEA75\" : {\"color\" : \"\",\"id\" : \"F8DCD5BBDED624AE18C514461B4AAEA75\",\"invisible\" : false,\"length\" : 0,\"source\" : \"F8DD0CA00423F4D774CF0766011BCA30F\",\"target\" : \"F2140F5B9EB414493EC719FFE8D4BF2ED\",\"weight\" : 0},\"F9F3EBB45E0E542B3FC53FCD55E436659\" : {\"color\" : \"\",\"id\" : \"F9F3EBB45E0E542B3FC53FCD55E436659\",\"invisible\" : false,\"length\" : 0,\"source\" : \"F2140F5B9EB414493EC719FFE8D4BF2ED\",\"target\" : \"F2140F5B9EB414493EC719FFE8D4BF2ED\",\"weight\" : 0},\"FA78183C1D3CA418F3CC3C83037C3C6B8\" : {\"color\" : \"\",\"id\" : \"FA78183C1D3CA418F3CC3C83037C3C6B8\",\"invisible\" : false,\"length\" : 0,\"source\" : \"F49BDA1295C9445F6F4EC266BF0A82D84\",\"target\" : \"F49BDA1295C9445F6F4EC266BF0A82D84\",\"weight\" : 0},\"FBD9E398833344A7ADC806BAD17402604\" : {\"color\" : \"\",\"id\" : \"FBD9E398833344A7ADC806BAD17402604\",\"invisible\" : false,\"length\" : 0,\"source\" : \"F9980C3AB1FE8467A0C39E0816714D39D\",\"target\" : \"F9980C3AB1FE8467A0C39E0816714D39D\",\"weight\" : 0},\"FC3F97C37978E48F7ACDF22F2D8EEEAC7\" : {\"color\" : \"\",\"id\" : \"FC3F97C37978E48F7ACDF22F2D8EEEAC7\",\"invisible\" : false,\"length\" : 0,\"source\" : \"F2140F5B9EB414493EC719FFE8D4BF2ED\",\"target\" : \"F9980C3AB1FE8467A0C39E0816714D39D\",\"weight\" : 0}},\"nodes\" : {\"F2140F5B9EB414493EC719FFE8D4BF2ED\" : {\"callbacks\" : {},\"color\" : \"\",\"id\" : \"F2140F5B9EB414493EC719FFE8D4BF2ED\",\"layer\" : 0,\"menus\" : {\"F2D93B026F585424AF4DCE24E0C2A49F8\" : {\"callback\" : {\"func\" : \"unknown\",\"id\" : \"FA9ED231CB4E94792E44909958FE38065\",\"knownArgs\" : [\"2\"],\"requiredArgs\" : {},\"trigger\" : \"click\"},\"id\" : \"F2D93B026F585424AF4DCE24E0C2A49F8\",\"menus\" : {},\"title\" : \"Simple\"}},\"messages\" : {},\"parent\" : \"\",\"size\" : 10,\"title\" : \"2\",\"type\" : \"circle\",\"x\" : 0,\"y\" : 0},\"F49BDA1295C9445F6F4EC266BF0A82D84\" : {\"callbacks\" : {},\"color\" : \"\",\"id\" : \"F49BDA1295C9445F6F4EC266BF0A82D84\",\"layer\" : 0,\"menus\" : {\"FA6051B31B0334002FC557EA064E34781\" : {\"callback\" : {\"func\" : \"unknown\",\"id\" : \"F94F08AE9E9724579DC4004270C597E1A\",\"knownArgs\" : [\"4\"],\"requiredArgs\" : {},\"trigger\" : \"click\"},\"id\" : \"FA6051B31B0334002FC557EA064E34781\",\"menus\" : {},\"title\" : \"Simple\"}},\"messages\" : {},\"parent\" : \"\",\"size\" : 10,\"title\" : \"4\",\"type\" : \"circle\",\"x\" : 0,\"y\" : 0},\"F55F63E4544B84A3F14A229612277EA64\" : {\"callbacks\" : {},\"color\" : \"\",\"id\" : \"F55F63E4544B84A3F14A229612277EA64\",\"layer\" : 0,\"menus\" : {\"F06668D287B154619349F2436DCD72C18\" : {\"callback\" : {\"func\" : \"unknown\",\"id\" : \"F7220CDA1859D4FB5D44E4B78F5ED59EB\",\"knownArgs\" : [\"3\"],\"requiredArgs\" : {},\"trigger\" : \"click\"},\"id\" : \"F06668D287B154619349F2436DCD72C18\",\"menus\" : {},\"title\" : \"Simple\"}},\"messages\" : {},\"parent\" : \"\",\"size\" : 10,\"title\" : \"3\",\"type\" : \"circle\",\"x\" : 0,\"y\" : 0},\"F8DD0CA00423F4D774CF0766011BCA30F\" : {\"callbacks\" : {},\"color\" : \"\",\"id\" : \"F8DD0CA00423F4D774CF0766011BCA30F\",\"layer\" : 0,\"menus\" : {\"F2B929BF53E274CED6C033077FD182A78\" : {\"callback\" : {\"func\" : \"unknown\",\"id\" : \"F0EFC447BC2A94F6A046EAA5CF1827861\",\"knownArgs\" : [\"5\"],\"requiredArgs\" : {},\"trigger\" : \"click\"},\"id\" : \"F2B929BF53E274CED6C033077FD182A78\",\"menus\" : {},\"title\" : \"Simple\"}},\"messages\" : {},\"parent\" : \"\",\"size\" : 10,\"title\" : \"5\",\"type\" : \"circle\",\"x\" : 0,\"y\" : 0},\"F9980C3AB1FE8467A0C39E0816714D39D\" : {\"callbacks\" : {},\"color\" : \"\",\"id\" : \"F9980C3AB1FE8467A0C39E0816714D39D\",\"layer\" : 0,\"menus\" : {\"F383B937CCF3547927CB4CC7779D548B7\" : {\"callback\" : {\"func\" : \"unknown\",\"id\" : \"FADAB64089636489B9C138F2DEEA6DF25\",\"knownArgs\" : [\"1\"],\"requiredArgs\" : {},\"trigger\" : \"click\"},\"id\" : \"F383B937CCF3547927CB4CC7779D548B7\",\"menus\" : {},\"title\" : \"Simple\"}},\"messages\" : {},\"parent\" : \"\",\"size\" : 10,\"title\" : \"1\",\"type\" : \"circle\",\"x\" : 0,\"y\" : 0}},\"simulation\" : true,\"type\" : \"directed\"},\"height\" : 600,\"id\" : \"FEE444EE1F5F64CD1BC9BD25BD64986EE\",\"menus\" : {},\"messages\" : {},\"renderer\" : \"GraphViz-Renderer.dot\",\"texTypesetting\" : true,\"title\" : \"Subgroups Digraph of Group( [ f1, f2 ] )\",\"width\" : 800,\"zoomToFit\" : true},\"mime\" : \"application\\/vnd.francy+json\",\"version\" : \"1.2.4\"}"
     },
     "execution_count": 20,
     "metadata": {
      "application/vnd.francy+json": {}
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "FrancyDigraphs(G);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "GAP 4",
   "language": "gap",
   "name": "gap-4"
  },
  "language_info": {
   "codemirror_mode": "gap",
   "file_extension": ".g",
   "mimetype": "text/x-gap",
   "name": "GAP 4",
   "nbconvert_exporter": "",
   "pygments_lexer": "gap",
   "version": "4.13dev"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}

[ Dauer der Verarbeitung: 0.28 Sekunden  (vorverarbeitet)  ]