Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/pkg/digraphs/doc/   (Algebra von RWTH Aachen Version 4.15.1©)  Datei vom 27.8.2025 mit Größe 348 kB image not shown  

Quelle  chap3.html

  Sprache: HTML
 

 products/Sources/formale Sprachen/GAP/pkg/digraphs/doc/chap3.html


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>GAP (Digraphs) - Chapter 3: Creating digraphs</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="generator" content="GAPDoc2HTML" />
<link rel="stylesheet" type="text/css" href="manual.css" />
<script src="manual.js" type="text/javascript"></script>
<script type="text/javascript">overwriteStyle();</script>
</head>
<body class="chap3"  onload="jscontent()">


<div class="chlinktop"><span class="chlink1">Goto Chapter: </span><a href="chap0.html">Top</a>  <a href="chap1.html">1</a>  <a href="chap2.html">2</a>  <a href="chap3.html">3</a>  <a href="chap4.html">4</a>  <a href="chap5.html">5</a>  <a href="chap6.html">6</a>  <a href="chap7.html">7</a>  <a href="chap8.html">8</a>  <a href="chap9.html">9</a>  <a href="chapA.html">A</a>  <a href="chapB.html">B</a>  <a href="chapBib.html">Bib</a>  <a href="chapInd.html">Ind</a>  </div>

<div class="chlinkprevnexttop"> <a href="chap0.html">[Top of Book]</a>   <a href="chap0.html#contents">[Contents]</a>    <a href="chap2.html">[Previous Chapter]</a>    <a href="chap4.html">[Next Chapter]</a>   </div>

<p id="mathjaxlink" class="pcenter"><a href="chap3_mj.html">[MathJax on]</a></p>
<p><a id="X7D34861E863A5D93" name="X7D34861E863A5D93"></a></p>
<div class="ChapSects"><a href="chap3.html#X7D34861E863A5D93">3 <span class="Heading">Creating digraphs</span></a>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap3.html#X7D34861E863A5D93">3.1 <span class="Heading">Creating digraphs</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7877ADC77F85E630">3.1-1 IsDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7D7EDF83820ED6F5">3.1-2 IsMutableDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7CAFAA89804F80BD">3.1-3 IsImmutableDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7E749324800B38A5">3.1-4 IsCayleyDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X80F1B6D28478D8B9">3.1-5 IsDigraphWithAdjacencyFunction</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X86E798B779515678">3.1-6 DigraphByOutNeighboursType</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X834843057CE86655">3.1-7 Digraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X8023FE387A3AB609">3.1-8 DigraphByAdjacencyMatrix</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7F37B6768349E269">3.1-9 DigraphByEdges</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7B75C1D680757D6F">3.1-10 EdgeOrbitsDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X81BC49B57EAADEFB">3.1-11 DigraphByInNeighbours</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7FCADADC7EC28478">3.1-12 CayleyDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7BB820C9813F035F">3.1-13 ListNamedDigraphs</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap3.html#X83608C407CC8836D">3.2 <span class="Heading">Changing representations</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7FBC4BDB82FBEDD2">3.2-1 AsBinaryRelation</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X86834E307EACC670">3.2-2 AsDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7B335342839E5146">3.2-3 Graph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7C4F13E080EC16B0">3.2-4 AsGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7C5360B2799943F3">3.2-5 AsTransformation</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap3.html#X85126078848B420A">3.3 <span class="Heading">New digraphs from old</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X83D93A8A8251E6F9">3.3-1 DigraphImmutableCopy</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X8399F7427B227228">3.3-2 DigraphImmutableCopyIfImmutable</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X83C51DA182CCEA2F">3.3-3 InducedSubdigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7CAF093B85A93D2F">3.3-4 ReducedDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X829E3EAC7C4B3B1E">3.3-5 MaximalSymmetricSubdigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X79BA6A66846D5A95">3.3-6 MaximalAntiSymmetricSubdigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7DD9766C86D3ED20">3.3-7 UndirectedSpanningForest</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X79C770918610AD97">3.3-8 DigraphShortestPathSpanningTree</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7D1D26D27F5B56C2">3.3-9 QuotientDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X78DECD26811EFD7C">3.3-10 DigraphReverse</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7F71D99D852B130F">3.3-11 DigraphDual</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X874883DD7DD450C4">3.3-12 DigraphSymmetricClosure</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7A6C419080AD41DE">3.3-13 DigraphTransitiveClosure</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X82AD17517E273600">3.3-14 DigraphTransitiveReduction</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X83B2506D79453208">3.3-15 DigraphAddVertex</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X8134BEE7786BD3A7">3.3-16 DigraphAddVertices</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7E58CC4880627658">3.3-17 DigraphAddEdge</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7BE5C7028760B053">3.3-18 DigraphAddEdgeOrbit</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X8693A61B7F752C76">3.3-19 DigraphAddEdges</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7B634A2B83C08B16">3.3-20 DigraphRemoveVertex</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7E290E847A5A299A">3.3-21 DigraphRemoveVertices</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X8433E3BC7E5EA6BF">3.3-22 DigraphRemoveEdge</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X85981D9187F49018">3.3-23 DigraphRemoveEdgeOrbit</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X87093FDA7F88E732">3.3-24 DigraphRemoveEdges</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X79324AF7818C0C02">3.3-25 DigraphRemoveLoops</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7DCCD0247897A3DE">3.3-26 DigraphRemoveAllMultipleEdges</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X792AD1147E2BFCB7">3.3-27 DigraphContractEdge</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7821753D85402A8C">3.3-28 DigraphReverseEdges</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X814F1DFC83DB273F">3.3-29 DigraphDisjointUnion</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7DA997697D310E44">3.3-30 DigraphEdgeUnion</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7DDFC759860E3390">3.3-31 DigraphJoin</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7D625CC87DBFFDED">3.3-32 DigraphCartesianProduct</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X84D24DC9833B54A5">3.3-33 DigraphDirectProduct</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X8160BCC378AF000F">3.3-34 ConormalProduct</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X79FD2AF279F20A72">3.3-35 HomomorphicProduct</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X8151176882BA9901">3.3-36 LexicographicProduct</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X807F95057F9DF576">3.3-37 ModularProduct</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X82E200F07FEFAF27">3.3-38 StrongProduct</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X8795087A78FE7D54">3.3-39 DigraphCartesianProductProjections</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X84FB64F185B804C2">3.3-40 DigraphDirectProductProjections</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X8595BF937B749F22">3.3-41 LineDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X8364C6F17A1680CB">3.3-42 LineUndirectedDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7FB8B48C87C0ED16">3.3-43 DoubleDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7C6E6CB284982C7A">3.3-44 BipartiteDoubleDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X8167A50A83256ED1">3.3-45 DigraphAddAllLoops</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X865436437DF95FEF">3.3-46 DistanceDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X86F9CCEA839ABC48">3.3-47 DigraphClosure</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7B5AC5FE859F4D80">3.3-48 DigraphMycielskian</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap3.html#X85B5D9B97F5187B7">3.4 <span class="Heading">Random digraphs</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X86CF9F66788B2A24">3.4-1 RandomDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X78FE275E7E77D56F">3.4-2 RandomMultiDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7D36B5E57F055051">3.4-3 RandomTournament</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7A023E4787682475">3.4-4 RandomLattice</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap3.html#X7C76D1DC7DAF03D3">3.5 <span class="Heading">Standard examples</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7D5E3E337D03EDFF">3.5-1 AndrasfaiGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X8636C2898395B7DF">3.5-2 BananaTree</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7FC309427BB170D8">3.5-3 BinaryTree</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X845C374280D6EAA4">3.5-4 BinomialTreeGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7E3240047C92733F">3.5-5 BishopsGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X81A0AC37816D287B">3.5-6 BondyGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X861F493382FA7C0B">3.5-7 BookGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X8542287E81BDB55E">3.5-8 BurntPancakeGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X84C1D3D67E3979A5">3.5-9 PancakeGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7B5E9D857D47F5C2">3.5-10 StackedBookGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X870594FC866AC88E">3.5-11 ChainDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7DB5AB657A797CF2">3.5-12 CirculantGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X812417E278198D9C">3.5-13 CompleteDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X8795B0AD856014FA">3.5-14 CompleteBipartiteDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X873F29CC863241F8">3.5-15 CompleteMultipartiteDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X80C29DDE876FFBEB">3.5-16 CycleDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7F6EC0AE81531C3C">3.5-17 CycleGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X80DAE31A79FEFD40">3.5-18 EmptyDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7CE45E2B782ADE9A">3.5-19 GearGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X795B62398767E313">3.5-20 HaarGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X801024F57DDC8A39">3.5-21 HalvedCubeGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7C43BDE47DF6553A">3.5-22 HanoiGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X782ABFCE812B020A">3.5-23 HelmGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7EE552F88609B1A2">3.5-24 HypercubeGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X80ED9CE785819607">3.5-25 JohnsonDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X79483C677AF65688">3.5-26 KellerGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X80576A8C861512FD">3.5-27 KingsGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X8655BA8584B3ACD0">3.5-28 KneserGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X84609DCA79FD9B56">3.5-29 KnightsGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7F61140C822880DA">3.5-30 LindgrenSousselierGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X832E82CF87BF5D43">3.5-31 LollipopGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X853613228110588E">3.5-32 MobiusLadderGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X825943547FD7A687">3.5-33 MycielskiGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7904BB2982014ADA">3.5-34 OddGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X815055168405B7F0">3.5-35 PathGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7A38DFC47AAE4A96">3.5-36 PermutationStarGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X823F43217A6C375D">3.5-37 PetersenGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7B5441F386BD105E">3.5-38 GeneralisedPetersenGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X85425DC5847E6D20">3.5-39 PrismGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X817982877B48D5BD">3.5-40 StackedPrismGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X785C3F1F7D690151">3.5-41 QueensGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7A6DD11881874F51">3.5-42 RooksGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X8404987F849D7CF2">3.5-43 SquareGridGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X8234361278E8816F">3.5-44 TriangularGridGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X78F78C077CBAE1EC">3.5-45 StarGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X81D59C4D809F4AD3">3.5-46 TadpoleGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7BFA33067F83F8B0">3.5-47 WalshHadamardGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X84F3B70A82EEE780">3.5-48 WebGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X817EA60D828A765E">3.5-49 WheelGraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7BE44CA27AA5F8DB">3.5-50 WindmillGraph</a></span>
</div></div>
</div>

<h3>3 <span class="Heading">Creating digraphs</span></h3>

<p>In this chapter we describe how to create digraphs.</p>

<p><a id="X7D34861E863A5D93" name="X7D34861E863A5D93"></a></p>

<h4>3.1 <span class="Heading">Creating digraphs</span></h4>

<p><a id="X7877ADC77F85E630" name="X7877ADC77F85E630"></a></p>

<h5>3.1-1 IsDigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsDigraph</code></td><td class="tdright">( category )</td></tr></table></div>
<p>Every digraph in <strong class="pkg">Digraphs</strong> belongs to the category <code class="code">IsDigraph</code>. Some basic attributes and operations for digraphs are <code class="func">DigraphVertices</code> (<a href="chap5.html#X7C45F7D878D896AC"><span class="RefLink">5.1-1</span></a>), <code class="func">DigraphEdges</code> (<a href="chap5.html#X7D1C6A4D7ECEC317"><span class="RefLink">5.1-3</span></a>), and <code class="func">OutNeighbours</code> (<a href="chap5.html#X7E9880767AE68E00"><span class="RefLink">5.2-6</span></a>).</p>

<p><a id="X7D7EDF83820ED6F5" name="X7D7EDF83820ED6F5"></a></p>

<h5>3.1-2 IsMutableDigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsMutableDigraph</code></td><td class="tdright">( category )</td></tr></table></div>
<p><code class="code">IsMutableDigraph</code> is a synonym for <code class="func">IsDigraph</code> (<a href="chap3.html#X7877ADC77F85E630"><span class="RefLink">3.1-1</span></a>) and <code class="func">IsMutable</code> (<a href="/home/runner/gap/doc/ref/chap12.html#X7999AD1D7A4F1F46"><span class="RefLink">Reference: IsMutable</span></a>). A mutable digraph may be changed in-place by methods in the <strong class="pkg">Digraphs</strong> package, and is not attribute-storing – see <code class="func">IsAttributeStoringRep</code> (<a href="/home/runner/gap/doc/ref/chap13.html#X7A951C33839AF2C1"><span class="RefLink">Reference: IsAttributeStoringRep</span></a>).</p>

<p>A mutable digraph may be converted into an immutable attribute-storing digraph by calling <code class="func">MakeImmutable</code> (<a href="/home/runner/gap/doc/ref/chap12.html#X80CE136D804097C7"><span class="RefLink">Reference: MakeImmutable</span></a>) on the digraph.</p>

<p><a id="X7CAFAA89804F80BD" name="X7CAFAA89804F80BD"></a></p>

<h5>3.1-3 IsImmutableDigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsImmutableDigraph</code></td><td class="tdright">( category )</td></tr></table></div>
<p><code class="code">IsImmutableDigraph</code> is a subcategory of <code class="func">IsDigraph</code> (<a href="chap3.html#X7877ADC77F85E630"><span class="RefLink">3.1-1</span></a>). Digraphs that lie in <code class="code">IsImmutableDigraph</code> are immutable and attribute-storing. In particular, they lie in <code class="func">IsAttributeStoringRep</code> (<a href="/home/runner/gap/doc/ref/chap13.html#X7A951C33839AF2C1"><span class="RefLink">Reference: IsAttributeStoringRep</span></a>).</p>

<p>A mutable digraph may be converted to an immutable digraph that lies in the category <code class="code">IsImmutableDigraph</code> by calling <code class="func">MakeImmutable</code> (<a href="/home/runner/gap/doc/ref/chap12.html#X80CE136D804097C7"><span class="RefLink">Reference: MakeImmutable</span></a>) on the digraph.</p>

<p>The operation <code class="func">DigraphMutableCopy</code> (<a href="chap3.html#X83D93A8A8251E6F9"><span class="RefLink">3.3-1</span></a>) can be used to construct a mutable copy of an immutable digraph. It is however not possible to convert an immutable digraph into a mutable digraph in-place.</p>

<p><a id="X7E749324800B38A5" name="X7E749324800B38A5"></a></p>

<h5>3.1-4 IsCayleyDigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsCayleyDigraph</code></td><td class="tdright">( category )</td></tr></table></div>
<p><code class="code">IsCayleyDigraph</code> is a subcategory of <code class="code">IsDigraph</code>. Digraphs that are Cayley digraphs of a group and that are constructed by the operation <code class="func">CayleyDigraph</code> (<a href="chap3.html#X7FCADADC7EC28478"><span class="RefLink">3.1-12</span></a>) are constructed in this category, and are always immutable.</p>

<p><a id="X80F1B6D28478D8B9" name="X80F1B6D28478D8B9"></a></p>

<h5>3.1-5 IsDigraphWithAdjacencyFunction</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsDigraphWithAdjacencyFunction</code></td><td class="tdright">( category )</td></tr></table></div>
<p><code class="code">IsDigraphWithAdjacencyFunction</code> is a subcategory of <code class="code">IsDigraph</code>. Digraphs that are <em>created</em> using an adjacency function are constructed in this category.</p>

<p><a id="X86E798B779515678" name="X86E798B779515678"></a></p>

<h5>3.1-6 DigraphByOutNeighboursType</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphByOutNeighboursType</code></td><td class="tdright">( global variable )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphFamily</code></td><td class="tdright">( family )</td></tr></table></div>
<p>The type of all digraphs is <code class="code">DigraphByOutNeighboursType</code>. The family of all digraphs is <code class="code">DigraphFamily</code>.</p>

<p><a id="X834843057CE86655" name="X834843057CE86655"></a></p>

<h5>3.1-7 Digraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Digraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">obj</var>[, <var class="Arg">source</var>, <var class="Arg">range</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Digraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">list</var>, <var class="Arg">func</var)</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Digraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">G</var>, <var class="Arg">list</var>, <var class="Arg">act</var>, <var class="Arg">adj</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<dl>
<dt><strong class="Mark">for a list (i.e. an adjacency list)</strong></dt>
<dd><p>if <var class="Arg">obj</var> is a list of lists of positive integers in the range from <code class="code">1</code> to <code class="code">Length(<var class="Arg">obj</var>)</code>, then this function returns the digraph with vertices <span class="SimpleMath">E ^ 0 =</span><code class="code">[1 .. Length(<var class="Arg">obj</var>)]</code>, and edges corresponding to the entries of <var class="Arg">obj</var>.</p>

<p>More precisely, there is an edge from vertex <code class="code">i</code> to <code class="code">j</code> if and only if <code class="code">j</code> is in <code class="code"><var class="Arg">obj</var>[i]</code>; the source of this edge is <code class="code">i</code> and the range is <code class="code">j</code>. If <code class="code">j</code> occurs in <code class="code"><var class="Arg">obj</var>[i]</codewith multiplicity <code class="code">k</code>, then there are <code class="code">k</code> edges from <code class="code">i</code> to <code class="code">j</code>.</p>

</dd>
<dt><strong class="Mark">for three lists</strong></dt>
<dd><p>if <var class="Arg">obj</var> is a duplicate-free list, and <var class="Arg">source</var> and <var class="Arg">range</var> are lists of equal length consisting of positive integers in the list <code class="code">[1 .. Length(<var class="Arg">obj</var>)]</code>, then this function returns a digraph with vertices <span class="SimpleMath">E ^ 0 =</span><code class="code">[1 .. Length(<var class="Arg">obj</var>)]</code>, and <code class="code">Length(<var class="Arg">source</var>)</code> edges. For each <code class="code">i</code> in <code class="code">[1 .. Length(<var class="Arg">source</var>)]</code> there exists an edge with source vertex <code class="code">source[i]</code> and range vertex <code class="code">range[i]</code>. See <code class="func">DigraphSource</code> (<a href="chap5.html#X7FDEBF3279759961"><span class="RefLink">5.2-5</span></a>) and <code class="func">DigraphRange</code> (<a href="chap5.html#X7FDEBF3279759961"><span class="RefLink">5.2-5</span></a>).</p>

<p>The vertices of the digraph will be labelled by the elements of <var class="Arg">obj</var>.</p>

</dd>
<dt><strong class="Mark">for an integer, and two lists</strong></dt>
<dd><p>if <var class="Arg">obj</var> is an integer, and <var class="Arg">source</var> and <var class="Arg">range</var> are lists of equal length consisting of positive integers in the list <code class="code">[1 .. <var class="Arg">obj</var>]</code>, then this function returns a digraph with vertices <span class="SimpleMath">E ^ 0 =</span><code class="code">[1 .. <var class="Arg">obj</var>]</code>, and <code class="code">Length(<var class="Arg">source</var>)</code> edges. For each <code class="code">i</code> in <code class="code">[1 .. Length(<var class="Arg">source</var>)]</code> there exists an edge with source vertex <code class="code">source[i]</code> and range vertex <code class="code">range[i]</code>. See <code class="func">DigraphSource</code> (<a href="chap5.html#X7FDEBF3279759961"><span class="RefLink">5.2-5</span></a>) and <code class="func">DigraphRange</code> (<a href="chap5.html#X7FDEBF3279759961"><span class="RefLink">5.2-5</span></a>).</p>

</dd>
<dt><strong class="Mark">for a list and a function</strong></dt>
<dd><p>if <var class="Arg">list</var> is a list and <var class="Arg">func</var> is a function taking 2 arguments that are elements of <var class="Arg">list</var>, and <var class="Arg">func</var> returns <code class="keyw">true</code> or <code class="keyw">false</code>, then this operation creates a digraph with vertices <code class="code">[1 .. Length(<var class="Arg">list</var>)]</code> and an edge from vertex <code class="code">i</code> to vertex <code class="code">j</code> if and only if <code class="code"><var class="Arg">func</var>(<var class="Arg">list</var>[i], <var class="Arg">list</var>[j])</code> returns <code class="keyw">true</code>.</p>

</dd>
<dt><strong class="Mark">for a group, a list, and two functions</strong></dt>
<dd><p>The arguments will be <var class="Arg">G, list, act, adj</var>.</p>

<p>Let <var class="Arg">G</var> be a group acting on the objects in <var class="Arg">list</var> via the action <var class="Arg">act</var>, and let <var class="Arg">adj</var> be a function taking two objects from <var class="Arg">list</var> as arguments and returning <code class="code">true</code> or <code class="code">false</code>. The function <var class="Arg">adj</var> will describe the adjacency between objects from <var class="Arg">list</var>, which is invariant under the action of <var class="Arg">G</var>. This variant of the constructor returns a digraph with vertices the objects of <var class="Arg">list</var> and directed edges <code class="code">[x, y]</code> when <code class="code">f(x, y)</code> is <code class="code">true</code>.</p>

<p>The action of the group <var class="Arg">G</var> on the objects in <var class="Arg">list</var> is stored in the attribute <code class="func">DigraphGroup</code> (<a href="chap7.html#X803ACEDA7BBAC5B3"><span class="RefLink">7.2-10</span></a>), and is used to speed up operations like <code class="func">DigraphDiameter</code> (<a href="chap5.html#X7F16B9EB8398459C"><span class="RefLink">5.4-1</span></a>).</p>

</dd>
<dt><strong class="Mark">for a Grape package graph</strong></dt>
<dd><p>if <var class="Arg">obj</var> is a <span class="URL"><a href="https://gap-packages.github.io/grape">GRAPE</a></span> package graph (i.e. a record for which the function <code class="code">IsGraph</code> returns <code class="keyw">true</code>), then this function returns a digraph isomorphic to <var class="Arg">obj</var>.</p>

</dd>
<dt><strong class="Mark">for a binary relation</strong></dt>
<dd><p>if <var class="Arg">obj</var> is a binary relation on the points <code class="code">[1 .. n]</code> for some positive integer <span class="SimpleMath">n</span>, then this function returns the digraph defined by <var class="Arg">obj</var>. Specifically, this function returns a digraph which has <span class="SimpleMath">n</span> vertices, and which has an edge with source <code class="code">i</code> and range <code class="code">j</code> if and only if <code class="code">[i,j]</code> is a pair in the binary relation <var class="Arg">obj</var>.</p>

</dd>
<dt><strong class="Mark">for a string naming a digraph</strong></dt>
<dd><p>if <var class="Arg">obj</var> is a non-empty string, then this function returns the digraph that has name <var class="Arg">obj</var>. <strong class="pkg">Digraphs</strong> comes with a database containing a few hundred common digraph names that can be loaded in this way. Valid names include <code class="code">"folkman"</code>, <code class="code">"diamond"</code> and <code class="code">"brinkmann"</code>. If the name is commonly followed by the word <code class="code">"graph"</code>, then it is called without writing <code class="code">"graph"</code> at the end. You can explore the available graph names using <code class="func">ListNamedDigraphs</code> (<a href="chap3.html#X7BB820C9813F035F"><span class="RefLink">3.1-13</span></a>). Digraph names are case and whitespace insensitive.</p>

<p>Note that any undirected graphs in the database are stored as symmetric digraphs, so the resulting digraph will have twice as many edges as its undirected counterpart.</p>

</dd>
</dl>

<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">gr := Digraph([</span>
<span class="GAPprompt">></span> <span class="GAPinput">[2, 5, 8, 10], [2, 3, 4, 2, 5, 6, 8, 9, 10], [1],</span>
<span class="GAPprompt">></span> <span class="GAPinput">[3, 5, 7, 8, 10], [2, 5, 7], [3, 6, 7, 9, 10], [1, 4],</span>
<span class="GAPprompt">></span> <span class="GAPinput">[1, 5, 9], [1, 2, 7, 8], [3, 5]]);</span>
<immutable multidigraph with 10 vertices, 38 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">gr := Digraph(["a""b""c"], ["a"], ["b"]);</span>
<immutable digraph with 3 vertices, 1 edge>
<span class="GAPprompt">gap></span> <span class="GAPinput">gr := Digraph(5, [1, 2, 2, 4, 1, 1], [2, 3, 5, 5, 1, 1]);</span>
<immutable multidigraph with 5 vertices, 6 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">Petersen := Graph(SymmetricGroup(5), [[1, 2]], OnSets,</span>
<span class="GAPprompt">></span> <span class="GAPinput">function(x, y) return Intersection(x, y) = []; end);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">Digraph(Petersen);</span>
<immutable digraph with 10 vertices, 30 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">gr := Digraph([1 .. 10], ReturnTrue);</span>
<immutable digraph with 10 vertices, 100 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">Digraph("Diamond");</span>
<immutable digraph with 4 vertices, 10 edges></pre></div>

<p>The next example illustrates the uses of the fourth and fifth variants of this constructor. The resulting digraph is a strongly regular graph, and it is actually the point graph of the van Lint-Schrijver partial geometry, <a href="chapBib.html#biBvLS81">[vLS81]</a>. The algebraic description is taken from the seminal paper of Calderbank and Kantor <a href="chapBib.html#biBCK86">[CK86]</a>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">f := GF(3 ^ 4);</span>
GF(3^4)
<span class="GAPprompt">gap></span> <span class="GAPinput">gamma := First(f, x -> Order(x) = 5);</span>
Z(3^4)^64
<span class="GAPprompt">gap></span> <span class="GAPinput">L := Union([Zero(f)], List(Group(gamma)));</span>
[ 0*Z(3), Z(3)^0, Z(3^4)^16, Z(3^4)^32, Z(3^4)^48, Z(3^4)^64 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">omega := Union(List(L, x -> List(Difference(L, [x]), y -> x - y)));</span>
[ Z(3)^0, Z(3), Z(3^4)^5, Z(3^4)^7, Z(3^4)^8, Z(3^4)^13, Z(3^4)^15, 
  Z(3^4)^16, Z(3^4)^21, Z(3^4)^23, Z(3^4)^24, Z(3^4)^29, Z(3^4)^31, 
  Z(3^4)^32, Z(3^4)^37, Z(3^4)^39, Z(3^4)^45, Z(3^4)^47, Z(3^4)^48, 
  Z(3^4)^53, Z(3^4)^55, Z(3^4)^56, Z(3^4)^61, Z(3^4)^63, Z(3^4)^64, 
  Z(3^4)^69, Z(3^4)^71, Z(3^4)^72, Z(3^4)^77, Z(3^4)^79 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">adj := function(x, y)</span>
<span class="GAPprompt">></span> <span class="GAPinput">  return x - y in omega;</span>
<span class="GAPprompt">></span> <span class="GAPinput">end;</span>
function( x, y ) ... end
<span class="GAPprompt">gap></span> <span class="GAPinput">digraph := Digraph(AsList(f), adj);</span>
<immutable digraph with 81 vertices, 2430 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">group := Group(Z(3));;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">act := \*;</span>
<Operation "*">
<span class="GAPprompt">gap></span> <span class="GAPinput">digraph := Digraph(group, List(f), act, adj);</span>
<immutable digraph with 81 vertices, 2430 edges>
</pre></div>

<p><a id="X8023FE387A3AB609" name="X8023FE387A3AB609"></a></p>

<h5>3.1-8 DigraphByAdjacencyMatrix</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphByAdjacencyMatrix</code>( [<var class="Arg">filt</var>, ]<var class="Arg">list</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>

<p>If <var class="Arg">list</var> is the adjacency matrix of a digraph in the sense of <code class="func">AdjacencyMatrix</code> (<a href="chap5.html#X7DC2CD70830BEE60"><span class="RefLink">5.2-1</span></a>), then this operation returns the digraph which is defined by <var class="Arg">list</var>.</p>

<p>Alternatively, if <var class="Arg">list</var> is a square boolean matrix, then this operation returns the digraph with <code class="code">Length(</code><var class="Arg">list</var><code class="code">)</code> vertices which has the edge <code class="code">[i,j]</code> if and only if <var class="Arg">list</var><code class="code">[i][j]</code> is <code class="keyw">true</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphByAdjacencyMatrix([</span>
<span class="GAPprompt">></span> <span class="GAPinput">[0, 1, 0, 2, 0],</span>
<span class="GAPprompt">></span> <span class="GAPinput">[1, 1, 1, 0, 1],</span>
<span class="GAPprompt">></span> <span class="GAPinput">[0, 3, 2, 1, 1],</span>
<span class="GAPprompt">></span> <span class="GAPinput">[0, 0, 1, 0, 1],</span>
<span class="GAPprompt">></span> <span class="GAPinput">[2, 0, 0, 0, 0]]);</span>
<immutable multidigraph with 5 vertices, 18 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphByAdjacencyMatrix([</span>
<span class="GAPprompt">></span> <span class="GAPinput">[true, false, true],</span>
<span class="GAPprompt">></span> <span class="GAPinput">[false, false, true],</span>
<span class="GAPprompt">></span> <span class="GAPinput">[false, true, false]]);</span>
<immutable digraph with 3 vertices, 4 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(D);</span>
[ [ 1, 3 ], [ 3 ], [ 2 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphByAdjacencyMatrix(IsMutableDigraph, </span>
<span class="GAPprompt">></span> <span class="GAPinput">[[true, false, true],</span>
<span class="GAPprompt">></span> <span class="GAPinput"> [false, false, true],</span>
<span class="GAPprompt">></span> <span class="GAPinput"> [false, true, false]]);</span>
<mutable digraph with 3 vertices, 4 edges>
</pre></div>

<p><a id="X7F37B6768349E269" name="X7F37B6768349E269"></a></p>

<h5>3.1-9 DigraphByEdges</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphByEdges</code>( [<var class="Arg">filt</var>, ]<var class="Arg">list</var>[, <var class="Arg">n</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>

<p>If <var class="Arg">list</var> is list of pairs of positive integers, then this function returns the digraph with the minimum number of vertices <code class="code">m</code> such that its list equal <var class="Arg">list</var>.</p>

<p>If the optional second argument <var class="Arg">n</var> is a positive integer with <code class="code"><var class="Arg">n</var> >= m</code> (with <code class="code">m</code> defined as above), then this function returns the digraph with <var class="Arg">n</var> vertices and list <var class="Arg">list</var>.</p>

<p>See <code class="func">DigraphEdges</code> (<a href="chap5.html#X7D1C6A4D7ECEC317"><span class="RefLink">5.1-3</span></a>).</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphByEdges(</span>
<span class="GAPprompt">></span> <span class="GAPinput">[[1, 3], [2, 1], [2, 3], [2, 5], [3, 6],</span>
<span class="GAPprompt">></span> <span class="GAPinput"> [4, 6], [5, 2], [5, 4], [5, 6], [6, 6]]);</span>
<immutable digraph with 6 vertices, 10 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphByEdges(</span>
<span class="GAPprompt">></span> <span class="GAPinput">[[1, 3], [2, 1], [2, 3], [2, 5], [3, 6],</span>
<span class="GAPprompt">></span> <span class="GAPinput"> [4, 6], [5, 2], [5, 4], [5, 6], [6, 6]], 12);</span>
<immutable digraph with 12 vertices, 10 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphByEdges(IsMutableDigraph, </span>
<span class="GAPprompt">></span> <span class="GAPinput">[[1, 3], [2, 1], [2, 3], [2, 5], [3, 6],</span>
<span class="GAPprompt">></span> <span class="GAPinput"> [4, 6], [5, 2], [5, 4], [5, 6], [6, 6]], 12);</span>
<mutable digraph with 12 vertices, 10 edges>
</pre></div>

<p><a id="X7B75C1D680757D6F" name="X7B75C1D680757D6F"></a></p>

<h5>3.1-10 EdgeOrbitsDigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ EdgeOrbitsDigraph</code>( <var class="Arg">G</var>, <var class="Arg">edges</var>[, <var class="Arg">n</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: An immutable digraph.</p>

<p>If <var class="Arg">G</var> is a permutation group, <var class="Arg">edges</var> is an edge or list of edges, and <var class="Arg">n</var> is a non-negative integer such that <var class="Arg">G</var> fixes <code class="code">[1 .. <var class="Arg">n</var>]</code> setwise, then this operation returns an immutable digraph with <var class="Arg">n</var> vertices and the union of the orbits of the edges in <var class="Arg"> edges </var> under the action of the permutation group <var class="Arg">G</var>. An edge in this context is simply a pair of positive integers.</p>

<p>If the optional third argument <var class="Arg">n</var> is not present, then the largest moved point of the permutation group <var class="Arg">G</var> is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">digraph := EdgeOrbitsDigraph(Group((1, 3), (1, 2)(3, 4)),</span>
<span class="GAPprompt">></span> <span class="GAPinput">                                [[1, 2], [4, 5]], 5);</span>
<immutable digraph with 5 vertices, 12 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(digraph);</span>
[ [ 2, 4, 5 ], [ 1, 3, 5 ], [ 2, 4, 5 ], [ 1, 3, 5 ], [  ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">RepresentativeOutNeighbours(digraph);</span>
[ [ 2, 4, 5 ], [  ] ]
</pre></div>

<p><a id="X81BC49B57EAADEFB" name="X81BC49B57EAADEFB"></a></p>

<h5>3.1-11 DigraphByInNeighbours</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphByInNeighbours</code>( [<var class="Arg">filt</var>, ]<var class="Arg">list</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphByInNeighbors</code>( [<var class="Arg">filt</var>, ]<var class="Arg">list</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>

<p>If <var class="Arg">list</var> is a list of lists of positive integers list the range <code class="code">[1 .. Length(<var class="Arg">list</var>)]</code>, then this function returns the digraph with vertices <span class="SimpleMath">E^0=</span><code class="code">[1 .. Length(<var class="Arg">list</var>)]</code>, and edges corresponding to the entries of <var class="Arg">list</var>. More precisely, there is an edge with source vertex <code class="code">i</code> and range vertex <code class="code">j</code> if <code class="code">i</code> is in the list <code class="code"><var class="Arg">list</var>[j]</code>.</p>

<p>If <code class="code">i</code> occurs in the list <code class="code"><var class="Arg">list</var>[j]</code> with multiplicity <code class="code">k</code>, then there are <code class="code">k</code> multiple edges from <code class="code">i</code> to <code class="code">j</code>.</p>

<p>See <code class="func">InNeighbours</code> (<a href="chap5.html#X85C7AA5A81DA6E11"><span class="RefLink">5.2-7</span></a>).</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphByInNeighbours([</span>
<span class="GAPprompt">></span> <span class="GAPinput">[2, 5, 8, 10], [2, 3, 4, 5, 6, 8, 9, 10],</span>
<span class="GAPprompt">></span> <span class="GAPinput">[1], [3, 5, 7, 8, 10], [2, 5, 7], [3, 6, 7, 9, 10], [1, 4],</span>
<span class="GAPprompt">></span> <span class="GAPinput">[1, 5, 9], [1, 2, 7, 8], [3, 5]]);</span>
<immutable digraph with 10 vertices, 37 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphByInNeighbours([[2, 3, 2], [1], [1, 2, 3]]);</span>
<immutable multidigraph with 3 vertices, 7 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphByInNeighbours(IsMutableDigraph, </span>
<span class="GAPprompt">></span> <span class="GAPinput">                              [[2, 3, 2], [1], [1, 2, 3]]);</span>
<mutable multidigraph with 3 vertices, 7 edges>
</pre></div>

<p><a id="X7FCADADC7EC28478" name="X7FCADADC7EC28478"></a></p>

<h5>3.1-12 CayleyDigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ CayleyDigraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">G</var>[, <var class="Arg">gens</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>Let <var class="Arg">G</var> be any group and let <var class="Arg">gens</var> be a list of elements of <var class="Arg">G</var>. This operation returns a digraph that corresponds to the Cayley graph of <var class="Arg">G</var> with respect to <var class="Arg">gens</var>.</p>

<p>The vertices of the digraph correspond to the elements of <var class="Arg">G</var>, in the order given by <code class="code">Set(<var class="Arg">G</var>)</code>. There exists an edge from vertex <code class="code">u</code> to vertex <code class="code">v</code> if and only if there exists a generator <code class="code">g</code> in <var class="Arg">gens</var> such that <code class="code">Set(<var class="Arg">G</var>)[u] * g = Set(<var class="Arg">G</var>)[v]</code>.</p>

<p>The labels of the vertices <code class="code">u</code>, <code class="code">v</code>, and the edge <code class="code">[u, v]</code> are the corresponding elements <code class="code">AsList(<var class="Arg">G</var>)[u]</code>, <code class="code">AsList(<var class="Arg">G</var>)[v]</code>, and generator <code class="code">g</code>, respectively; see <code class="func">DigraphVertexLabel</code> (<a href="chap5.html#X7CA91E4B7904F793"><span class="RefLink">5.1-11</span></a>) and <code class="func">DigraphEdgeLabel</code> (<a href="chap5.html#X79FAEACC7F438C2F"><span class="RefLink">5.1-13</span></a>).</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>

<p>If the optional third argument <var class="Arg">gens</var> is not present, then the generators of <var class="Arg">G</var> are used by default.</p>

<p>The digraph created by this operation belongs to the category <code class="func">IsCayleyDigraph</code> (<a href="chap3.html#X7E749324800B38A5"><span class="RefLink">3.1-4</span></a>), the group <var class="Arg">G</var> can be recovered from the digraph using <code class="func">GroupOfCayleyDigraph</code> (<a href="chap5.html#X7A000B1D7CCF7093"><span class="RefLink">5.5-1</span></a>), and the generators <var class="Arg">gens</var> can be obtained using <code class="func">GeneratorsOfCayleyDigraph</code> (<a href="chap5.html#X8528455987D7D2BF"><span class="RefLink">5.5-2</span></a>).</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">G := DihedralGroup(8);</span>
<pc group of size 8 with 3 generators>
<span class="GAPprompt">gap></span> <span class="GAPinput">CayleyDigraph(G);</span>
<immutable digraph with 8 vertices, 24 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">G := DihedralGroup(IsPermGroup, 8);</span>
Group([ (1,2,3,4), (2,4) ])
<span class="GAPprompt">gap></span> <span class="GAPinput">CayleyDigraph(G);</span>
<immutable digraph with 8 vertices, 16 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">digraph := CayleyDigraph(G, [()]);</span>
<immutable digraph with 8 vertices, 8 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">GroupOfCayleyDigraph(digraph) = G;</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">GeneratorsOfCayleyDigraph(digraph);</span>
[ () ]
<span class="GAPprompt">gap></span> <span class="GAPinput">digraph := CayleyDigraph(IsMutable, G, [()]);</span>
<mutable digraph with 8 vertices, 8 edges>
</pre></div>

<p><a id="X7BB820C9813F035F" name="X7BB820C9813F035F"></a></p>

<h5>3.1-13 ListNamedDigraphs</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ListNamedDigraphs</code>( <var class="Arg">s</var>[, <var class="Arg">level</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A list of strings representing digraph names.</p>

<p>This function searches through the list of names that are currently in the <strong class="pkg">Digraphs</strong> database of named digraphs. The first argument <var class="Arg">s</var> should be a partially completed string; this function returns all completions <code class="code">str</code> of the string <var class="Arg">s</var> such that <code class="code">Digraph(str)</code> will successfully return a digraph.</p>

<p>The optional second argument <var class="Arg">level</var> controls the flexibility of the search. If <code class="code"><var class="Arg">level</var> = 1</code>, then only strings beginning exactly with <var class="Arg">s</var> are returned. If <code class="code"><var class="Arg">level</var> = 2</code>, then all names containing <var class="Arg">s</var> as a substring are returned. If <code class="code"><var class="Arg">level</var> = 3</code>, then once again a substring search is carried out, but characters that are not alphanumeric are ignored in the search.</p>

<p>If <var class="Arg">level</var> is not specified, it is set by default to equal 2.</p>

<p>The search is always case and whitespace insensitive, and this is also the case when applying <code class="func">Digraph</code> (<a href="chap3.html#X834843057CE86655"><span class="RefLink">3.1-7</span></a>) to a string.</p>

<p><a id="X83608C407CC8836D" name="X83608C407CC8836D"></a></p>

<h4>3.2 <span class="Heading">Changing representations</span></h4>

<p><a id="X7FBC4BDB82FBEDD2" name="X7FBC4BDB82FBEDD2"></a></p>

<h5>3.2-1 AsBinaryRelation</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ AsBinaryRelation</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A binary relation.</p>

<p>If <var class="Arg">digraph</var> is a digraph with a positive number of vertices <span class="SimpleMath">n</span>, and no multiple edges, then this operation returns a binary relation on the points <code class="code">[1..n]</code>. The pair <code class="code">[i,j]</code> is in the binary relation if and only if <code class="code">[i,j]</code> is an edge in <var class="Arg">digraph</var>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[3, 2], [1, 2], [2], [3, 4]]);</span>
<immutable digraph with 4 vertices, 7 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">AsBinaryRelation(D);</span>
Binary Relation on 4 points
</pre></div>

<p><a id="X86834E307EACC670" name="X86834E307EACC670"></a></p>

<h5>3.2-2 AsDigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ AsDigraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">f</var>[, <var class="Arg">n</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph, or <code class="keyw">fail</code>.</p>

<p>If <var class="Arg">f</var> is a binary relation represented as one of the following in <strong class="pkg">GAP</strong>:</p>


<dl>
<dt><strong class="Mark">
          a transformation
        </strong></dt>
<dd><p>satisfying <code class="func">IsTransformation</code> (<a href="/home/runner/gap/doc/ref/chap53.html#X7B6259467974FB70"><span class="RefLink">Reference: IsTransformation</span></a>);</p>

</dd>
<dt><strong class="Mark">
          a permutation
        </strong></dt>
<dd><p>satisfying <code class="func">IsPerm</code> (<a href="/home/runner/gap/doc/ref/chap42.html#X7AA69C6686FC49EA"><span class="RefLink">Reference: IsPerm</span></a>);</p>

</dd>
<dt><strong class="Mark">
          a partial perm
        </strong></dt>
<dd><p>satisfying <code class="func">IsPartialPerm</code> (<a href="/home/runner/gap/doc/ref/chap54.html#X7EECE133792B30FC"><span class="RefLink">Reference: IsPartialPerm</span></a>);</p>

</dd>
<dt><strong class="Mark">
          a binary relation
        </strong></dt>
<dd><p>satisfying <code class="func">IsBinaryRelation</code> (<a href="/home/runner/gap/doc/ref/chap33.html#X788D722F82165551"><span class="RefLink">Reference: IsBinaryRelation</span></a>);</p>

</dd>
</dl>
<p>and <var class="Arg">n</var> is a non-negative integer, then <code class="code">AsDigraph</codeattempts to construct a digraph with <var class="Arg">n</var> vertices whose edges are determined by <var class="Arg">f</var>.</p>

<p>The digraph returned by <code class="code">AsDigraph</code> has for each vertex <code class="code">v</code> in <code class="code">[1 .. <var class="Arg">n</var>]</code>, an edge with source <code class="code">v</code> and range <code class="code">v ^ <var class="Arg">f</var></code>. If <code class="code">v ^ <var class="Arg">f</var></code> is greater than <var class="Arg">n</var> for any <code class="code">v</code>, then <code class="keyw">fail</code> is returned.</p>

<p>If the optional second argument <var class="Arg">n</var> is not supplied, then the degree of the transformation <var class="Arg">f</var>, the largest moved point of the permutation <var class="Arg">f</var>, the maximum of the degree and the codegree of the partial perm <var class="Arg">f</var>, or as applicable, is used by default.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">f := Transformation([4, 3, 3, 1, 7, 9, 10, 4, 2, 3]);</span>
Transformation( [ 4, 3, 3, 1, 7, 9, 10, 4, 2, 3 ] )
<span class="GAPprompt">gap></span> <span class="GAPinput">AsDigraph(f);</span>
<immutable functional digraph with 10 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">AsDigraph(f, 4);</span>
<immutable functional digraph with 4 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">AsDigraph(f, 5);</span>
fail
<span class="GAPprompt">gap></span> <span class="GAPinput">AsDigraph((1, 2, 3, 4)) = CycleDigraph(4);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">D := AsDigraph(IsMutableDigraph, (1, 3)(2, 4), 5);</span>
<mutable digraph with 5 vertices, 5 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphEdges(D);</span>
[ [ 1, 3 ], [ 2, 4 ], [ 3, 1 ], [ 4, 2 ], [ 5, 5 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">b := BinaryRelationOnPoints(</span>
<span class="GAPprompt">></span> <span class="GAPinput">[[3], [1, 3, 5], [1], [1, 2, 4], [2, 3, 5]]);</span>
Binary Relation on 5 points
<span class="GAPprompt">gap></span> <span class="GAPinput">D := AsDigraph(b);</span>
<immutable digraph with 5 vertices, 11 edges>
</pre></div>

<p><a id="X7B335342839E5146" name="X7B335342839E5146"></a></p>

<h5>3.2-3 Graph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Graph</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A <span class="URL"><a href="https://gap-packages.github.io/grape">GRAPE</a></span> package graph.</p>

<p>If <var class="Arg">digraph</var> is a mutable or immutable digraph without multiple edges, then this operation returns a <span class="URL"><a href="https://gap-packages.github.io/grape">GRAPE</a></span> package graph that is isomorphic to <var class="Arg">digraph</var>.</p>

<p>If <var class="Arg">digraph</var> is a multidigraph, then since <span class="URL"><a href="https://gap-packages.github.io/grape">GRAPE</a></span> does not support multiple edges, the multiple edges will be reduced to a single edge in the result. In order words, for a multidigraph this operation will return the same as <code class="code">Graph(DigraphRemoveAllMultipleEdges(</code><var class="Arg">digraph</var><code class="code">))</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Petersen := Graph(SymmetricGroup(5), [[1, 2]], OnSets,</span>
<span class="GAPprompt">></span> <span class="GAPinput">function(x, y) return Intersection(x, y) = []; end);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">Display(Petersen);</span>
rec(
  adjacencies := [ [ 3, 5, 8 ] ],
  group := 
   Group( [ ( 1, 2, 3, 5, 7)( 4, 6, 8, 9,10), ( 2, 4)( 6, 9)( 7,10) 
     ] ),
  isGraph := true,
  names := [ [ 1, 2 ], [ 2, 3 ], [ 3, 4 ], [ 1, 3 ], [ 4, 5 ], 
      [ 2, 4 ], [ 1, 5 ], [ 3, 5 ], [ 1, 4 ], [ 2, 5 ] ],
  order := 10,
  representatives := [ 1 ],
  schreierVector := [ -1, 1, 1, 2, 1, 1, 1, 1, 2, 2 ] )
<span class="GAPprompt">gap></span> <span class="GAPinput">Digraph(Petersen);</span>
<immutable digraph with 10 vertices, 30 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">Graph(last) = Petersen;</span>
true</pre></div>

<p><a id="X7C4F13E080EC16B0" name="X7C4F13E080EC16B0"></a></p>

<h5>3.2-4 AsGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ AsGraph</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>Returns: A <span class="URL"><a href="https://gap-packages.github.io/grape">GRAPE</a></span> package graph.</p>

<p>If <var class="Arg">digraph</var> is a digraph, then this method returns the same as <code class="func">Graph</code> (<a href="chap3.html#X7B335342839E5146"><span class="RefLink">3.2-3</span></a>), except that if <var class="Arg">digraph</var> is immutable, then the result will be stored as a mutable attribute of <var class="Arg">digraph</var>. In this latter case, when <code class="code">AsGraph(</code><var class="Arg">digraph</var><code class="code">)</code> is called subsequently, the same <strong class="pkg">GAP</strongobject will be returned as before.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[1, 2], [3], []]);</span>
<immutable digraph with 3 vertices, 3 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">G := AsGraph(D);</span>
rec( adjacencies := [ [ 1, 2 ], [ 3 ], [  ] ], group := Group(()), 
  isGraph := true, names := [ 1 .. 3 ], order := 3, 
  representatives := [ 1, 2, 3 ], schreierVector := [ -1, -2, -3 ] )
</pre></div>

<p><a id="X7C5360B2799943F3" name="X7C5360B2799943F3"></a></p>

<h5>3.2-5 AsTransformation</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ AsTransformation</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>Returns: A transformation, or <code class="keyw">fail</code></p>

<p>If <var class="Arg">digraph</var> is a functional digraph, then <code class="code">AsTransformation</code> returns the transformation which is defined by <var class="Arg">digraph</var>. See <code class="func">IsFunctionalDigraph</code> (<a href="chap6.html#X7E8F37E585DAED52"><span class="RefLink">6.2-9</span></a>). Otherwise, <code class="code">AsTransformation(</code><var class="Arg">digraph</var><code class="code">)</code> returns <code class="keyw">fail</code>.</p>

<p>If <var class="Arg">digraph</var> is a functional digraph with <span class="SimpleMath">n</spanvertices, then <code class="code">AsTransformation(</code><var class="Arg">digraph</var><code class="code">)</code> will return the transformation <code class="code">f</code> of degree at most <span class="SimpleMath">n</span> where for each <span class="SimpleMath">1 ≤ i ≤ n</span>, <code class="code">i ^ f</code> is equal to the unique out-neighbour of vertex <code class="code">i</code> in <var class="Arg">digraph</var>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[1], [3], [2]]);</span>
<immutable digraph with 3 vertices, 3 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">AsTransformation(D);</span>
Transformation( [ 1, 3, 2 ] )
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CycleDigraph(IsMutableDigraph, 3);</span>
<mutable digraph with 3 vertices, 3 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">AsTransformation(D);</span>
Transformation( [ 2, 3, 1 ] )
<span class="GAPprompt">gap></span> <span class="GAPinput">AsPermutation(last);</span>
(1,2,3)
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[2, 3], [], []]);</span>
<immutable digraph with 3 vertices, 2 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">AsTransformation(D);</span>
fail</pre></div>

<p><a id="X85126078848B420A" name="X85126078848B420A"></a></p>

<h4>3.3 <span class="Heading">New digraphs from old</span></h4>

<p><a id="X83D93A8A8251E6F9" name="X83D93A8A8251E6F9"></a></p>

<h5>3.3-1 DigraphImmutableCopy</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphImmutableCopy</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphMutableCopy</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphCopySameMutability</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphCopy</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>Each of these operations returns a new copy of <var class="Arg">digraph</var>, of the appropriate mutability, retaining none of the attributes or properties of <var class="Arg">digraph</var>.</p>

<p><code class="code">DigraphCopy</code> is a synonym for <code class="code">DigraphCopySameMutability</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CycleDigraph(10);</span>
<immutable cycle digraph with 10 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphCopy(D) = D;</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIdenticalObj(DigraphCopy(D), D);</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphMutableCopy(D);</span>
<mutable digraph with 10 vertices, 10 edges>
</pre></div>

<p><a id="X8399F7427B227228" name="X8399F7427B227228"></a></p>

<h5>3.3-2 DigraphImmutableCopyIfImmutable</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphImmutableCopyIfImmutable</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphImmutableCopyIfMutable</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphMutableCopyIfMutable</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphMutableCopyIfImmutable</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>Each of these operations returns either the original argument <var class="Arg">digraph</var>, or a new copy of <var class="Arg">digraph</var> of the appropriate mutability, according to the mutability of <var class="Arg">digraph</var>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">C := CycleDigraph(10);</span>
<immutable cycle digraph with 10 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphImmutableCopyIfImmutable(C);</span>
<immutable digraph with 10 vertices, 10 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIdenticalObj(C, D);</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">C = D;</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphImmutableCopyIfMutable(C);</span>
<immutable cycle digraph with 10 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIdenticalObj(C, D);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">C = D;</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphMutableCopyIfMutable(C);</span>
<immutable cycle digraph with 10 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsMutableDigraph(D);</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphMutableCopyIfImmutable(C);</span>
<mutable digraph with 10 vertices, 10 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsMutableDigraph(D);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">C := CycleDigraph(IsMutableDigraph, 10);</span>
<mutable digraph with 10 vertices, 10 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphImmutableCopyIfImmutable(C);</span>
<mutable digraph with 10 vertices, 10 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIdenticalObj(C, D);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">C = D;</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphImmutableCopyIfMutable(C);</span>
<immutable digraph with 10 vertices, 10 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIdenticalObj(C, D);</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">C = D;</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphMutableCopyIfMutable(C);</span>
<mutable digraph with 10 vertices, 10 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsMutableDigraph(D);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphMutableCopyIfImmutable(C);</span>
<mutable digraph with 10 vertices, 10 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIdenticalObj(C, D);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsMutableDigraph(D);</span>
true</pre></div>

<p><a id="X83C51DA182CCEA2F" name="X83C51DA182CCEA2F"></a></p>

<h5>3.3-3 InducedSubdigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ InducedSubdigraph</code>( <var class="Arg">digraph</var>, <var class="Arg">verts</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">digraph</var> is a digraph, and <var class="Arg">verts</var> is a subset of the vertices of <var class="Arg">digraph</var>, then this operation returns a digraph constructed from <var class="Arg">digraph</var> by retaining precisely those vertices in <var class="Arg">verts</var>, and those edges whose source and range vertices are both contained in <var class="Arg">verts</var>.</p>

<p>The vertices of the induced subdigraph are <code class="code">[1..Length(verts)]</code> but the original vertex labels can be accessed via <code class="func">DigraphVertexLabels</code> (<a href="chap5.html#X7E51F2FE87140B32"><span class="RefLink">5.1-12</span></a>).</p>

<p>If <var class="Arg">digraph</var> belongs to <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then <var class="Arg">digraph</var> is modified in place. If <var class="Arg">digraph</var> belongs to <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), a new immutable digraph containing the appropriate vertices and edges is returned.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[1, 1, 2, 3, 4, 4], [1, 3, 4], [3, 1], [1, 1]]);</span>
<immutable multidigraph with 4 vertices, 13 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">InducedSubdigraph(D, [1, 3, 4]);</span>
<immutable multidigraph with 3 vertices, 9 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphVertices(last);</span>
[ 1 .. 3 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphMutableCopy(D);</span>
<mutable multidigraph with 4 vertices, 13 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">new := InducedSubdigraph(D, [1, 3, 4]);</span>
<mutable multidigraph with 3 vertices, 9 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D = new;</span>
true
</pre></div>

<p><a id="X7CAF093B85A93D2F" name="X7CAF093B85A93D2F"></a></p>

<h5>3.3-4 ReducedDigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ReducedDigraph</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ReducedDigraphAttr</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>This function returns a digraph isomorphic to the subdigraph of <var class="Arg">digraph</varinduced by the set of non-isolated vertices, i.e. the set of those vertices of <var class="Arg">digraph</var> which are the source or range of some edge in <var class="Arg">digraph</var>. See <code class="func">InducedSubdigraph</code> (<a href="chap3.html#X83C51DA182CCEA2F"><span class="RefLink">3.3-3</span></a>).</p>

<p>The ordering of the remaining vertices of <var class="Arg">digraph</var> is preserved, as are the labels of the remaining vertices and edges; see <code class="func">DigraphVertexLabels</code(<a href="chap5.html#X7E51F2FE87140B32"><span class="RefLink">5.1-12</span></a>) and <code class="func">DigraphEdgeLabels</code> (<a href="chap5.html#X7C24851087D4A8FB"><span class="RefLink">5.1-14</span></a>). This can allow one to match a vertex in the reduced digraph to the corresponding vertex in <var class="Arg">digraph</var>.</p>

<p>If <var class="Arg">digraph</var> is immutable, then a new immutable digraph is returned. Otherwise, the isolated vertices of the mutable digraph <var class="Arg">digraph</var> are removed in-place.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[1, 2], [], [], [1, 4], []]);</span>
<immutable digraph with 5 vertices, 4 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">R := ReducedDigraph(D);</span>
<immutable digraph with 3 vertices, 4 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(R);</span>
[ [ 1, 2 ], [  ], [ 1, 3 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphEdges(D);</span>
[ [ 1, 1 ], [ 1, 2 ], [ 4, 1 ], [ 4, 4 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphEdges(R);</span>
[ [ 1, 1 ], [ 1, 2 ], [ 3, 1 ], [ 3, 3 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphVertexLabel(R, 3);</span>
4
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphVertexLabel(R, 2);</span>
2
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph(IsMutableDigraph, [[], [3], [2]]);</span>
<mutable digraph with 3 vertices, 2 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">ReducedDigraph(D);</span>
<mutable digraph with 2 vertices, 2 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D;</span>
<mutable digraph with 2 vertices, 2 edges>
</pre></div>

<p><a id="X829E3EAC7C4B3B1E" name="X829E3EAC7C4B3B1E"></a></p>

<h5>3.3-5 MaximalSymmetricSubdigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ MaximalSymmetricSubdigraph</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ MaximalSymmetricSubdigraphAttr</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ MaximalSymmetricSubdigraphWithoutLoops</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ MaximalSymmetricSubdigraphWithoutLoopsAttr</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">digraph</var> is a digraph, then <code class="code">MaximalSymmetricSubdigraph</code> returns a symmetric digraph without multiple edges which has the same vertex set as <var class="Arg">digraph</var>, and whose edge list is formed from <var class="Arg">digraph</var> by ignoring the multiplicity of edges, and by ignoring edges <code class="code">[u,v]</code> for which there does not exist an edge <code class="code">[v,u]</code>.</p>

<p>The digraph returned by <code class="code">MaximalSymmetricSubdigraphWithoutLoops</codeis the same, except that loops are removed.</p>

<p>If <var class="Arg">digraph</var> is immutable, then a new immutable digraph is returned. Otherwise, the mutable digraph <var class="Arg">digraph</var> is changed in-place into such a digraph described above.</p>

<p>See <code class="func">IsSymmetricDigraph</code> (<a href="chap6.html#X81B3EA7887219860"><span class="RefLink">6.2-14</span></a>), <code class="func">IsMultiDigraph</code> (<a href="chap6.html#X7BB84CFC7E8B2B26"><span class="RefLink">6.2-11</span></a>), and <code class="func">DigraphHasLoops</code> (<a href="chap6.html#X7D92935C7D535187"><span class="RefLink">6.2-1</span></a>) for more information.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[2, 2], [1, 3], [4], [3, 1]]);</span>
<immutable multidigraph with 4 vertices, 7 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">not IsSymmetricDigraph(D) and IsMultiDigraph(D);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(D);</span>
[ [ 2, 2 ], [ 1, 3 ], [ 4 ], [ 3, 1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">S := MaximalSymmetricSubdigraph(D);</span>
<immutable symmetric digraph with 4 vertices, 4 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsSymmetricDigraph(S) and not IsMultiDigraph(S);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(S);</span>
[ [ 2 ], [ 1 ], [ 4 ], [ 3 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CycleDigraph(IsMutableDigraph, 3);</span>
<mutable digraph with 3 vertices, 3 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">MaximalSymmetricSubdigraph(D);</span>
<mutable empty digraph with 3 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">D;</span>
<mutable empty digraph with 3 vertices>
</pre></div>

<p><a id="X79BA6A66846D5A95" name="X79BA6A66846D5A95"></a></p>

<h5>3.3-6 MaximalAntiSymmetricSubdigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ MaximalAntiSymmetricSubdigraph</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ MaximalAntiSymmetricSubdigraphAttr</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">digraph</var> is a digraph, then <code class="code">MaximalAntiSymmetricSubdigraph</code> returns an anti-symmetric subdigraph of <var class="Arg">digraph</var> formed by retaining the vertices of <var class="Arg">digraph</var>, discarding any duplicate edges, and discarding any edge <code class="code">[i,j]</code> of <var class="Arg">digraph</var> where <code class="code">i > j</code> and the reverse edge <code class="code">[j,i]</code> is an edge of <var class="Arg">digraph</var>. In other words, for every symmetric pair of edges <code class="code">[i,j]</codeand <code class="code">[j,i]</code> in <var class="Arg">digraph</var>, where <code class="code">i</code> and <code class="code">j</code> are distinct, it discards the edge <span class="SimpleMath">[max(i,j),min(i,j)]</span>.</p>

<p>If <var class="Arg">digraph</var> is immutable, then a new immutable digraph is returned. Otherwise, the mutable digraph <var class="Arg">digraph</var> is changed in-place.</p>

<p>See <code class="func">IsAntisymmetricDigraph</code> (<a href="chap6.html#X7DB1BC2286FC08E2"><span class="RefLink">6.2-2</span></a>) for more information.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[2, 2], [1, 3], [4], [3, 1]]);</span>
<immutable multidigraph with 4 vertices, 7 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">not IsAntiSymmetricDigraph(D) and IsMultiDigraph(D);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(D);</span>
[ [ 2, 2 ], [ 1, 3 ], [ 4 ], [ 3, 1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D := MaximalAntiSymmetricSubdigraph(D);</span>
<immutable antisymmetric digraph with 4 vertices, 4 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsAntiSymmetricDigraph(D) and not IsMultiDigraph(D);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(D);</span>
[ [ 2 ], [ 3 ], [ 4 ], [ 1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph(IsMutableDigraph, [[2], [1]]);</span>
<mutable digraph with 2 vertices, 2 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">MaximalAntiSymmetricSubdigraph(D);</span>
<mutable digraph with 2 vertices, 1 edge>
<span class="GAPprompt">gap></span> <span class="GAPinput">D;</span>
<mutable digraph with 2 vertices, 1 edge>
</pre></div>

<p><a id="X7DD9766C86D3ED20" name="X7DD9766C86D3ED20"></a></p>

<h5>3.3-7 UndirectedSpanningForest</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UndirectedSpanningForest</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UndirectedSpanningForestAttr</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UndirectedSpanningTree</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UndirectedSpanningTreeAttr</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>Returns: A digraph, or <code class="keyw">fail</code>.</p>

<p>If <var class="Arg">digraph</var> is a digraph with at least one vertex, then <code class="code">UndirectedSpanningForest</code> returns an undirected spanning forest of <var class="Arg">digraph</var>, otherwise this attribute returns <code class="keyw">fail</code>. See <code class="func">IsUndirectedSpanningForest</code> (<a href="chap4.html#X833C3299787E2309"><span class="RefLink">4.1-2</span></a>) for the definition of an undirected spanning forest.</p>

<p>If <var class="Arg">digraph</var> is a digraph with at least one vertex and whose <code class="func">MaximalSymmetricSubdigraph</code> (<a href="chap3.html#X829E3EAC7C4B3B1E"><span class="RefLink">3.3-5</span></a>) is connected (see <code class="func">IsConnectedDigraph</code> (<a href="chap6.html#X83C08C0B7EC1A91F"><span class="RefLink">6.6-3</span></a>)), then <code class="code">UndirectedSpanningTree</code> returns an undirected spanning tree of <var class="Arg">digraph</var>, otherwise this attribute returns <code class="keyw">fail</code>. See <code class="func">IsUndirectedSpanningTree</code> (<a href="chap4.html#X833C3299787E2309"><span class="RefLink">4.1-2</span></a>) for the definition of an undirected spanning tree.</p>

<p>If <var class="Arg">digraph</var> is immutable, then an immutable digraph is returned. Otherwise, the mutable digraph <var class="Arg">digraph</var> is changed in-place into an undirected spanning tree of <var class="Arg">digraph</var>.</p>

<p>Note that for an immutable digraph that has known undirected spanning tree, the attribute <code class="code">UndirectedSpanningTree</code> returns the same digraph as the attribute <code class="code">UndirectedSpanningForest</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[1, 2, 1, 3], [1], [4], [3, 4, 3]]);</span>
<immutable multidigraph with 4 vertices, 9 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">UndirectedSpanningTree(D);</span>
fail
<span class="GAPprompt">gap></span> <span class="GAPinput">forest := UndirectedSpanningForest(D);</span>
<immutable undirected forest with 4 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(forest);</span>
[ [ 2 ], [ 1 ], [ 4 ], [ 3 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">IsUndirectedSpanningForest(D, forest);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphConnectedComponents(forest).comps;</span>
[ [ 1, 2 ], [ 3, 4 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphConnectedComponents(MaximalSymmetricSubdigraph(D)).comps;</span>
[ [ 1, 2 ], [ 3, 4 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">UndirectedSpanningForest(MaximalSymmetricSubdigraph(D))</span>
<span class="GAPprompt">></span> <span class="GAPinput">= forest;</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CompleteDigraph(4);</span>
<immutable complete digraph with 4 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">tree := UndirectedSpanningTree(D);</span>
<immutable undirected tree with 4 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsUndirectedSpanningTree(D, tree);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">tree = UndirectedSpanningForest(D);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">UndirectedSpanningForest(EmptyDigraph(0));</span>
fail
<span class="GAPprompt">gap></span> <span class="GAPinput">D := PetersenGraph(IsMutableDigraph);</span>
<mutable digraph with 10 vertices, 30 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">UndirectedSpanningTree(D);</span>
<mutable digraph with 10 vertices, 18 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D;</span>
<mutable digraph with 10 vertices, 18 edges>
</pre></div>

<p><a id="X79C770918610AD97" name="X79C770918610AD97"></a></p>

<h5>3.3-8 DigraphShortestPathSpanningTree</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphShortestPathSpanningTree</code>( <var class="Arg">digraph</var>, <var class="Arg">v</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph, or <code class="keyw">fail</code>.</p>

<p>If <var class="Arg">v</var> is a vertex in <var class="Arg">digraph</var> and every other vertex of <var class="Arg">digraph</var> is reachable from <var class="Arg">v</var>, then this operation returns the shortest path spanning tree of <var class="Arg">digraph</var> rooted at <var class="Arg">v</var>. If there exist vertices in <var class="Arg">digraph</var> (other than <var class="Arg">v</var>) that are not reachable from <var class="Arg">v</var>, then <code class="code">DigraphShortestPathSpanningTree</code> returns <code class="keyw">fail</code>. See <code class="func">IsReachable</code> (<a href="chap5.html#X7FBAB09E7C0BE5CF"><span class="RefLink">5.4-20</span></a>).</p>

<p>The <em>shortest path spanning tree of <var class="Arg">digraph</var> rooted at <var class="Arg">v</var></em> is a subdigraph of <var class="Arg">digraph</var> that is a directed tree, with unique source vertex <var class="Arg">v</var>, and where for each other vertex <var class="Arg">u</var> in <var class="Arg">digraph</var>, the unique directed path from <var class="Arg">v</var> to <var class="Arg">u</var> in the tree is the lexicographically-least shortest directed path from <var class="Arg">v</var> to <var class="Arg">u</var> in <var class="Arg">digraph</var>.</p>

<p>See <code class="func">IsDirectedTree</code> (<a href="chap6.html#X7B46EA6C7B2DF2FB"><span class="RefLink">6.6-8</span></a>), <code class="func">DigraphSources</code> (<a href="chap5.html#X7F5C6268839BE98C"><span class="RefLink">5.1-9</span></a>), and <code class="func">DigraphShortestPath</code> (<a href="chap5.html#X80E9D645843973A6"><span class="RefLink">5.4-24</span></a>).</p>

<p>If <var class="Arg">digraph</var> belongs to <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then <var class="Arg">digraph</var> is modified in place. If <var class="Arg">digraph</var> belongs to <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the spanning tree is a new immutable digraph.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[1, 2], [3], [2, 4], [1], [2, 4]]);</span>
<immutable digraph with 5 vertices, 8 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">ForAll([2 .. 5], v -> IsReachable(D, 1, v));</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphShortestPathSpanningTree(D, 1);</span>
fail
<span class="GAPprompt">gap></span> <span class="GAPinput">tree := DigraphShortestPathSpanningTree(D, 5);</span>
<immutable directed tree with 5 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(tree);</span>
[ [  ], [ 3 ], [  ], [ 1 ], [ 2, 4 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">ForAll(DigraphVertices(D), v -></span>
<span class="GAPprompt">></span> <span class="GAPinput">DigraphShortestPath(D, 5, v) = DigraphPath(tree, 5, v));</span>
true
</pre></div>

<p><a id="X7D1D26D27F5B56C2" name="X7D1D26D27F5B56C2"></a></p>

<h5>3.3-9 QuotientDigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ QuotientDigraph</code>( <var class="Arg">digraph</var>, <var class="Arg">p</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">digraph</var> is a digraph, and <var class="Arg">p</var> is a partition of the vertices of <var class="Arg">digraph</var>, then this operation returns a digraph constructed by amalgamating all vertices of <var class="Arg">digraph</var> which lie in the same part of <var class="Arg">p</var>.</p>

<p>A partition of the vertices of <var class="Arg">digraph</var> is a list of non-empty disjoint lists, such that the union of all the sub-lists is equal to vertex set of <var class="Arg">digraph</var>. In particular, each vertex must appear in precisely one sub-list.</p>

<p>The vertices of <var class="Arg">digraph</var> in part <code class="code">i</code> of <var class="Arg">p</var> will become vertex <code class="code">i</code> in the quotient, and there exists some edge in <var class="Arg">digraph</var> with source in part <code class="code">i</code> and range in part <code class="code">j</code> if and only if there is an edge from <code class="code">i</code> to <code class="code">j</code> in the quotient. In particular, this means that the quotient of a digraph has no multiple edges. which was a change introduced in version 1.0.0 of the <strong class="pkg">Digraphs</strong> package.</p>

<p>If <var class="Arg">digraph</var> belongs to <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then <var class="Arg">digraph</var> is modified in place. If <var class="Arg">digraph</var> belongs to <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), a new immutable digraph with the above properties is returned.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[2, 1], [4], [1], [1, 3, 4]]);</span>
<immutable digraph with 4 vertices, 7 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphVertices(D);</span>
[ 1 .. 4 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphEdges(D);</span>
[ [ 1, 2 ], [ 1, 1 ], [ 2, 4 ], [ 3, 1 ], [ 4, 1 ], [ 4, 3 ], 
  [ 4, 4 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">p := [[1], [2, 4], [3]];</span>
[ [ 1 ], [ 2, 4 ], [ 3 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">quo := QuotientDigraph(D, p);</span>
<immutable digraph with 3 vertices, 6 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphVertices(quo);</span>
[ 1 .. 3 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphEdges(quo);</span>
[ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ], [ 2, 3 ], [ 3, 1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">QuotientDigraph(EmptyDigraph(0), []);</span>
<immutable empty digraph with 0 vertices>
</pre></div>

<p><a id="X78DECD26811EFD7C" name="X78DECD26811EFD7C"></a></p>

<h5>3.3-10 DigraphReverse</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphReverse</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphReverseAttr</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>The reverse of a digraph is the digraph formed by reversing the orientation of each of its edges, i.e. for every edge <code class="code">[i, j]</code> of a digraph, the reverse contains the corresponding edge <code class="code">[j, i]</code>.</p>

<p><code class="code">DigraphReverse</code> returns the reverse of the digraph <var class="Arg">digraph</var>. If <var class="Arg">digraph</var> is immutable, then a new immutable digraph is returned. Otherwise, the mutable digraph <var class="Arg">digraph</var> is changed in-place into its reverse.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[3], [1, 3, 5], [1], [1, 2, 4], [2, 3, 5]]);</span>
<immutable digraph with 5 vertices, 11 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphReverse(D);</span>
<immutable digraph with 5 vertices, 11 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(last);</span>
[ [ 2, 3, 4 ], [ 4, 5 ], [ 1, 2, 5 ], [ 4 ], [ 2, 5 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[2, 4], [1], [4], [3, 4]]);</span>
<immutable digraph with 4 vertices, 6 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphEdges(D);</span>
[ [ 1, 2 ], [ 1, 4 ], [ 2, 1 ], [ 3, 4 ], [ 4, 3 ], [ 4, 4 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphEdges(DigraphReverse(D));</span>
[ [ 1, 2 ], [ 2, 1 ], [ 3, 4 ], [ 4, 1 ], [ 4, 3 ], [ 4, 4 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CycleDigraph(IsMutableDigraph, 3);</span>
<mutable digraph with 3 vertices, 3 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(D);</span>
[ [ 2 ], [ 3 ], [ 1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphReverse(D);</span>
<mutable digraph with 3 vertices, 3 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(D);</span>
[ [ 3 ], [ 1 ], [ 2 ] ]
</pre></div>

<p><a id="X7F71D99D852B130F" name="X7F71D99D852B130F"></a></p>

<h5>3.3-11 DigraphDual</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphDual</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphDualAttr</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>The <em>dual</em> of <var class="Arg">digraph</var> has the same vertices as <var class="Arg">digraph</var>, and there is an edge in the dual from <code class="code">i</code> to <code class="code">j</codewhenever there is no edge from <code class="code">i</code> to <code class="code">j</code> in <var class="Arg">digraph</var>. The <em>dual</em> is sometimes called the <em>complement</em>.</p>

<p><code class="code">DigraphDual</code> returns the dual of the digraph <var class="Arg">digraph</var>. If <var class="Arg">digraph</var> is an immutable digraph, then a new immutable digraph is returned. Otherwise, the mutable digraph <var class="Arg">digraph</var> is changed in-place into its dual.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[2, 3], [], [4, 6], [5], [],</span>
<span class="GAPprompt">></span> <span class="GAPinput">[7, 8, 9], [], [], []]);</span>
<immutable digraph with 9 vertices, 8 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphDual(D);</span>
<immutable digraph with 9 vertices, 73 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CycleDigraph(IsMutableDigraph, 3);</span>
<mutable digraph with 3 vertices, 3 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphDual(D);</span>
<mutable digraph with 3 vertices, 6 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D;</span>
<mutable digraph with 3 vertices, 6 edges>
</pre></div>

<p><a id="X874883DD7DD450C4" name="X874883DD7DD450C4"></a></p>

<h5>3.3-12 DigraphSymmetricClosure</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphSymmetricClosure</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphSymmetricClosureAttr</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">digraph</var> is a digraph, then this attribute gives the minimal symmetric digraph which has the same vertices and contains all the edges of <var class="Arg">digraph</var>.</p>

<p>A digraph is <em>symmetric</em> if its adjacency matrix <code class="func">AdjacencyMatrix</code> (<a href="chap5.html#X7DC2CD70830BEE60"><span class="RefLink">5.2-1</span></a>) is symmetric. For a digraph with multiple edges this means that there are the same number of edges from a vertex <code class="code">u</code> to a vertex <code class="code">v</code> as there are from <code class="code">v</code> to <code class="code">u</code>; see <code class="func">IsSymmetricDigraph</code> (<a href="chap6.html#X81B3EA7887219860"><span class="RefLink">6.2-14</span></a>).</p>

<p>If <var class="Arg">digraph</var> is immutable, then a new immutable digraph is returned. Otherwise, the mutable digraph <var class="Arg">digraph</var> is changed in-place into its symmetric closure.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[1, 2, 3], [2, 4], [1], [3, 4]]);</span>
<immutable digraph with 4 vertices, 8 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphSymmetricClosure(D);</span>
<immutable symmetric digraph with 4 vertices, 11 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsSymmetricDigraph(D);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">List(OutNeighbours(D), AsSet);</span>
[ [ 1, 2, 3 ], [ 1, 2, 4 ], [ 1, 4 ], [ 2, 3, 4 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[2, 2], [1]]);</span>
<immutable multidigraph with 2 vertices, 3 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphSymmetricClosure(D);</span>
<immutable symmetric multidigraph with 2 vertices, 4 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(D);</span>
[ [ 2, 2 ], [ 1, 1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CycleDigraph(IsMutableDigraph, 3);</span>
<mutable digraph with 3 vertices, 3 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphSymmetricClosure(D);</span>
<mutable digraph with 3 vertices, 6 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D;</span>
<mutable digraph with 3 vertices, 6 edges>
</pre></div>

<p><a id="X7A6C419080AD41DE" name="X7A6C419080AD41DE"></a></p>

<h5>3.3-13 DigraphTransitiveClosure</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphTransitiveClosure</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphTransitiveClosureAttr</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphReflexiveTransitiveClosure</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphReflexiveTransitiveClosureAttr</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">digraph</var> is a digraph with no multiple edges, then these attributes return the (reflexive) transitive closure of <var class="Arg">digraph</var>.</p>

<p>A digraph is <em>reflexive</em> if it has a loop at every vertex, and it is <em>transitive</em> if whenever <code class="code">[i,j]</code> and <code class="code">[j,k]</code> are edges of <var class="Arg">digraph</var>, <code class="code">[i,k]</code> is also an edge. The <em>(reflexive) transitive closure</em> of a digraph <var class="Arg">digraph</var> is the least (reflexive and) transitive digraph containing <var class="Arg">digraph</var>.</p>

<p>If <var class="Arg">digraph</var> is immutable, then a new immutable digraph is returned. Otherwise, the mutable digraph <var class="Arg">digraph</var> is changed in-place into its (reflexive) transitive closure.</p>

<p>Let <span class="SimpleMath">n</span> be the number of vertices of <var class="Arg">digraph</var>, and let <span class="SimpleMath">m</span> be the number of edges. For an arbitrary digraph, these attributes will use a version of the Floyd-Warshall algorithm, with complexity <span class="SimpleMath">O(n^3)</span>. However, for a topologically sortable digraph [see <code class="func">DigraphTopologicalSort</code> (<a href="chap5.html#X785C30378064CF47"><span class="RefLink">5.1-10</span></a>)], these attributes will use methods with complexity <span class="SimpleMath">O(m + n + m ⋅ n)</span> when this is faster.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphFromDiSparse6String(".H`eOWR`Ul^");</span>
<immutable digraph with 9 vertices, 8 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsReflexiveDigraph(D) or IsTransitiveDigraph(D);</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(D);</span>
[ [ 4, 6 ], [ 1, 3 ], [  ], [ 5 ], [  ], [ 7, 8, 9 ], [  ], [  ], 
  [  ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">T := DigraphTransitiveClosure(D);</span>
<immutable transitive digraph with 9 vertices, 18 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(T);</span>
[ [ 4, 6, 5, 7, 8, 9 ], [ 1, 3, 4, 5, 6, 7, 8, 9 ], [  ], [ 5 ], 
  [  ], [ 7, 8, 9 ], [  ], [  ], [  ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">RT := DigraphReflexiveTransitiveClosure(D);</span>
<immutable preorder digraph with 9 vertices, 27 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(RT);</span>
[ [ 4, 6, 5, 7, 8, 9, 1 ], [ 1, 3, 4, 5, 6, 7, 8, 9, 2 ], [ 3 ], 
  [ 5, 4 ], [ 5 ], [ 7, 8, 9, 6 ], [ 7 ], [ 8 ], [ 9 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CycleDigraph(IsMutableDigraph, 3);</span>
<mutable digraph with 3 vertices, 3 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphReflexiveTransitiveClosure(D);</span>
<mutable digraph with 3 vertices, 9 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D;</span>
<mutable digraph with 3 vertices, 9 edges>
</pre></div>

<p><a id="X82AD17517E273600" name="X82AD17517E273600"></a></p>

<h5>3.3-14 DigraphTransitiveReduction</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphTransitiveReduction</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphTransitiveReductionAttr</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphReflexiveTransitiveReduction</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphReflexiveTransitiveReductionAttr</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">digraph</var> is a topologically sortable digraph [see <code class="func">DigraphTopologicalSort</code> (<a href="chap5.html#X785C30378064CF47"><span class="RefLink">5.1-10</span></a>)] with no multiple edges, then these operations return the (reflexive) transitive reduction of <var class="Arg">digraph</var>.</p>

<p>The (reflexive) transitive reduction of such a digraph is the unique least subgraph such that the (reflexive) transitive closure of the subgraph is equal to the (reflexive) transitive closure of <var class="Arg">digraph</var> [see <code class="func">DigraphReflexiveTransitiveClosure</code> (<a href="chap3.html#X7A6C419080AD41DE"><span class="RefLink">3.3-13</span></a>)]. In order words, it is the least subgraph of <var class="Arg">digraph</var> which retains the same reachability as <var class="Arg">digraph</var>.</p>

<p>If <var class="Arg">digraph</var> is immutable, then a new immutable digraph is returned. Otherwise, the mutable digraph <var class="Arg">digraph</var> is changed in-place into its (reflexive) transitive reduction.</p>

<p>Let <span class="SimpleMath">n</span> be the number of vertices of an arbitrary digraph, and let <span class="SimpleMath">m</span> be the number of edges. Then these operations use methods with complexity <span class="SimpleMath">O(m + n + m ⋅ n)</span>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[1, 2, 3], [3], [3]]);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphHasLoops(D);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">D1 := DigraphReflexiveTransitiveReduction(D);</span>
<immutable digraph with 3 vertices, 2 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphHasLoops(D1);</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(D1);</span>
[ [ 2 ], [ 3 ], [  ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D2 := DigraphTransitiveReduction(D);</span>
<immutable digraph with 3 vertices, 4 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphHasLoops(D2);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(D2);</span>
[ [ 2, 1 ], [ 3 ], [ 3 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphReflexiveTransitiveClosure(D)</span>
<span class="GAPprompt">></span> <span class="GAPinput"> = DigraphReflexiveTransitiveClosure(D1);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphTransitiveClosure(D)</span>
<span class="GAPprompt">></span> <span class="GAPinput"> = DigraphTransitiveClosure(D2);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph(IsMutableDigraph, [[1], [1], [1, 2, 3]]);</span>
<mutable digraph with 3 vertices, 5 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphReflexiveTransitiveReduction(D);</span>
<mutable digraph with 3 vertices, 2 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D;</span>
<mutable digraph with 3 vertices, 2 edges>
</pre></div>

<p><a id="X83B2506D79453208" name="X83B2506D79453208"></a></p>

<h5>3.3-15 DigraphAddVertex</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphAddVertex</code>( <var class="Arg">digraph</var>[, <var class="Arg">label</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>The operation returns a digraph constructed from <var class="Arg">digraph</var> by adding a single new vertex, and no new edges.</p>

<p>If the optional second argument <var class="Arg">label</var> is a <strong class="pkg">GAP</strongobject, then the new vertex will be labelled <var class="Arg">label</var>.</p>

<p>If <var class="Arg">digraph</var> belongs to <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the vertex is added directly to <var class="Arg">digraph</var>. If <var class="Arg">digraph</var> belongs to <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), an immutable copy of <var class="Arg">digraph</var> with the additional vertex is returned.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CompleteDigraph(3);</span>
<immutable complete digraph with 3 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">new := DigraphAddVertex(D);</span>
<immutable digraph with 4 vertices, 6 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D = new;</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphVertices(new);</span>
[ 1 .. 4 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">new := DigraphAddVertex(D, Group([(1, 2)]));</span>
<immutable digraph with 4 vertices, 6 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphVertexLabels(new);</span>
[ 1, 2, 3, Group([ (1,2) ]) ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CompleteBipartiteDigraph(IsMutableDigraph, 2, 3);</span>
<mutable digraph with 5 vertices, 12 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">new := DigraphAddVertex(D);</span>
<mutable digraph with 6 vertices, 12 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D = new;</span>
true
</pre></div>

<p><a id="X8134BEE7786BD3A7" name="X8134BEE7786BD3A7"></a></p>

<h5>3.3-16 DigraphAddVertices</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphAddVertices</code>( <var class="Arg">digraph</var>, <var class="Arg">m</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphAddVertices</code>( <var class="Arg">digraph</var>, <var class="Arg">labels</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>For a non-negative integer <var class="Arg">m</var>, this operation returns a digraph constructed from <var class="Arg">digraph</var> by adding <var class="Arg">m</var> new vertices.</p>

<p>Otherwise, if <var class="Arg">labels</var> is a list consisting of <code class="code">k</code> <strong class="pkg">GAP</strong> objects, then this operation returns a digraph constructed from <var class="Arg">digraph</var> by adding <code class="code">k</code> new vertices, which are labelled according to this list.</p>

<p>If <var class="Arg">digraph</var> belongs to <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the vertices are added directly to <var class="Arg">digraph</var>, which is changed in-place. If <var class="Arg">digraph</var> belongs to <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then <var class="Arg">digraph</var> itself is returned if no vertices are added (i.e. <code class="code"><var class="Arg">m</var>=0</code> or <var class="Arg">labels</var> is empty), otherwise the result is a new immutable digraph.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CompleteDigraph(3);</span>
<immutable complete digraph with 3 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">new := DigraphAddVertices(D, 3);</span>
<immutable digraph with 6 vertices, 6 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphVertices(new);</span>
[ 1 .. 6 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">new := DigraphAddVertices(D, [Group([(1, 2)]), "d"]);</span>
<immutable digraph with 5 vertices, 6 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphVertexLabels(new);</span>
[ 1, 2, 3, Group([ (1,2) ]), "d" ]
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphAddVertices(D, 0) = D;</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CompleteBipartiteDigraph(IsMutableDigraph, 2, 3);</span>
<mutable digraph with 5 vertices, 12 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">new := DigraphAddVertices(D, 4);</span>
<mutable digraph with 9 vertices, 12 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D = new;</span>
true
</pre></div>

<p><a id="X7E58CC4880627658" name="X7E58CC4880627658"></a></p>

<h5>3.3-17 DigraphAddEdge</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphAddEdge</code>( <var class="Arg">digraph</var>, <var class="Arg">edge</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphAddEdge</code>( <var class="Arg">digraph</var>, <var class="Arg">src</var>, <var class="Arg">ran</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">edge</var> is a pair of vertices of <var class="Arg">digraph</var>, or <var class="Arg">src</var> and <var class="Arg">ran</var> are vertices of <var class="Arg">digraph</var>, then this operation returns a digraph constructed from <var class="Arg">digraph</var> by adding a new edge with source <var class="Arg">edge</var><code class="code">[1]</code> [<var class="Arg">src</var>] and range <var class="Arg">edge</var><code class="code">[2]</code> [<var class="Arg">ran</var>].</p>

<p>If <var class="Arg">digraph</var> belongs to <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the edge is added directly to <var class="Arg">digraph</var>. If <var class="Arg">digraph</var> belongs to <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then an immutable copy of <var class="Arg">digraph</var> with the additional edge is returned.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D1 := Digraph([[2], [3], []]);</span>
<immutable digraph with 3 vertices, 2 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphEdges(D1);</span>
[ [ 1, 2 ], [ 2, 3 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D2 := DigraphAddEdge(D1, [3, 1]);</span>
<immutable digraph with 3 vertices, 3 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphEdges(D2);</span>
[ [ 1, 2 ], [ 2, 3 ], [ 3, 1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D3 := DigraphAddEdge(D2, [2, 3]);</span>
<immutable multidigraph with 3 vertices, 4 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphEdges(D3);</span>
[ [ 1, 2 ], [ 2, 3 ], [ 2, 3 ], [ 3, 1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CycleDigraph(IsMutableDigraph, 4);</span>
<mutable digraph with 4 vertices, 4 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">new := DigraphAddEdge(D, [1, 3]);</span>
<mutable digraph with 4 vertices, 5 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphEdges(new);</span>
[ [ 1, 2 ], [ 1, 3 ], [ 2, 3 ], [ 3, 4 ], [ 4, 1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D = new;</span>
true
</pre></div>

<p><a id="X7BE5C7028760B053" name="X7BE5C7028760B053"></a></p>

<h5>3.3-18 DigraphAddEdgeOrbit</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphAddEdgeOrbit</code>( <var class="Arg">digraph</var>, <var class="Arg">edge</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A new digraph.</p>

<p>This operation returns a new digraph with the same vertices and edges as <var class="Arg">digraph</var> and with additional edges consisting of the orbit of the edge <var class="Arg">edge</var> under the action of the <code class="func">DigraphGroup</code> (<a href="chap7.html#X803ACEDA7BBAC5B3"><span class="RefLink">7.2-10</span></a>) of <var class="Arg">digraph</var>. If <var class="Arg">edge</var> is already an edge in <var class="Arg">digraph</var>, then <var class="Arg">digraph</var> is returned unchanged. The argument <var class="Arg">digraph</var> must be an immutable digraph.</p>

<p>An edge is simply a pair of vertices of <var class="Arg">digraph</var>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">gr1 := CayleyDigraph(DihedralGroup(8));</span>
<immutable digraph with 8 vertices, 24 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">gr2 := DigraphAddEdgeOrbit(gr1, [1, 8]);</span>
<immutable digraph with 8 vertices, 32 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphEdges(gr1);</span>
[ [ 1, 2 ], [ 1, 3 ], [ 1, 4 ], [ 2, 1 ], [ 2, 5 ], [ 2, 6 ], 
  [ 3, 8 ], [ 3, 4 ], [ 3, 7 ], [ 4, 6 ], [ 4, 7 ], [ 4, 1 ], 
  [ 5, 7 ], [ 5, 6 ], [ 5, 8 ], [ 6, 4 ], [ 6, 8 ], [ 6, 2 ], 
  [ 7, 5 ], [ 7, 1 ], [ 7, 3 ], [ 8, 3 ], [ 8, 2 ], [ 8, 5 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphEdges(gr2);</span>
[ [ 1, 2 ], [ 1, 3 ], [ 1, 4 ], [ 1, 8 ], [ 2, 1 ], [ 2, 5 ], 
  [ 2, 6 ], [ 2, 7 ], [ 3, 8 ], [ 3, 4 ], [ 3, 7 ], [ 3, 6 ], 
  [ 4, 6 ], [ 4, 7 ], [ 4, 1 ], [ 4, 5 ], [ 5, 7 ], [ 5, 6 ], 
  [ 5, 8 ], [ 5, 4 ], [ 6, 4 ], [ 6, 8 ], [ 6, 2 ], [ 6, 3 ], 
  [ 7, 5 ], [ 7, 1 ], [ 7, 3 ], [ 7, 2 ], [ 8, 3 ], [ 8, 2 ], 
  [ 8, 5 ], [ 8, 1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">gr3 := DigraphRemoveEdgeOrbit(gr2, [1, 8]);</span>
<immutable digraph with 8 vertices, 24 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">gr3 = gr1;</span>
true
</pre></div>

<p><a id="X8693A61B7F752C76" name="X8693A61B7F752C76"></a></p>

<h5>3.3-19 DigraphAddEdges</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphAddEdges</code>( <var class="Arg">digraph</var>, <var class="Arg">edges</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">edges</var> is a (possibly empty) list of pairs of vertices of <var class="Arg">digraph</var>, then this operation returns a digraph constructed from <var class="Arg">digraph</var> by adding the edges specified by <var class="Arg">edges</var>. More precisely, for every <code class="code">edge</code> in <var class="Arg">edges</var>, a new edge will be added with source <code class="code">edge[1]</code> and range <code class="code">edges[2]</code>.</p>

<p>If an edge is included in <var class="Arg">edges</var> with multiplicity <code class="code">k</code>, then it will be added <code class="code">k</code> times. If <var class="Arg">digraph</var> belongs to <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the edges are added directly to <var class="Arg">digraph</var>. If <var class="Arg">digraph</var> belongs to <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the result is returned as an immutable digraph.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">func := function(n)</span>
<span class="GAPprompt">></span> <span class="GAPinput"> local source, range, i;</span>
<span class="GAPprompt">></span> <span class="GAPinput"source := [];</span>
<span class="GAPprompt">></span> <span class="GAPinput"> range  := [];</span>
<span class="GAPprompt">></span> <span class="GAPinput"> for i in [1 .. n - 2] do</span>
<span class="GAPprompt">></span> <span class="GAPinput">   Add(source, i);</span>
<span class="GAPprompt">></span> <span class="GAPinput">   Add(range, i + 1);</span>
<span class="GAPprompt">></span> <span class="GAPinput"> od;</span>
<span class="GAPprompt">></span> <span class="GAPinput"> return Digraph(n, source, range);</span>
<span class="GAPprompt">></span> <span class="GAPinput">end;;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := func(1024);</span>
<immutable digraph with 1024 vertices, 1022 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">new := DigraphAddEdges(D,</span>
<span class="GAPprompt">></span> <span class="GAPinput">[[1023, 1024], [1, 1024], [1023, 1024], [1024, 1]]);</span>
<immutable multidigraph with 1024 vertices, 1026 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D = new;</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">D2 := DigraphMutableCopy(func(1024));</span>
<mutable digraph with 1024 vertices, 1022 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">new := DigraphAddEdges(D2,</span>
<span class="GAPprompt">></span> <span class="GAPinput">[[1023, 1024], [1, 1024], [1023, 1024], [1024, 1]]);</span>
<mutable multidigraph with 1024 vertices, 1026 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D2 = new;</span>
true
</pre></div>

<p><a id="X7B634A2B83C08B16" name="X7B634A2B83C08B16"></a></p>

<h5>3.3-20 DigraphRemoveVertex</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphRemoveVertex</code>( <var class="Arg">digraph</var>, <var class="Arg">v</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">v</var> is a vertex of <var class="Arg">digraph</var>, then this operation returns a digraph constructed from <var class="Arg">digraph</var> by removing vertex <var class="Arg">v</var>, along with any edge whose source or range vertex is <var class="Arg">v</var>.</p>

<p>If <var class="Arg">digraph</var> has <code class="code">n</code> vertices, then the vertices of the returned digraph are <code class="code">[1..n-1]</code>, but the original labels can be accessed via <code class="func">DigraphVertexLabels</code> (<a href="chap5.html#X7E51F2FE87140B32"><span class="RefLink">5.1-12</span></a>).</p>

<p>If <var class="Arg">digraph</var> belongs to <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the vertex is removed directly from <var class="Arg">digraph</var>. If <var class="Arg">digraph</var> belongs to <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), an immutable copy of <var class="Arg">digraph</var> without the vertex is returned.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph(["a""b""c"],</span>
<span class="GAPprompt">></span> <span class="GAPinput">                 ["a""a""b""c""c"],</span>
<span class="GAPprompt">></span> <span class="GAPinput">                 ["b""c""a""a""c"]);</span>
<immutable digraph with 3 vertices, 5 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphVertexLabels(D);</span>
"a""b""c" ]
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphEdges(D);</span>
[ [ 1, 2 ], [ 1, 3 ], [ 2, 1 ], [ 3, 1 ], [ 3, 3 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">new := DigraphRemoveVertex(D, 2);</span>
<immutable digraph with 2 vertices, 3 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphVertexLabels(new);</span>
"a""c" ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CycleDigraph(IsMutableDigraph, 5);</span>
<mutable digraph with 5 vertices, 5 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">new := DigraphRemoveVertex(D, 1);</span>
<mutable digraph with 4 vertices, 3 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphVertexLabels(D);</span>
[ 2, 3, 4, 5 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D = new;</span>
true
</pre></div>

<p><a id="X7E290E847A5A299A" name="X7E290E847A5A299A"></a></p>

<h5>3.3-21 DigraphRemoveVertices</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphRemoveVertices</code>( <var class="Arg">digraph</var>, <var class="Arg">verts</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">verts</var> is a (possibly empty) duplicate-free list of vertices of <var class="Arg">digraph</var>, then this operation returns a digraph constructed from <var class="Arg">digraph</var> by removing every vertex in <var class="Arg">verts</var>, along with any edge whose source or range vertex is in <var class="Arg">verts</var>.</p>

<p>If <var class="Arg">digraph</var> has <code class="code">n</code> vertices, then the vertices of the new digraph are <code class="code">[1 .. n-Length(<var class="Arg">verts</var>)]</code>, but the original labels can be accessed via <code class="func">DigraphVertexLabels</code> (<a href="chap5.html#X7E51F2FE87140B32"><span class="RefLink">5.1-12</span></a>).</p>

<p>If <var class="Arg">digraph</var> belongs to <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the vertices are removed directly from <var class="Arg">digraph</var>. If <var class="Arg">digraph</var> belongs to <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), an immutable copy of <var class="Arg">digraph</var> without the vertices is returned.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[3], [1, 3, 5], [1], [1, 2, 4], [2, 3, 5]]);</span>
<immutable digraph with 5 vertices, 11 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">SetDigraphVertexLabels(D, ["a""b""c""d""e"]);</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">new := DigraphRemoveVertices(D, [2, 4]);</span>
<immutable digraph with 3 vertices, 4 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphVertexLabels(new);</span>
"a""c""e" ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CycleDigraph(IsMutableDigraph, 5);</span>
<mutable digraph with 5 vertices, 5 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">new := DigraphRemoveVertices(D, [1, 3]);</span>
<mutable digraph with 3 vertices, 1 edge>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphVertexLabels(D);</span>
[ 2, 4, 5 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D = new;</span>
true
</pre></div>

<p><a id="X8433E3BC7E5EA6BF" name="X8433E3BC7E5EA6BF"></a></p>

<h5>3.3-22 DigraphRemoveEdge</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphRemoveEdge</code>( <var class="Arg">digraph</var>, <var class="Arg">edge</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphRemoveEdge</code>( <var class="Arg">digraph</var>, <var class="Arg">src</var>, <var class="Arg">ran</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">digraph</var> is a digraph with no multiple edges and <var class="Arg">edge</var> is a pair of vertices of <var class="Arg">digraph</var>, or <var class="Arg">src</var> and <var class="Arg">ran</var> are vertices of <var class="Arg">digraph</var>, then this operation returns a digraph constructed from <var class="Arg">digraph</var> by removing the edge specified by <var class="Arg">edge</var> or <var class="Arg">[src, ran]</var>.</p>

<p>If <var class="Arg">digraph</var> belongs to <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the edge is removed directly from <var class="Arg">digraph</var>. If <var class="Arg">digraph</var> belongs to <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), an immutable copy of <var class="Arg">digraph</var> without the edge is returned.</p>

<p>Note that if <var class="Arg">digraph</var> belongs to <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then a new copy of <var class="Arg">digraph</var> will be returned even if <var class="Arg">edge</var> or <var class="Arg">[src, ran]</var> does not define an edge of <var class="Arg">digraph</var>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CycleDigraph(250000);</span>
<immutable cycle digraph with 250000 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphRemoveEdge(D, [250000, 1]);</span>
<immutable digraph with 250000 vertices, 249999 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">new := DigraphRemoveEdge(D, [25000, 2]);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">new = D;</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIdenticalObj(new, D);</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphMutableCopy(D);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">new := DigraphRemoveEdge(D, 2500, 2);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIdenticalObj(new, D);</span>
true
</pre></div>

<p><a id="X85981D9187F49018" name="X85981D9187F49018"></a></p>

<h5>3.3-23 DigraphRemoveEdgeOrbit</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphRemoveEdgeOrbit</code>( <var class="Arg">digraph</var>, <var class="Arg">edge</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A new digraph.</p>

<p>This operation returns a new digraph with the same vertices as <var class="Arg">digraph</var> and with the orbit of the edge <var class="Arg">edge</var> (under the action of the <code class="func">DigraphGroup</code> (<a href="chap7.html#X803ACEDA7BBAC5B3"><span class="RefLink">7.2-10</span></a>) of <var class="Arg">digraph</var>) removed. If <var class="Arg">edge</var> is not an edge in <var class="Arg">digraph</var>, then <var class="Arg">digraph</var> is returned unchanged. The argument <var class="Arg">digraph</var> must be an immutable digraph.</p>

<p>An edge is simply a pair of vertices of <var class="Arg">digraph</var>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">gr1 := CayleyDigraph(DihedralGroup(8));</span>
<immutable digraph with 8 vertices, 24 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">gr2 := DigraphAddEdgeOrbit(gr1, [1, 8]);</span>
<immutable digraph with 8 vertices, 32 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphEdges(gr1);</span>
[ [ 1, 2 ], [ 1, 3 ], [ 1, 4 ], [ 2, 1 ], [ 2, 5 ], [ 2, 6 ], 
  [ 3, 8 ], [ 3, 4 ], [ 3, 7 ], [ 4, 6 ], [ 4, 7 ], [ 4, 1 ], 
  [ 5, 7 ], [ 5, 6 ], [ 5, 8 ], [ 6, 4 ], [ 6, 8 ], [ 6, 2 ], 
  [ 7, 5 ], [ 7, 1 ], [ 7, 3 ], [ 8, 3 ], [ 8, 2 ], [ 8, 5 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphEdges(gr2);</span>
[ [ 1, 2 ], [ 1, 3 ], [ 1, 4 ], [ 1, 8 ], [ 2, 1 ], [ 2, 5 ], 
  [ 2, 6 ], [ 2, 7 ], [ 3, 8 ], [ 3, 4 ], [ 3, 7 ], [ 3, 6 ], 
  [ 4, 6 ], [ 4, 7 ], [ 4, 1 ], [ 4, 5 ], [ 5, 7 ], [ 5, 6 ], 
  [ 5, 8 ], [ 5, 4 ], [ 6, 4 ], [ 6, 8 ], [ 6, 2 ], [ 6, 3 ], 
  [ 7, 5 ], [ 7, 1 ], [ 7, 3 ], [ 7, 2 ], [ 8, 3 ], [ 8, 2 ], 
  [ 8, 5 ], [ 8, 1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">gr3 := DigraphRemoveEdgeOrbit(gr2, [1, 8]);</span>
<immutable digraph with 8 vertices, 24 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">gr3 = gr1;</span>
true
</pre></div>

<p><a id="X87093FDA7F88E732" name="X87093FDA7F88E732"></a></p>

<h5>3.3-24 DigraphRemoveEdges</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphRemoveEdges</code>( <var class="Arg">digraph</var>, <var class="Arg">edges</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If one of the following holds:</p>


<ul>
<li><p><var class="Arg">digraph</var> is a digraph with no multiple edges, and <var class="Arg">edges</var> is a list of pairs of vertices of <var class="Arg">digraph</var>, or</p>

</li>
<li><p><var class="Arg">digraph</var> is a digraph and <var class="Arg">edges</var> is an empty list</p>

</li>
</ul>
<p>then this operation returns a digraph constructed from <var class="Arg">digraph</var> by removing all of the edges specified by <var class="Arg">edges</var> (see <code class="func">DigraphRemoveEdge</code> (<a href="chap3.html#X8433E3BC7E5EA6BF"><span class="RefLink">3.3-22</span></a>)).</p>

<p>If <var class="Arg">digraph</var> belongs to <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the edge is removed directly from <var class="Arg">digraph</var>. If <var class="Arg">digraph</var> belongs to <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), the edge is removed from an immutable copy of <var class="Arg">digraph</var> and this new digraph is returned.</p>

<p>Note that if <var class="Arg">edges</var> is empty, then this operation will always return <var class="Arg">digraph</var> rather than a copy. Also, if any element of <var class="Arg">edges</var> is invalid (i.e. does not define an edge of <var class="Arg">digraph</var>) then that element will simply be ignored.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CycleDigraph(250000);</span>
<immutable cycle digraph with 250000 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphRemoveEdges(D, [[250000, 1]]);</span>
<immutable digraph with 250000 vertices, 249999 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphMutableCopy(D);</span>
<mutable digraph with 250000 vertices, 249999 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">new := DigraphRemoveEdges(D, [[1, 2], [2, 3], [3, 100]]);</span>
<mutable digraph with 250000 vertices, 249997 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">new = D;</span>
true
</pre></div>

<p><a id="X79324AF7818C0C02" name="X79324AF7818C0C02"></a></p>

<h5>3.3-25 DigraphRemoveLoops</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphRemoveLoops</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphRemoveLoopsAttr</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">digraph</var> is a digraph, then this operation returns a digraph constructed from <var class="Arg">digraph</var> by removing every loop. A loop is an edge with equal source and range.</p>

<p>If <var class="Arg">digraph</var> is immutable, then a new immutable digraph is returned. Otherwise, the loops are removed from the mutable digraph <var class="Arg">digraph</var> in-place.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[1, 2, 4], [1, 4], [3, 4], [1, 4, 5], [1, 5]]);</span>
<immutable digraph with 5 vertices, 12 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphRemoveLoops(D);</span>
<immutable digraph with 5 vertices, 8 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph(IsMutableDigraph, [[1, 2], [1]]);</span>
<mutable digraph with 2 vertices, 3 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphRemoveLoops(D);</span>
<mutable digraph with 2 vertices, 2 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D;</span>
<mutable digraph with 2 vertices, 2 edges>
</pre></div>

<p><a id="X7DCCD0247897A3DE" name="X7DCCD0247897A3DE"></a></p>

<h5>3.3-26 DigraphRemoveAllMultipleEdges</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphRemoveAllMultipleEdges</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphRemoveAllMultipleEdgesAttr</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">digraph</var> is a digraph, then this operation returns a digraph constructed from <var class="Arg">digraph</var> by removing all multiple edges. The result is the largest subdigraph of <var class="Arg">digraph</var> which does not contain multiple edges.</p>

<p>If <var class="Arg">digraph</var> is immutable, then a new immutable digraph is returned. Otherwise, the multiple edges of the mutable digraph <var class="Arg">digraph</var> are removed in-place.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D1 := Digraph([[1, 2, 3, 2], [1, 1, 3], [2, 2, 2]]);</span>
<immutable multidigraph with 3 vertices, 10 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D2 := DigraphRemoveAllMultipleEdges(D1);</span>
<immutable digraph with 3 vertices, 6 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(D2);</span>
[ [ 1, 2, 3 ], [ 1, 3 ], [ 2 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph(IsMutableDigraph, [[2, 2], [1]]);</span>
<mutable multidigraph with 2 vertices, 3 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphRemoveAllMultipleEdges(D);</span>
<mutable digraph with 2 vertices, 2 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D;</span>
<mutable digraph with 2 vertices, 2 edges>
</pre></div>

<p><a id="X792AD1147E2BFCB7" name="X792AD1147E2BFCB7"></a></p>

<h5>3.3-27 DigraphContractEdge</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphContractEdge</code>( <var class="Arg">digraph</var>, <var class="Arg">edge</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphContractEdge</code>( <var class="Arg">digraph</var>, <var class="Arg">src</var>, <var class="Arg">ran</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">edge</var> is a pair of vertices of <var class="Arg">digraph</var>, or <var class="Arg">src</var> and <var class="Arg">ran</var> are vertices of <var class="Arg">digraph</var>, where <var class="Arg">ran</var> <> <var class="Arg">src</var>, then then this operation merges the two vertices of the edge given into one. Edges incident to <var class="Arg">src</var> and <var class="Arg">ran</var> will now be incident to <code class="code">v</code>, the new vertex, with their direction preserved.</p>

<p>A new digraph constructed from <var class="Arg">digraph</var> is returned, unless <var class="Arg">digraph</var> belongs to <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>); in this case changes are made directly to <var class="Arg">digraph</var>, which is then returned. The <var class="Arg">digraph</var> must not belong to <code class="func">IsMultiDigraph</code> (<a href="chap6.html#X7BB84CFC7E8B2B26"><span class="RefLink">6.2-11</span></a>).</p>

<p>The labels of any remaining edges will be preserved.</p>

<p>Assigned vertex labels for <var class="Arg">src</var> and <var class="Arg">ran</var> are combined into a list, and assigned to the new vertex <code class="code">v</code>.</p>

<p>If an edge <var class="Arg">[src, src]</var> or <var class="Arg">[ran, ran]</var> exists, a singular edge <code class="code">[v, v]</code> is created. If edge <var class="Arg">[ran, src]</var> exists, this is also removed.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphByEdges([[1, 2], [2, 1]]);</span>
<immutable digraph with 2 vertices, 2 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D2 := DigraphContractEdge(D, 1, 2);</span>
<immutable empty digraph with 1 vertex>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphEdges(D2);</span>
[  ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphByEdges(IsMutableDigraph, [[1, 2], [2, 3], [3, 4]]);</span>
<mutable digraph with 4 vertices, 3 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphVertexLabels(D);;  # setting vertex labels</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphContractEdge(D, [2, 3]);</span>
<mutable digraph with 3 vertices, 2 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphEdges(D);</span>
[ [ 1, 3 ], [ 3, 2 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphVertexLabels(D);</span>
[ 1, 4, [ 2, 3 ] ]
</pre></div>

<p><a id="X7821753D85402A8C" name="X7821753D85402A8C"></a></p>

<h5>3.3-28 DigraphReverseEdges</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphReverseEdges</code>( <var class="Arg">digraph</var>, <var class="Arg">edges</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphReverseEdge</code>( <var class="Arg">digraph</var>, <var class="Arg">edge</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphReverseEdge</code>( <var class="Arg">digraph</var>, <var class="Arg">src</var>, <var class="Arg">ran</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">digraph</var> is a digraph without multiple edges, and <var class="Arg">edges</var> is a list of pairs of vertices of <var class="Arg">digraph</var> (the entries of each pair corresponding to the source and the range of an edge, respectively), then <code class="code">DigraphReverseEdges</code> returns a digraph constructed from <var class="Arg">digraph</var> by reversing the orientation of every edge specified by <var class="Arg">edges</var>. If only one edge is to be reversed, then <code class="code">DigraphReverseEdge</code> can be used instead. In this case, the second argument should just be a single vertex-pair, or the second and third arguments should be the source and range of an edge respectively.</p>

<p>Note that even though <var class="Arg">digraph</var> cannot have multiple edges, the output may have multiple edges.</p>

<p>If <var class="Arg">digraph</var> belongs to <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the edges are reversed in <var class="Arg">digraph</var>. If <var class="Arg">digraph</var> belongs to <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), an immutable copy of <var class="Arg">digraph</var> with the specified edges reversed is returned.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphFromDiSparse6String(".Tg?i@s?t_e?_qEsC");</span>
<immutable digraph with 21 vertices, 8 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphEdges(D);</span>
[ [ 1, 2 ], [ 1, 7 ], [ 1, 8 ], [ 5, 21 ], [ 7, 19 ], [ 9, 1 ], 
  [ 11, 2 ], [ 21, 1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">new := DigraphReverseEdge(D, [7, 19]);</span>
<immutable digraph with 21 vertices, 8 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphEdges(new);</span>
[ [ 1, 2 ], [ 1, 7 ], [ 1, 8 ], [ 5, 21 ], [ 9, 1 ], [ 11, 2 ], 
  [ 19, 7 ], [ 21, 1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D2 := DigraphMutableCopy(new);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">new := DigraphReverseEdges(D2, [[19, 7]]);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">D2 = new;</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">D = new;</span>
true
</pre></div>

<p><a id="X814F1DFC83DB273F" name="X814F1DFC83DB273F"></a></p>

<h5>3.3-29 DigraphDisjointUnion</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphDisjointUnion</code>( <var class="Arg">D1</var>, <var class="Arg">D2</var>, <var class="Arg">...</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphDisjointUnion</code>( <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>In the first form, if <var class="Arg">D1</var>, <var class="Arg">D2</var>, etc. are digraphs, then <code class="code">DigraphDisjointUnion</code> returns their disjoint union. In the second form, if <var class="Arg">list</var> is a non-empty list of digraphs, then <code class="code">DigraphDisjointUnion</code> returns the disjoint union of the digraphs contained in the list.</p>

<p>For a disjoint union of digraphs, the vertex set is the disjoint union of the vertex sets, and the edge list is the disjoint union of the edge lists.</p>

<p>More specifically, for a collection of digraphs <var class="Arg">D1</var>, <var class="Arg">D2</var>, <code class="code">...</code>, the disjoint union with have <code class="code">DigraphNrVertices(</code><var class="Arg">D1</var><code class="code">)</code> <code class="code">+</code> <code class="code">DigraphNrVertices(</code><var class="Arg">D2</var><code class="code">)</code> <code class="code">+</code> <code class="code">...</code> vertices. The edges of <var class="Arg">D1</var> will remain unchanged, whilst the edges of the <code class="code">i</code>th digraph, <var class="Arg">D</var><code class="code">[i]</code>, will be changed so that they belong to the vertices of the disjoint union corresponding to <var class="Arg">D</var><code class="code">[i]</code>. In particular, the edges of <var class="Arg">D</var><code class="code">[i]</code> will have their source and range increased by <code class="code">DigraphNrVertices(</code><var class="Arg">D1</var><code class="code">)</code> <code class="code">+</code> <code class="code">...</code> <code class="code">+</code> <code class="code">DigraphNrVertices(</code><var class="Arg">D</var><code class="code">[i-1])</code>.</p>

<p>Note that previously set <code class="func">DigraphVertexLabels</code> (<a href="chap5.html#X7E51F2FE87140B32"><span class="RefLink">5.1-12</span></a>) will be lost.</p>

<p>If the first digraph <var class="Arg">D1</var> [<var class="Arg">list[1]</var>] belongs to <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then <var class="Arg">D1</var> [<var class="Arg">list[1]</var>] is modified in place to contain the appropriate vertices and edges. If <var class="Arg">digraph</var> belongs to <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), a new immutable digraph containing the appropriate vertices and edges is returned.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D1 := CycleDigraph(3);</span>
<immutable cycle digraph with 3 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(D1);</span>
[ [ 2 ], [ 3 ], [ 1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D2 := CompleteDigraph(3);</span>
<immutable complete digraph with 3 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(D2);</span>
[ [ 2, 3 ], [ 1, 3 ], [ 1, 2 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">union := DigraphDisjointUnion(D1, D2);</span>
<immutable digraph with 6 vertices, 9 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(union);</span>
[ [ 2 ], [ 3 ], [ 1 ], [ 5, 6 ], [ 4, 6 ], [ 4, 5 ] ]
</pre></div>

<p><a id="X7DA997697D310E44" name="X7DA997697D310E44"></a></p>

<h5>3.3-30 DigraphEdgeUnion</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphEdgeUnion</code>( <var class="Arg">D1</var>, <var class="Arg">D2</var>, <var class="Arg">...</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphEdgeUnion</code>( <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>In the first form, if <var class="Arg">D1</var>, <var class="Arg">D2</var>, etc. are digraphs, then <code class="code">DigraphEdgeUnion</code> returns their edge union. In the second form, if <var class="Arg">list</var> is a non-empty list of digraphs, then <code class="code">DigraphEdgeUnion</code> returns the edge union of the digraphs contained in the list.</p>

<p>The vertex set of the edge union of a collection of digraphs is the <em>union</em> of the vertex sets, whilst the edge list of the edge union is the <em>concatenation</em> of the edge lists. The number of vertices of the edge union is equal to the <em>maximum</em> number of vertices of one of the digraphs, whilst the number of edges of the edge union will equal the <em>sum</em> of the number of edges of each digraph.</p>

<p>Note that previously set <code class="func">DigraphVertexLabels</code> (<a href="chap5.html#X7E51F2FE87140B32"><span class="RefLink">5.1-12</span></a>) will be lost.</p>

<p>If the first digraph <var class="Arg">D1</var> [<var class="Arg">list[1]</var>] belongs to <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then <var class="Arg">D1</var> [<var class="Arg">list[1]</var>] is modified in place to contain the appropriate vertices and edges. If <var class="Arg">digraph</var> belongs to <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), a new immutable digraph containing the appropriate vertices and edges is returned.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CycleDigraph(10);</span>
<immutable cycle digraph with 10 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphEdgeUnion(D, D);</span>
<immutable multidigraph with 10 vertices, 20 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D1 := Digraph([[2], [1]]);</span>
<immutable digraph with 2 vertices, 2 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D2 := Digraph([[2, 3], [2], [1]]);</span>
<immutable digraph with 3 vertices, 4 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">union := DigraphEdgeUnion(D1, D2);</span>
<immutable multidigraph with 3 vertices, 6 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(union);</span>
[ [ 2, 2, 3 ], [ 1, 2 ], [ 1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">union = DigraphByEdges(</span>
<span class="GAPprompt">></span> <span class="GAPinput">Concatenation(DigraphEdges(D1), DigraphEdges(D2)));</span>
true
</pre></div>

<p><a id="X7DDFC759860E3390" name="X7DDFC759860E3390"></a></p>

<h5>3.3-31 DigraphJoin</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphJoin</code>( <var class="Arg">D1</var>, <var class="Arg">D2</var>, <var class="Arg">...</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphJoin</code>( <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>In the first form, if <var class="Arg">D1</var>, <var class="Arg">D2</var>, etc. are digraphs, then <code class="code">DigraphJoin</code> returns their join. In the second form, if <var class="Arg">list</var> is a non-empty list of digraphs, then <code class="code">DigraphJoin</code> returns the join of the digraphs contained in the list.</p>

<p>The join of a collection of digraphs <var class="Arg">D1</var>, <var class="Arg">D2</var>, <code class="code">...</code> is formed by first taking the <code class="func">DigraphDisjointUnion</code> (<a href="chap3.html#X814F1DFC83DB273F"><span class="RefLink">3.3-29</span></a>) of the collection. In the disjoint union, if <span class="SimpleMath">i ≠ j</span> then there are no edges between vertices corresponding to digraphs <var class="Arg">D</var><code class="code">[i]</code> and <var class="Arg">D</var><code class="code">[j]</code> in the collection; the join is created by including all such edges.</p>

<p>For example, the join of two empty digraphs is a complete bipartite digraph.</p>

<p>Note that previously set <code class="func">DigraphVertexLabels</code> (<a href="chap5.html#X7E51F2FE87140B32"><span class="RefLink">5.1-12</span></a>) will be lost.</p>

<p>If the first digraph <var class="Arg">D1</var> [<var class="Arg">list[1]</var>] belongs to <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then <var class="Arg">D1</var> [<var class="Arg">list[1]</var>] is modified in place to contain the appropriate vertices and edges. If <var class="Arg">digraph</var> belongs to <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), a new immutable digraph containing the appropriate vertices and edges is returned.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CompleteDigraph(3);</span>
<immutable complete digraph with 3 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsCompleteDigraph(DigraphJoin(D, D));</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">D2 := CycleDigraph(3);</span>
<immutable cycle digraph with 3 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphJoin(D, D2);</span>
<immutable digraph with 6 vertices, 27 edges>
</pre></div>

<p><a id="X7D625CC87DBFFDED" name="X7D625CC87DBFFDED"></a></p>

<h5>3.3-32 DigraphCartesianProduct</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphCartesianProduct</code>( <var class="Arg">gr1</var>, <var class="Arg">gr2</var>, <var class="Arg">...</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphCartesianProduct</code>( <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>In the first form, if <var class="Arg">gr1</var>, <var class="Arg">gr2</var>, etc. are digraphs, then <code class="code">DigraphCartesianProduct</code> returns a digraph isomorphic to their Cartesian product.</p>

<p>In the second form, if <var class="Arg">list</var> is a non-empty list of digraphs, then <code class="code">DigraphCartesianProduct</code> returns a digraph isomorphic to the Cartesian product of the digraphs contained in the list.</p>

<p>Mathematically, the Cartesian product of two digraphs <code class="code">G</code>, <code class="code">H</code> is a digraph with vertex set <code class="code">Cartesian(DigraphVertices(G), DigraphVertices(H))</code> such that there is an edge from <code class="code">[u, u']</code> to <code class="code">[v, v']</code> iff <code class="code"> u = v </code> and there is an edge from <code class="code">u'</code> to <code class="code">v'</code> in <code class="code">H</code> or <code class="code"> u' = v'</code> and there is an edge from <code class="code">u</code> to <code class="code">v</code> in <code class="code">G</code>.</p>

<p>Due to technical reasons, the digraph <code class="code">D</code> returned by <code class="code">DigraphCartesianProduct</code> has vertex set <code class="code">[1 .. DigraphNrVertices(G)*DigraphNrVertices(H)]</code> instead, and the exact method of encoding pairs of vertices into integers is implementation specific. The original vertex pair can be somewhat regained by using <code class="func">DigraphCartesianProductProjections</code> (<a href="chap3.html#X8795087A78FE7D54"><span class="RefLink">3.3-39</span></a>). In addition, <code class="func">DigraphVertexLabels</code> (<a href="chap5.html#X7E51F2FE87140B32"><span class="RefLink">5.1-12</span></a>) are preserved: if vertex pair <code class="code">[u,u']</code> was encoded as <code class="code">i</code> then the vertex label of <code class="code">i</code> will be the pair of vertex labels of <code class="code">u</code> and <code class="code">u'</code> i.e. <code class="code">DigraphVertexLabel(D,i) = [DigraphVertexLabel(G,u), DigraphVertexLabel(H,u')]</code>.</p>

<p>As the Cartesian product is associative, the Cartesian product of a collection of digraphs <var class="Arg">gr1</var>, <var class="Arg">gr2</var>, <code class="code">...</code> is computed in the obvious fashion.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">gr := ChainDigraph(4);</span>
<immutable chain digraph with 4 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">gr2 := CycleDigraph(3);</span>
<immutable cycle digraph with 3 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">gr3 := DigraphCartesianProduct(gr, gr2);</span>
<immutable digraph with 12 vertices, 21 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIsomorphicDigraph(gr3, </span>
<span class="GAPprompt">></span> <span class="GAPinput">Digraph([[2, 5], [3, 6], [4, 7], [8], </span>
<span class="GAPprompt">></span> <span class="GAPinput">         [6, 9], [7, 10], [8, 11], [12],</span>
<span class="GAPprompt">></span> <span class="GAPinput">         [10, 1], [11, 2], [12, 3], [4]]));</span>
true
</pre></div>

<p><a id="X84D24DC9833B54A5" name="X84D24DC9833B54A5"></a></p>

<h5>3.3-33 DigraphDirectProduct</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphDirectProduct</code>( <var class="Arg">gr1</var>, <var class="Arg">gr2</var>, <var class="Arg">...</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphDirectProduct</code>( <var class="Arg">list</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>In the first form, if <var class="Arg">gr1</var>, <var class="Arg">gr2</var>, etc. are digraphs, then <code class="code">DigraphDirectProduct</code> returns a digraph isomorphic to their direct product.</p>

<p>In the second form, if <var class="Arg">list</var> is a non-empty list of digraphs, then <code class="code">DigraphDirectProduct</code> returns a digraph isomorphic to the direct product of the digraphs contained in the list.</p>

<p>Mathematically, the direct product of two digraphs <code class="code">G</code>, <code class="code">H</code> is a digraph with vertex set <code class="code">Cartesian(DigraphVertices(G), DigraphVertices(H))</code> such that there is an edge from <code class="code">[u, u']</code> to <code class="code">[v, v']</code> iff there is an edge from <code class="code">u</code> to <code class="code">v</code> in <code class="code">G</code> and an edge from <code class="code">u'</code> to <code class="code">v'</code> in <code class="code">H</code>.</p>

<p>Due to technical reasons, the digraph <code class="code">D</code> returned by <code class="code">DigraphDirectProduct</code> has vertex set <code class="code">[1 .. DigraphNrVertices(G)*DigraphNrVertices(H)]</code> instead, and the exact method of encoding pairs of vertices into integers is implementation specific. The original vertex pair can be somewhat regained by using <code class="func">DigraphDirectProductProjections</code> (<a href="chap3.html#X84FB64F185B804C2"><span class="RefLink">3.3-40</span></a>). In addition <code class="func">DigraphVertexLabels</code> (<a href="chap5.html#X7E51F2FE87140B32"><span class="RefLink">5.1-12</span></a>) are preserved: if vertex pair <code class="code">[u,u']</code> was encoded as <code class="code">i</code> then the vertex label of <code class="code">i</code> will be the pair of vertex labels of <code class="code">u</code> and <code class="code">u'</code> i.e. <code class="code">DigraphVertexLabel(D,i) = [DigraphVertexLabel(G,u), DigraphVertexLabel(H,u')]</code>.</p>

<p>As the direct product is associative, the direct product of a collection of digraphs <var class="Arg">gr1</var>, <var class="Arg">gr2</var>, <code class="code">...</code> is computed in the obvious fashion.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">gr := ChainDigraph(4);</span>
<immutable chain digraph with 4 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">gr2 := CycleDigraph(3);</span>
<immutable cycle digraph with 3 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">gr3 := DigraphDirectProduct(gr, gr2);</span>
<immutable digraph with 12 vertices, 9 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIsomorphicDigraph(gr3, </span>
<span class="GAPprompt">></span> <span class="GAPinput">Digraph([[6], [7], [8], [], </span>
<span class="GAPprompt">></span> <span class="GAPinput">         [10], [11], [12], [],</span>
<span class="GAPprompt">></span> <span class="GAPinput">         [2], [3], [4], []]));</span>
true
</pre></div>

<p><a id="X8160BCC378AF000F" name="X8160BCC378AF000F"></a></p>

<h5>3.3-34 ConormalProduct</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ConormalProduct</code>( <var class="Arg">D1</var>, <var class="Arg">D2</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">D1</var> and <var class="Arg">D2</var> are digraphs without multiple edges, then <code class="code">ConormalProduct</code> calculates the <em>co-normal product digraph</em> (<code class="code">CNPD</code>) of <var class="Arg">D1</var> and <var class="Arg">D2</var>. <code class="code">CNPD</code> has vertex set <code class="code">V1 x V2</code> where <code class="code">V1</codeis the vertex set of <var class="Arg">D1</var> and <code class="code">V2</code> is the vertex set of <var class="Arg">D2</var> (a vertex <code class="code">[a, b]</code> has label <code class="code">(a - 1) * |V2| + b</code> in the output). There is an edge from <code class="code">[a, b]</code> to <code class="code">[c, d]</code> when at least one of the following two conditions are satisfied:</p>


<ul>
<li><p>There is an edge from <code class="code">a</code> to <code class="code">c</code> in <var class="Arg">D1</var>.</p>

</li>
<li><p>There is an edge from <code class="code">b</code> to <code class="code">d</code> in <var class="Arg">D2</var>.</p>

</li>
</ul>

<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">ConormalProduct(DigraphSymmetricClosure(CycleDigraph(7)),</span>
<span class="GAPprompt">></span> <span class="GAPinput">DigraphSymmetricClosure(CycleDigraph(4)));</span>
<immutable digraph with 28 vertices, 504 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">ConormalProduct(NullDigraph(0), CompleteDigraph(10));</span>
<immutable empty digraph with 0 vertices>
</pre></div>

<p><a id="X79FD2AF279F20A72" name="X79FD2AF279F20A72"></a></p>

<h5>3.3-35 HomomorphicProduct</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ HomomorphicProduct</code>( <var class="Arg">D1</var>, <var class="Arg">D2</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">D1</var> and <var class="Arg">D2</var> are digraphs without multiple edges, then <code class="code">HomomorphicProduct</code> calculates the <em>homomorphic product digraph</em> (<code class="code">HPD</code>) of <var class="Arg">D1</var> and <var class="Arg">D2</var>. <code class="code">HPD</code> has vertex set <code class="code">V1 x V2</code> where <code class="code">V1</code> is the vertex set of <var class="Arg">D1</var> and <code class="code">V2</code> is the vertex set of <var class="Arg">D2</var> (a vertex <code class="code">[a, b]</code> has label <code class="code">(a - 1) * |V2| + b</code> in the output). There is an edge from <code class="code">[a, b]</code> to <code class="code">[c, d]</code> when at least one of the following two conditions are satisfied:</p>


<ul>
<li><p>The vertices <code class="code">a</code> and <code class="code">c</code> of <var class="Arg">D1</var> are equal.</p>

</li>
<li><p>There is an edge from <code class="code">a</code> to <code class="code">c</code> in <var class="Arg">D1</var> and no edge from <code class="code">b</code> to <code class="code">d</code> in <var class="Arg">D2</var>.</p>

</li>
</ul>

<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">HomomorphicProduct(PetersenGraph(),</span>
<span class="GAPprompt">></span> <span class="GAPinput">DigraphSymmetricClosure(ChainDigraph(4)));</span>
<immutable digraph with 40 vertices, 460 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D1 := Digraph([[2], [1, 3, 4], [2, 5], [2, 5], [3, 4]]);</span>
<immutable digraph with 5 vertices, 10 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D2 := Digraph([[2], [1, 3], [2, 4], [3]]);</span>
<immutable digraph with 4 vertices, 6 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">HomomorphicProduct(D1, D2);</span>
<immutable digraph with 20 vertices, 180 edges>
</pre></div>

<p><a id="X8151176882BA9901" name="X8151176882BA9901"></a></p>

<h5>3.3-36 LexicographicProduct</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ LexicographicProduct</code>( <var class="Arg">D1</var>, <var class="Arg">D2</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">D1</var> and <var class="Arg">D2</var> are digraphs without multiple edges, then <code class="code">LexicographicProduct</code> calculates the <em>lexicographic product digraph</em> (<code class="code">LPD</code>) of <var class="Arg">D1</var> and <var class="Arg">D2</var>. <code class="code">LPD</code> has vertex set <code class="code">V1 x V2</code> where <code class="code">V1</code> is the vertex set of <var class="Arg">D1</var> and <code class="code">V2</code> is the vertex set of <var class="Arg">D2</var> (a vertex <code class="code">[a, b]</code> has label <code class="code">(a - 1) * |V2| + b</code> in the output). There is an edge from <code class="code">[a, b]</code> to <code class="code">[c, d]</code> when at least one of the following two conditions are satisfied:</p>


<ul>
<li><p>There is an edge from <code class="code">a</code> to <code class="code">c</code> in <var class="Arg">D1</var>.</p>

</li>
<li><p>The vertices <code class="code">a</code> and <code class="code">c</code> of <var class="Arg">D1</var> are equal and there is an edge from <code class="code">b</code> to <code class="code">d</code> in <var class="Arg">D2</var>.</p>

</li>
</ul>

<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">LexicographicProduct(DigraphSymmetricClosure(CycleDigraph(3)),</span>
<span class="GAPprompt">></span> <span class="GAPinput">DigraphSymmetricClosure(ChainDigraph(2)));</span>
<immutable digraph with 6 vertices, 30 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(last);</span>
[ [ 2, 3, 4, 5, 6 ], [ 1, 3, 4, 5, 6 ], [ 1, 2, 4, 5, 6 ], 
  [ 1, 2, 3, 5, 6 ], [ 1, 2, 3, 4, 6 ], [ 1, 2, 3, 4, 5 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">LexicographicProduct(NullDigraph(0), CompleteDigraph(10));</span>
<immutable empty digraph with 0 vertices>
</pre></div>

<p><a id="X807F95057F9DF576" name="X807F95057F9DF576"></a></p>

<h5>3.3-37 ModularProduct</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ModularProduct</code>( <var class="Arg">D1</var>, <var class="Arg">D2</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">D1</var> and <var class="Arg">D2</var> are digraphs without multiple edges, then <code class="code">ModularProduct</code> calculates the <em>modular product digraph</em> (<code class="code">MPD</code>) of <var class="Arg">D1</var> and <var class="Arg">D2</var>. <code class="code">MPD</code> has vertex set <code class="code">V1 x V2</code> where <code class="code">V1</code> is the vertex set of <var class="Arg">D1</var> and <code class="code">V2</code> is the vertex set of <var class="Arg">D2</var> (a vertex <code class="code">[a, b]</code> has label <code class="code">(a - 1) * |V2| + b</code> in the output). There is an edge from <code class="code">[a, b]</code> to <code class="code">[c, d]</code> precisely when the following two conditions are satisfied:</p>


<ul>
<li><p>The vertices <code class="code">a</code> and <code class="code">c</code> of <var class="Arg">D1</var> are equal if and only if the vertices <code class="code">b</code> and <code class="code">d</code> of <var class="Arg">D2</var> are equal.</p>

</li>
<li><p>There is an edge from <code class="code">a</code> to <code class="code">c</code> in <var class="Arg">D1</var> if and only if there is an edge from <code class="code">b</code> to <code class="code">d</code> in <var class="Arg">D2</var>.</p>

</li>
</ul>
<p>Notably, the complete (with loops) subdigraphs of <code class="code">MPD</code> are precisely the partial isomorphisms from <var class="Arg">D1</var> to <var class="Arg">D2</var>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">ModularProduct(Digraph([[1], [1, 2]]), Digraph([[], [2]]));</span>
<immutable digraph with 4 vertices, 4 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(last);</span>
[ [ 4 ], [ 2, 3 ], [  ], [ 4 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">ModularProduct(PetersenGraph(),</span>
<span class="GAPprompt">></span> <span class="GAPinput">DigraphSymmetricClosure(CycleDigraph(5)));</span>
<immutable digraph with 50 vertices, 950 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">ModularProduct(NullDigraph(0), CompleteDigraph(10));</span>
<immutable empty digraph with 0 vertices>
</pre></div>

<p><a id="X82E200F07FEFAF27" name="X82E200F07FEFAF27"></a></p>

<h5>3.3-38 StrongProduct</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ StrongProduct</code>( <var class="Arg">D1</var>, <var class="Arg">D2</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">D1</var> and <var class="Arg">D2</var> are digraphs without multiple edges, then <code class="code">StrongProduct</code> calculates the <em>strong product digraph</em> (<code class="code">SPD</code>) of <var class="Arg">D1</var> and <var class="Arg">D2</var>. <code class="code">SPD</code> has vertex set <code class="code">V1 x V2</code> where <code class="code">V1</code> is the vertex set of <var class="Arg">D1</var> and <code class="code">V2</code> is the vertex set of <var class="Arg">D2</var> (a vertex <code class="code">[a, b]</code> has label <code class="code">(a - 1) * |V2| + b</code> in the output). There is an edge from <code class="code">[a, b]</code> to <code class="code">[c, d]</code> when at least one of the following three conditions are satisfied:</p>


<ul>
<li><p>The vertices <code class="code">a</code> and <code class="code">c</code> of <var class="Arg">D1</var> are equal and there is an edge from <code class="code">b</code> to <code class="code">d</code> in <var class="Arg">D2</var>.</p>

</li>
<li><p>The vertices <code class="code">b</code> and <code class="code">d</code> of <var class="Arg">D2</var> are equal and there is an edge from <code class="code">a</code> to <code class="code">c</code> in <var class="Arg">D1</var>.</p>

</li>
<li><p>There is an edge from <code class="code">a</code> to <code class="code">c</code> in <var class="Arg">D1</var> and there is an edge from <code class="code">b</code> to <code class="code">d</code> in <var class="Arg">D2</var>.</p>

</li>
</ul>
<p>The SPD of two paths of lengths <code class="code">m</code> and <code class="code">n</code> is also the king's graph for an <code class="code">m</code> by <code class="code">n</code> board.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D1 := Digraph([[2], [1, 3, 4], [2, 5], [2, 5], [3, 4]]);</span>
<immutable digraph with 5 vertices, 10 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D2 := Digraph([[2], [1, 3, 4], [2], [2]]);</span>
<immutable digraph with 4 vertices, 6 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">StrongProduct(D1, D2);</span>
<immutable digraph with 20 vertices, 130 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">StrongProduct(DigraphSymmetricClosure(ChainDigraph(3)),</span>
<span class="GAPprompt">></span> <span class="GAPinput">DigraphSymmetricClosure(ChainDigraph(4)));</span>
<immutable digraph with 12 vertices, 58 edges>
</pre></div>

<p><a id="X8795087A78FE7D54" name="X8795087A78FE7D54"></a></p>

<h5>3.3-39 DigraphCartesianProductProjections</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphCartesianProductProjections</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>Returns: A list of transformations.</p>

<p>If <var class="Arg">digraph</var> is a Cartesian product digraph, <code class="code">digraph = DigraphCartesianProduct(gr_1, gr_2, ... )</code>, then <code class="code">DigraphCartesianProductProjections</code> returns a list <code class="code">proj</code> such that <code class="code">proj[i]</code> is the projection onto the <code class="code">i</code>-th coordinate of the product.</p>

<p>A projection is an idempotent endomorphism of <var class="Arg">digraph</var>. If <code class="code">gr1, gr2, ...</code> are all loopless digraphs, then the induced subdigraph of <var class="Arg">digraph</var> on the image of <code class="code">proj[i]</code> is isomorphic to <code class="code">gr_i</code>.</p>

<p>Currently this attribute is only set upon creating an immutable digraph via <code class="code">DigraphCartesianProduct</code> and there is no way of calculating it for other digraphs.</p>

<p>For more information see <code class="func">DigraphCartesianProduct</code> (<a href="chap3.html#X7D625CC87DBFFDED"><span class="RefLink">3.3-32</span></a>)</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphCartesianProduct(ChainDigraph(3), CycleDigraph(4),</span>
<span class="GAPprompt">></span> <span class="GAPinput">Digraph([[2], [2]]));;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">HasDigraphCartesianProductProjections(D);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">proj := DigraphCartesianProductProjections(D);; Length(proj);</span>
3
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIdempotent(proj[2]);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">RankOfTransformation(proj[3]);</span>
2
<span class="GAPprompt">gap></span> <span class="GAPinput">S := ImageSetOfTransformation(proj[2]);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIsomorphicDigraph(CycleDigraph(4), InducedSubdigraph(D, S));</span>
true
</pre></div>

<p><a id="X84FB64F185B804C2" name="X84FB64F185B804C2"></a></p>

<h5>3.3-40 DigraphDirectProductProjections</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphDirectProductProjections</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>Returns: A list of transformations.</p>

<p>If <var class="Arg">digraph</var> is a direct product digraph, <code class="code">digraph = DigraphDirectProduct(gr_1, gr_2, ... )</code>, then <code class="code">DigraphDirectProductProjections</code> returns a list <code class="code">proj</code> such that <code class="code">proj[i]</code> is the projection onto the <code class="code">i</code>-th coordinate of the product.</p>

<p>A projection is an idempotent endomorphism of <var class="Arg">digraph</var>. If <code class="code">gr1, gr2, ...</code> are all loopless digraphs, then the image of <var class="Arg">digraph</var> under <code class="code">proj[i]</code> is isomorphic to <code class="code">gr_i</code>.</p>

<p>Currently this attribute is only set upon creating an immutable digraph via <code class="code">DigraphDirectProduct</code> and there is no way of calculating it for other digraphs.</p>

<p>For more information, see <code class="func">DigraphDirectProduct</code> (<a href="chap3.html#X84D24DC9833B54A5"><span class="RefLink">3.3-33</span></a>)</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphDirectProduct(ChainDigraph(3), CycleDigraph(4),</span>
<span class="GAPprompt">></span> <span class="GAPinput">Digraph([[2], [2]]));;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">HasDigraphDirectProductProjections(D);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">proj := DigraphDirectProductProjections(D);; Length(proj);</span>
3
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIdempotent(proj[2]);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">RankOfTransformation(proj[3]);</span>
2
<span class="GAPprompt">gap></span> <span class="GAPinput">P := DigraphRemoveAllMultipleEdges(</span>
<span class="GAPprompt">></span> <span class="GAPinput">ReducedDigraph(OnDigraphs(D, proj[2])));; </span>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIsomorphicDigraph(CycleDigraph(4), P);</span>
true
</pre></div>

<p><a id="X8595BF937B749F22" name="X8595BF937B749F22"></a></p>

<h5>3.3-41 LineDigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ LineDigraph</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ EdgeDigraph</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>Given a digraph <var class="Arg">digraph</var>, the operation returns the digraph obtained by associating a vertex with each edge of <var class="Arg">digraph</var>, and creating an edge from a vertex <code class="keyw">v</code> to a vertex <code class="keyw">u</code> if and only if the terminal vertex of the edge associated with <code class="keyw">v</code> is the start vertex of the edge associated with <code class="keyw">u</code>.</p>

<p>Note that the returned digraph is always a new immutable digraph, and the argument <var class="Arg">digraph</var> is never modified.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">LineDigraph(CompleteDigraph(3));</span>
<immutable digraph with 6 vertices, 12 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">LineDigraph(ChainDigraph(3));</span>
<immutable digraph with 2 vertices, 1 edge>
</pre></div>

<p><a id="X8364C6F17A1680CB" name="X8364C6F17A1680CB"></a></p>

<h5>3.3-42 LineUndirectedDigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ LineUndirectedDigraph</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ EdgeUndirectedDigraph</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>Given a symmetric digraph <var class="Arg">digraph</var>, the operation returns the symmetric digraph obtained by associating a vertex with each edge of <var class="Arg">digraph</var>, ignoring directions and multiplicities, and adding an edge between two vertices if and only if the corresponding edges have a vertex in common.</p>

<p>Note that the returned digraph is always a new immutable digraph, and the argument <var class="Arg">digraph</var> is never modified.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">LineUndirectedDigraph(CompleteDigraph(3));</span>
<immutable digraph with 3 vertices, 6 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">LineUndirectedDigraph(DigraphSymmetricClosure(ChainDigraph(3)));</span>
<immutable digraph with 2 vertices, 2 edges>
</pre></div>

<p><a id="X7FB8B48C87C0ED16" name="X7FB8B48C87C0ED16"></a></p>

<h5>3.3-43 DoubleDigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DoubleDigraph</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>Let <var class="Arg">digraph</var> be a digraph with vertex set <code class="code">V</code>. This function returns the double digraph of <var class="Arg">digraph</var>. The vertex set of the double digraph is the original vertex set together with a duplicate. The edges are <code class="code">[u_1, v_2]</code> and <code class="code">[u_2, v_1]</code> if and only if <code class="code">[u, v]</code> is an edge in <var class="Arg">digraph</var>, together with the original edges and their duplicates.</p>

<p>If <var class="Arg">digraph</var> is mutable, then <var class="Arg">digraph</var> is modified in-place. If <var class="Arg">digraph</var> is immutable, then a new immutable digraph constructed as described above is returned.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">gamma := Digraph([[2], [3], [1]]);</span>
<immutable digraph with 3 vertices, 3 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DoubleDigraph(gamma);</span>
<immutable digraph with 6 vertices, 12 edges>
</pre></div>

<p><a id="X7C6E6CB284982C7A" name="X7C6E6CB284982C7A"></a></p>

<h5>3.3-44 BipartiteDoubleDigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ BipartiteDoubleDigraph</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>Let <var class="Arg">digraph</var> be a digraph with vertex set <code class="code">V</code>. This function returns the bipartite double digraph of <var class="Arg">digraph</var>. The vertex set of the double digraph is the original vertex set together with a duplicate. The edges are <code class="code">[u_1, v_2]</code> and <code class="code">[u_2, v_1]</code> if and only if <code class="code">[u, v]</code> is an edge in <var class="Arg">digraph</var>. The resulting graph is bipartite, since the original edges are not included in the resulting digraph.</p>

<p>If <var class="Arg">digraph</var> is mutable, then <var class="Arg">digraph</var> is modified in-place. If <var class="Arg">digraph</var> is immutable, then a new immutable digraph constructed as described above is returned.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">gamma := Digraph([[2], [3], [1]]);</span>
<immutable digraph with 3 vertices, 3 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">BipartiteDoubleDigraph(gamma);</span>
<immutable digraph with 6 vertices, 6 edges>
</pre></div>

<p><a id="X8167A50A83256ED1" name="X8167A50A83256ED1"></a></p>

<h5>3.3-45 DigraphAddAllLoops</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphAddAllLoops</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphAddAllLoopsAttr</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>For a digraph <var class="Arg">digraph</var> this operation returns a new digraph constructed from <var class="Arg">digraph</var>, such that a loop is added for every vertex which did not have a loop in <var class="Arg">digraph</var>.</p>

<p>If <var class="Arg">digraph</var> is immutable, then a new immutable digraph is returned. Otherwise, the loops are added to the loopless vertices of the mutable digraph <var class="Arg">digraph</var> in-place.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := EmptyDigraph(13);</span>
<immutable empty digraph with 13 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphAddAllLoops(D);</span>
<immutable reflexive digraph with 13 vertices, 13 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(D);</span>
[ [ 1 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ], [ 6 ], [ 7 ], [ 8 ], [ 9 ], 
  [ 10 ], [ 11 ], [ 12 ], [ 13 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[1, 2, 3], [1, 3], [1]]);</span>
<immutable digraph with 3 vertices, 6 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphAddAllLoops(D);</span>
<immutable reflexive digraph with 3 vertices, 8 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(D);</span>
[ [ 1, 2, 3 ], [ 1, 3, 2 ], [ 1, 3 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CycleDigraph(IsMutableDigraph, 3);</span>
<mutable digraph with 3 vertices, 3 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphAddAllLoops(D);</span>
<mutable digraph with 3 vertices, 6 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D;</span>
<mutable digraph with 3 vertices, 6 edges>
</pre></div>

<p><a id="X865436437DF95FEF" name="X865436437DF95FEF"></a></p>

<h5>3.3-46 DistanceDigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DistanceDigraph</code>( <var class="Arg">digraph</var>, <var class="Arg">i</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DistanceDigraph</code>( <var class="Arg">digraph</var>, <var class="Arg">list</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>The first argument is a digraph, the second argument is a non-negative integer or a list of positive integers. This operation returns a digraph on the same set of vertices as <var class="Arg">digraph</var>, with two vertices being adjacent if and only if the distance between them in <var class="Arg">digraph</var> equals <var class="Arg">i</var> or is a number in <var class="Arg">list</var>. See <code class="func">DigraphShortestDistance</code> (<a href="chap5.html#X8104A9D37BCD8A05"><span class="RefLink">5.4-2</span></a>).</p>

<p>If <var class="Arg">digraph</var> is mutable, then <var class="Arg">digraph</var> is modified in-place. If <var class="Arg">digraph</var> is immutable, then a new immutable digraph constructed as described above is returned.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">digraph := DigraphFromSparse6String(</span>
<span class="GAPprompt">></span> <span class="GAPinput">":]n?AL`BC_DEbEF`GIaGHdIJeGKcKL_@McDHfILaBJfHMjKM");</span>
<immutable symmetric digraph with 30 vertices, 90 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DistanceDigraph(digraph, 1);</span>
<immutable digraph with 30 vertices, 90 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DistanceDigraph(digraph, [1, 2]);</span>
<immutable digraph with 30 vertices, 270 edges>
</pre></div>

<p><a id="X86F9CCEA839ABC48" name="X86F9CCEA839ABC48"></a></p>

<h5>3.3-47 DigraphClosure</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphClosure</code>( <var class="Arg">digraph</var>, <var class="Arg">k</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>Given a symmetric loopless digraph with no multiple edges <var class="Arg">digraph</var>, the <em><var class="Arg">k</var>-closure of <var class="Arg">digraph</var></em> is defined to be the unique smallest symmetric loopless digraph <code class="code">C</code> with no multiple edges on the vertices of <var class="Arg">digraph</var> that contains all the edges of <var class="Arg">digraph</varand satisfies the property that the sum of the degrees of every two non-adjacenct vertices in <code class="code">C</code> is less than <var class="Arg">k</var>. See <code class="func">IsSymmetricDigraph</code> (<a href="chap6.html#X81B3EA7887219860"><span class="RefLink">6.2-14</span></a>), <code class="func">DigraphHasLoops</code> (<a href="chap6.html#X7D92935C7D535187"><span class="RefLink">6.2-1</span></a>), <code class="func">IsMultiDigraph</code> (<a href="chap6.html#X7BB84CFC7E8B2B26"><span class="RefLink">6.2-11</span></a>), and <code class="func">OutDegreeOfVertex</code> (<a href="chap5.html#X7A09EB648070276D"><span class="RefLink">5.2-10</span></a>).</p>

<p>The operation <code class="code">DigraphClosure</code> returns the <var class="Arg">k</var>-closure of <var class="Arg">digraph</var>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CompleteDigraph(6);</span>
<immutable complete digraph with 6 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphRemoveEdges(D, [[1, 2], [2, 1]]);</span>
<immutable digraph with 6 vertices, 28 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">closure := DigraphClosure(D, 6);</span>
<immutable digraph with 6 vertices, 30 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsCompleteDigraph(closure);</span>
true
</pre></div>

<p><a id="X7B5AC5FE859F4D80" name="X7B5AC5FE859F4D80"></a></p>

<h5>3.3-48 DigraphMycielskian</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphMycielskian</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphMycielskianAttr</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">digraph</var> is a symmetric digraph, then <code class="code">DigraphMycielskian</code> returns the Mycielskian of <var class="Arg">digraph</var>.</p>

<p>The Mycielskian of a symmetric digraph is a larger symmetric digraph constructed from it, which has a larger chromatic number. For further information, see <span class="URL"><a href="https://en.wikipedia.org/wiki/Mycielskian">https://en.wikipedia.org/wiki/Mycielskian</a></span>.</p>

<p>If <var class="Arg">digraph</var> is immutable, then a new immutable digraph is returned. Otherwise, the mutable digraph <var class="Arg">digraph</var> is changed in-place into its Mycielskian.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CycleDigraph(2);</span>
<immutable cycle digraph with 2 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">ChromaticNumber(D);</span>
2
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphMycielskian(D);</span>
<immutable digraph with 5 vertices, 10 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">ChromaticNumber(D);</span>
3
<span class="GAPprompt">gap></span> <span class="GAPinput">D := DigraphMycielskian(D);</span>
<immutable digraph with 11 vertices, 40 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">ChromaticNumber(D);</span>
4
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CompleteBipartiteDigraph(IsMutable, 2, 3);</span>
<mutable digraph with 5 vertices, 12 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphMycielskian(D);</span>
<mutable digraph with 11 vertices, 46 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D;</span>
<mutable digraph with 11 vertices, 46 edges>
</pre></div>

<p><a id="X85B5D9B97F5187B7" name="X85B5D9B97F5187B7"></a></p>

<h4>3.4 <span class="Heading">Random digraphs</span></h4>

<p><a id="X86CF9F66788B2A24" name="X86CF9F66788B2A24"></a></p>

<h5>3.4-1 RandomDigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ RandomDigraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var>[, <var class="Arg">p</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>

<p>The other implemented filters are as follows: <code class="func">IsConnectedDigraph</code> (<a href="chap6.html#X83C08C0B7EC1A91F"><span class="RefLink">6.6-3</span></a>), <code class="func">IsSymmetricDigraph</code> (<a href="chap6.html#X81B3EA7887219860"><span class="RefLink">6.2-14</span></a>), <code class="func">IsAcyclicDigraph</code> (<a href="chap6.html#X7BD08D4478218F77"><span class="RefLink">6.6-1</span></a>), <code class="func">IsEulerianDigraph</code(<a href="chap6.html#X79DFBB198525544E"><span class="RefLink">6.6-10</span></a>), <code class="func">IsHamiltonianDigraph</code> (<a href="chap6.html#X79EFEBC37C2D262D"><span class="RefLink">6.6-11</span></a>).</p>

<p>For <code class="func">IsConnectedDigraph</code> (<a href="chap6.html#X83C08C0B7EC1A91F"><span class="RefLink">6.6-3</span></a>), a random tree is first created independent of the value of <var class="Arg">p</var>, guaranteeing connectivity (with <span class="SimpleMath"><var class="Arg">n</var>-1</span> edges), and then edges are added between the remaining pairs of vertices with probability approximately <var class="Arg">p</var>.</p>

<p>For <code class="func">IsHamiltonianDigraph</code> (<a href="chap6.html#X79EFEBC37C2D262D"><span class="RefLink">6.6-11</span></a>), a random Hamiltonian cycle is first created independent of the value of <var class="Arg">p</var> (with <var class="Arg">n</var> edges), and then edges are added between the remaining pairs of vertices with probability approximately <var class="Arg">p</var>.</p>

<p>For <code class="func">IsEulerianDigraph</code> (<a href="chap6.html#X79DFBB198525544E"><span class="RefLink">6.6-10</span></a>), a random Eulerian cycle is created where <var class="Arg">p</var> influences how long the cycle will be. The cycle grows by randomly considering edges that extend the cycle, and adding an edge with probability approximately <var class="Arg">p</var>. The cycle stops when we get back to the start vertex and have no more edges left to consider from it that extend the cycle further (any possible edge from the start vertex has either been added to the cycle, or rejected, leaving no more edges to consider). Thus <span class="SimpleMath"><var class="Arg">p</var> = 1</span> does not necessarily guarantee a complete digraph. Instead, it guarantees that all edges considered up to the point where the cycle stops, are added.</p>

<p>For <code class="func">IsAcyclicDigraph</code> (<a href="chap6.html#X7BD08D4478218F77"><span class="RefLink">6.6-1</span></a>) and <code class="func">IsSymmetricDigraph</code> (<a href="chap6.html#X81B3EA7887219860"><span class="RefLink">6.2-14</span></a>), edges are added between any pairs of vertices with probability approximately <var class="Arg">p</var>.</p>

<p>If <var class="Arg">n</var> is a positive integer, then this function returns a random digraph with <var class="Arg">n</var> vertices and without multiple edges. The result may or may not have loops. If using <code class="func">IsAcyclicDigraph</code> (<a href="chap6.html#X7BD08D4478218F77"><span class="RefLink">6.6-1</span></a>), the resulting graph will not have any loops by definition.</p>

<p>If the optional second argument <var class="Arg">p</var> is a float with value <span class="SimpleMath">0 ≤</span> <var class="Arg"> p </var> <span class="SimpleMath">≤ 1</span>, then an edge will exist between each pair of vertices with probability approximately <var class="Arg">p</var>. If <var class="Arg">p</var> is not specified, then a random probability will be assumed (chosen with uniform probability).</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">RandomDigraph(1000);</span>
<immutable digraph with 1000 vertices, 364444 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">RandomDigraph(10000, 0.023);</span>
<immutable digraph with 10000 vertices, 2300438 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">RandomDigraph(IsMutableDigraph, 1000, 1 / 2);</span>
<mutable digraph with 1000 vertices, 499739 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">RandomDigraph(IsConnectedDigraph, 1000, 0.75);</span>
<immutable digraph with 1000 vertices, 750265 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">RandomDigraph(IsSymmetricDigraph, 1000);</span>
<immutable digraph with 1000 vertices, 329690 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">RandomDigraph(IsAcyclicDigraph, 1000, 0.25);</span>
<immutable digraph with 1000 vertices, 125070 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">RandomDigraph(IsHamiltonianDigraph, 1000, 0.5);</span>
<immutable digraph with 1000 vertices, 500327 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">RandomDigraph(IsEulerianDigraph, 1000, 0.5);</span>
<immutable digraph with 1000 vertices, 433869 edges>
</pre></div>

<p><a id="X78FE275E7E77D56F" name="X78FE275E7E77D56F"></a></p>

<h5>3.4-2 RandomMultiDigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ RandomMultiDigraph</code>( <var class="Arg">n</var>[, <var class="Arg">m</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is a positive integer, then this function returns a random digraph with <var class="Arg">n</var> vertices. If the optional second argument <var class="Arg">m</var> is a positive integer, then the digraph will have <var class="Arg">m</var> edges. If <var class="Arg">m</var> is not specified, then the number of edges will be chosen randomly (with uniform probability) from the range <code class="code">[1 .. </code><span class="SimpleMath">n choose 2</span><code class="code">]</code>.</p>

<p>The method used by this function chooses each edge from the set of all possible edges with uniform probability. No effort is made to avoid creating multiple edges, so it is possible (but not guaranteed) that the result will have multiple edges. The result may or may not have loops.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">RandomMultiDigraph(1000);</span>
<immutable multidigraph with 1000 vertices, 216659 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">RandomMultiDigraph(1000, 950);</span>
<immutable multidigraph with 1000 vertices, 950 edges>
</pre></div>

<p><a id="X7D36B5E57F055051" name="X7D36B5E57F055051"></a></p>

<h5>3.4-3 RandomTournament</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ RandomTournament</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>

<p>If <var class="Arg">n</var> is a non-negative integer, this function returns a random tournament with <var class="Arg">n</var> vertices. See <code class="func">IsTournament</code> (<a href="chap6.html#X7DD8D1A185EBE865"><span class="RefLink">6.2-15</span></a>).</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">RandomTournament(10);</span>
<immutable tournament with 10 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">RandomTournament(IsMutableDigraph, 10);</span>
<mutable digraph with 1000 vertices, 500601 edges>
</pre></div>

<p><a id="X7A023E4787682475" name="X7A023E4787682475"></a></p>

<h5>3.4-4 RandomLattice</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ RandomLattice</code>( <var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>

<p>If <var class="Arg">n</var> is a positive integer, this function return a random lattice with <code class="code">m</code> vertices, where it is guaranteed that <code class="code">m</code> is between <var class="Arg">n</var> and <code class="code">2 * <var class="Arg">n</var></code>. See <code class="func">IsLatticeDigraph</code> (<a href="chap6.html#X78D3E17B7F737516"><span class="RefLink">6.4-3</span></a>).</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">RandomLattice(10);</span>
<immutable lattice digraph with 10 vertices, 39 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">RandomLattice(IsMutableDigraph, 10);</span>
<mutable digraph with 12 vertices, 52 edges>
</pre></div>

<p><a id="X7C76D1DC7DAF03D3" name="X7C76D1DC7DAF03D3"></a></p>

<h4>3.5 <span class="Heading">Standard examples</span></h4>

<p><a id="X7D5E3E337D03EDFF" name="X7D5E3E337D03EDFF"></a></p>

<h5>3.5-1 AndrasfaiGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ AndrasfaiGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is an integer greater than 0, then this operation returns the <var class="Arg">n</var>th <em>Andrasfai graph</em>. The Andrasfai graph is a circulant graph with <code class="code">3<var class="Arg">n</var> - 1</code> vertices. The indices of the Andrasfai graph are given by the numbers between <code class="code">1</code> and <code class="code">3<var class="Arg">n</var> - 1</code> that are congruent to <code class="code">1</code> mod <code class="code">3</code> (that is, for each index <span class="SimpleMath">j</span>, vertex <span class="SimpleMath">i</span> is adjacent to the <span class="SimpleMath">i + j</span>th and <span class="SimpleMath">i - j</span> vertices). The graph has <code class="code">6(3<var class="Arg">n</var> - 1)</code> edges. The graph is triangle free.</p>

<p>As a circulant graph, the Andrasfai graph is biconnected, cyclic, Hamiltonian, regular, and vertex transitive.</p>

<p>See <span class="URL"><a href="https://mathworld.wolfram.com/AndrasfaiGraph.html">https://mathworld.wolfram.com/AndrasfaiGraph.html</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := AndrasfaiGraph(4);</span>
<immutable Hamiltonian biconnected vertex-transitive symmetric digraph\
 with 11 vertices, 44 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsBiconnectedDigraph(D);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIsomorphicDigraph(D, CirculantGraph(11, [1, 4, 7, 10]));</span>
true</pre></div>

<p><a id="X8636C2898395B7DF" name="X8636C2898395B7DF"></a></p>

<h5>3.5-2 BananaTree</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ BananaTree</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var>, <var class="Arg">k</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph</p>

<p>If <var class="Arg">n</var> and <var class="Arg">k</var> are positive integers with <var class="Arg">k</var> greater than <span class="SimpleMath">1</span>, then this operation returns the <em>banana tree</em> with parameters <var class="Arg">n</var> and <var class="Arg">k</var>, as defined below.</p>

<p>From <span class="URL"><a href="https://mathworld.wolfram.com/BananaTree.html">https://mathworld.wolfram.com/BananaTree.html</a></span>:</p>

<p><q>An <code class="code">(<var class="Arg">n</var>,<var class="Arg">k</var>)</code>-banana tree, as defined by Chen et al. (1997), is a graph obtained by connecting one leaf of each of <var class="Arg">n</var> copies of an <var class="Arg">k</var>-star graph with a single root vertex that is distinct from all the stars.</q></p>

<p>Specifically, in the resulting digraph, vertex <code class="code">1</code> is the 'root', and for each <code class="code">m</code> in <code class="code">[1 .. <var class="Arg">k</var>]</code>, the <code class="code">m</code>th star is on the vertices <code class="code">[((m - 1) * n) + 2 .. (m * n) + 1]</code>, with the first of these being the 'centre' of the star, and the second being the 'leaf' adjacent <code class="code">1</code>.</p>

<p>See also <code class="func">StarGraph</code> (<a href="chap3.html#X78F78C077CBAE1EC"><span class="RefLink">3.5-45</span></a>) and <code class="func">IsUndirectedTree</code> (<a href="chap6.html#X80FC20FA7AC4BC2A"><span class="RefLink">6.6-9</span></a>).</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := BananaTree(2, 4);</span>
<immutable undirected tree with 9 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := BananaTree(3, 3);</span>
<immutable undirected tree with 10 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := BananaTree(5, 2);</span>
<immutable undirected tree with 11 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := BananaTree(3, 4);</span>
<immutable undirected tree with 13 vertices>
</pre></div>

<p><a id="X7FC309427BB170D8" name="X7FC309427BB170D8"></a></p>

<h5>3.5-3 BinaryTree</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ BinaryTree</code>( [<var class="Arg">filt</var>, ]<var class="Arg">m</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>This function returns a binary tree of depth <var class="Arg">m</var> with <code class="code">2 ^ <var class="Arg">m</var> - 1</code> vertices. All edges are directed towards the root of the tree, which is vertex <code class="code">1</code>.</p>

<p>Note that <code class="code">BinaryTree(<var class="Arg">m</var>)</code> is the induced subdigraph of <code class="code">BinaryTree(<var class="Arg">m</var>+1)</code> on the vertices <code class="code">[1..2^(<var class="Arg">m</var>-1)]</code>.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">BinaryTree(1);</span>
<immutable empty digraph with 1 vertex>
<span class="GAPprompt">gap></span> <span class="GAPinput">BinaryTree(8);</span>
<immutable digraph with 255 vertices, 254 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">BinaryTree(IsMutableDigraph, 8);</span>
<mutable digraph with 255 vertices, 254 edges>
</pre></div>

<p><a id="X845C374280D6EAA4" name="X845C374280D6EAA4"></a></p>

<h5>3.5-4 BinomialTreeGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ BinomialTreeGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is a positive integer then this operation returns the <var class="Arg">n</var>th <em>binomial tree graph</em>. The binomial tree graph has <var class="Arg">n</var> vertices and <code class="code"><var class="Arg">n</var>-1</code> undirected edges. The vertices of the binomial tree graph are the numbers from 1 to <var class="Arg">n</var> in binary representation, with a vertex <code class="code">v</code> having as a direct parent the vertex with binary representation the same as <code class="code">v</code> but with the lowest 1-bit cleared. For example, the vertex <span class="SimpleMath">011</span> has parent <span class="SimpleMath">010</span>, and the vertex <span class="SimpleMath">010</span> has parent <span class="SimpleMath">000</span>.</p>

<p>The binomial tree graph is an undirected tree, and is symmetric as a digraph.</p>

<p>See <span class="URL"><a href="https://metacpan.org/pod/Graph::Maker::BinomialTree">https://metacpan.org/pod/Graph::Maker::BinomialTree</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := BinomialTreeGraph(9);</span>
<immutable undirected tree with 9 vertices></pre></div>

<p><a id="X7E3240047C92733F" name="X7E3240047C92733F"></a></p>

<h5>3.5-5 BishopsGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ BishopsGraph</code>( [<var class="Arg">filt</var>, ][<var class="Arg">color</var>, ]<var class="Arg">m</var>, <var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ BishopGraph</code>( [<var class="Arg">filt</var>, ][<var class="Arg">color</var>, ]<var class="Arg">m</var>, <var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">m</var> and <var class="Arg">n</var> are positive integers, then this operation returns the <em>bishop's graph</em> of an <var class="Arg">m</var> by <var class="Arg">n</var> chessboard, as a symmetric digraph.</p>

<p>A bishop's graph represents all possible moves of the bishop chess piece across a chessboard. An <var class="Arg">m</var> by <var class="Arg">n</var> chessboard is a grid of <var class="Arg">m</var> columns ("files") and <var class="Arg">n</var> rows ("ranks") that intersect in squares. Orthogonally adjacent squares are alternately colored light and dark, with the square in the first rank and file being dark.</p>

<p>The <code class="code"><var class="Arg">m</var> * <var class="Arg">n</var></code> vertices of the bishop's graph can be placed onto the <code class="code"><var class="Arg">m</var> * <var class="Arg">n</var></code> squares of an <var class="Arg">m</var> by <var class="Arg">n</var> chessboard, such that two vertices are adjacent in the digraph if and only if a bishop can move between the corresponding squares in a single turn. A legal bishop's move is defined as any move which moves the bishop piece to a diagonally adjacent square or to a square which can be reached through a series of diagonally adjacent squares, with all of these small moves being in the same direction.</p>

<p>The chosen correspondence between vertices and chess squares is given by <code class="func">DigraphVertexLabels</code> (<a href="chap5.html#X7E51F2FE87140B32"><span class="RefLink">5.1-12</span></a>). In more detail, the vertices of the digraph are labelled by elements of the Cartesian product <code class="code">[1..<var class="Arg">m</var>] x [1..<var class="Arg">n</var>]</code>, where the first entry indexes the column (file) of the square in the chessboard, and the second entry indexes the row (rank) of the square. (Note that the files are traditionally indexed by the lowercase letters of the alphabet). The vertices are sorted in ascending order, first by row (second component) and then column (first component). If the optional second argument <var class="Arg">color</var> is present, then this should be one of the strings <code class="code">"dark"</code>, <code class="code">"light"</code>, or <code class="code">"both"</code>. The default is <code class="code">"both"</code>. A bishop on a light square can only move to light squares, and a bishop on a dark square can only move to dark squares. This optional argument controls which bishops are represented in the resulting digraph. If <var class="Arg">color</var> is <code class="code">"both"</code>, then the resulting digraph will show all the vertices of an <var class="Arg">m</var> by <var class="Arg">n</var> chessboard, and will be disconnected (unless <code class="code"><var class="Arg">m</var> = <var class="Arg">n</var> = 1</code>). Otherwise, <code class="func">BishopsGraph</code> returns the induced subdigraph of this on the vertices that correspond to either the dark squares or the light squares, according to the value of <var class="Arg">color</var>.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">BishopsGraph(8, 8);</span>
<immutable symmetric digraph with 64 vertices, 560 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := BishopsGraph("dark", 3, 5);</span>
<immutable connected symmetric digraph with 8 vertices, 24 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsConnectedDigraph(D);       </span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">BishopsGraph("light", 4, 4);</span>
<immutable connected symmetric digraph with 8 vertices, 28 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := BishopsGraph("both", 1, 5);</span>
<immutable empty digraph with 5 vertices>
</pre></div>

<p><a id="X81A0AC37816D287B" name="X81A0AC37816D287B"></a></p>

<h5>3.5-6 BondyGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ BondyGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is a non-negative integer then this operation returns the <var class="Arg">n</var>th <em>Bondy graph</em>. The Bondy graphs are a family of hypohamiltonian graphs: a graph which is not Hamiltonian itself but the removal of any vertex produces a Hamiltonian graph. The Bondy graphs are the <code class="code">(3(2<var class="Arg">n</var> + 1) + 2, 2)</code>-th Generalised Petersen graphs, and have <code class="code">12<var class="Arg">n</var> + 10</code> vertices and <code class="code">15 + 18<var class="Arg">n</var></code> undirected edges.</p>

<p>See <span class="URL"><a href="https://mathworld.wolfram.com/HypohamiltonianGraph.html">https://mathworld.wolfram.com/HypohamiltonianGraph.html</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := BondyGraph(1);</span>
<immutable symmetric digraph with 22 vertices, 66 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsHamiltonianDigraph(D);</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">G := List([1 .. 22], x -> DigraphRemoveVertex(D, x));;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">ForAll(G, IsHamiltonianDigraph);</span>
true</pre></div>

<p><a id="X861F493382FA7C0B" name="X861F493382FA7C0B"></a></p>

<h5>3.5-7 BookGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ BookGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">m</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>The <em>book graph</em> is the Cartesian product of a complete digraph with two vertices (as the "book spine") and the <span class="SimpleMath"><var class="Arg">m</var>+1</span> star graph (as the "pages"). For more details on the book graph please refer to <span class="URL"><a href="https://mathworld.wolfram.com/BookGraph.html">https://mathworld.wolfram.com/BookGraph.html</a></span>.</p>

<p>See <code class="func">DigraphCartesianProduct</code> (<a href="chap3.html#X7D625CC87DBFFDED"><span class="RefLink">3.3-32</span></a>), <code class="func">CompleteDigraph</code> (<a href="chap3.html#X812417E278198D9C"><span class="RefLink">3.5-13</span></a>), and <code class="func">StarGraph</code> (<a href="chap3.html#X78F78C077CBAE1EC"><span class="RefLink">3.5-45</span></a>).</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">BookGraph(1);</span>
<immutable bipartite symmetric digraph with bicomponents of size 2>
<span class="GAPprompt">gap></span> <span class="GAPinput">BookGraph(2);</span>
<immutable bipartite symmetric digraph with bicomponents of size 3>
<span class="GAPprompt">gap></span> <span class="GAPinput">BookGraph(IsMutable, 12);</span>
<mutable digraph with 26 vertices, 74 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">BookGraph(7);</span>
<immutable bipartite symmetric digraph with bicomponents of size 8>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsSymmetricDigraph(BookGraph(24));</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsBipartiteDigraph(BookGraph(24));</span>
true
</pre></div>

<p><a id="X8542287E81BDB55E" name="X8542287E81BDB55E"></a></p>

<h5>3.5-8 BurntPancakeGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ BurntPancakeGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is a positive integer, then this operation returns the <em>burnt pancake graph</em> with <span class="SimpleMath">n!</span> vertices and <span class="SimpleMath">n2^nn!</span> directed edges. The <span class="SimpleMath">n</span>th burnt pancake graph is the Cayley graph of the hyperoctahedral group acting on <code class="code">[<var class="Arg">-n</var> .. -1, 1 .. <var class="Arg">n</var>]</code> with respect to the generating set consisting of the <q>prefix reversals</q>, which are defined in exactly the same way as in <code class="func">PancakeGraph</code> (<a href="chap3.html#X84C1D3D67E3979A5"><span class="RefLink">3.5-9</span></a>). The hyperoctahedral group consists of permutations <span class="SimpleMath">p</span> acting on <code class="code">[<var class="Arg">-n</var> .. -1, 1 .. <var class="Arg">n</var>]</code>, where the image of every point <span class="SimpleMath">i</span> in <code class="code">[<var class="Arg">-n</var> .. -1, 1 .. <var class="Arg">n</var>]</code> is equal to the negative of the image of <span class="SimpleMath">-i</span> under <span class="SimpleMath">p</span>. GAP only works with permutations of positive integers and so <code class="code">BurntPancakeGraph</code> returns the Cayley graph of the hyperoctahedral group acting on <code class="code">[1 .. <var class="Arg">2n</var>]</code> instead of <code class="code">[<var class="Arg">-n</var> .. -1, 1 .. <var class="Arg">n</var>]</code>. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>

<p>See <span class="URL"><a href="https://en.wikipedia.org/wiki/Pancake_graph">https://en.wikipedia.org/wiki/Pancake_graph</a></span> for further details.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">BurntPancakeGraph(3);</span>
<immutable symmetric digraph with 48 vertices, 144 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">BurntPancakeGraph(4);</span>
<immutable symmetric digraph with 384 vertices, 1536 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">BurntPancakeGraph(5);</span>
<immutable symmetric digraph with 3840 vertices, 19200 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">BurntPancakeGraph(IsMutableDigraph, 1);</span>
<mutable digraph with 1 vertex, 1 edge>
</pre></div>

<p><a id="X84C1D3D67E3979A5" name="X84C1D3D67E3979A5"></a></p>

<h5>3.5-9 PancakeGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ PancakeGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is a positive integer, then this operation returns the <em>pancake graph</em> with <span class="SimpleMath">n!</span> vertices and <span class="SimpleMath">n!(n - 1)</span> directed edges. The <span class="SimpleMath">n</span>th pancake graph is the Cayley graph of the symmetric group acting on <code class="code">[1 .. <var class="Arg">n</var>]</code> with respect to the generating set consisting of the <q>prefix reversals</q>. This generating set consists of the permutations <code class="code">p2</code>, <code class="code">p3</code>, ..., <code class="code">p<var class="Arg">n</var></code> where <code class="code">ListPerm(pi, <var class="Arg">n</var>)</codeis the concatenation of <code class="code">[i, i - 1 .. 1]</code> and <code class="code">[i + 1 .. <var class="Arg">n</var>]</code>.</p>

<p>If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>

<p>See <span class="URL"><a href="https://en.wikipedia.org/wiki/Pancake_graph">https://en.wikipedia.org/wiki/Pancake_graph</a></span> for further details.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := PancakeGraph(5);</span>
<immutable Hamiltonian symmetric digraph with 120 vertices, 480 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphUndirectedGirth(D);</span>
6
<span class="GAPprompt">gap></span> <span class="GAPinput">ChromaticNumber(D);</span>
3
<span class="GAPprompt">gap></span> <span class="GAPinput">IsHamiltonianDigraph(D);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsCayleyDigraph(D);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsVertexTransitive(D);</span>
true</pre></div>

<p><a id="X7B5E9D857D47F5C2" name="X7B5E9D857D47F5C2"></a></p>

<h5>3.5-10 StackedBookGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ StackedBookGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">m</var>, <var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>The <em>stacked book graph</em> is the Cartesian product of the symmetric closure of the chain digraph with <var class="Arg">n</var> vertices (as the "book spine") and the <span class="SimpleMath"><var class="Arg">m</var>+1</span> star graph (as the "pages"). For more details on the stacked book graph please refer to <span class="URL"><a href="https://mathworld.wolfram.com/StackedBookGraph.html">https://mathworld.wolfram.com/StackedBookGraph.html</a></span>.</p>

<p>See <code class="func">DigraphCartesianProduct</code> (<a href="chap3.html#X7D625CC87DBFFDED"><span class="RefLink">3.3-32</span></a>), <code class="func">DigraphSymmetricClosure</code> (<a href="chap3.html#X874883DD7DD450C4"><span class="RefLink">3.3-12</span></a>), <code class="func">ChainDigraph</code> (<a href="chap3.html#X870594FC866AC88E"><span class="RefLink">3.5-11</span></a>), and <code class="func">StarGraph</code> (<a href="chap3.html#X78F78C077CBAE1EC"><span class="RefLink">3.5-45</span></a>).</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">StackedBookGraph(1, 1);</span>
<immutable bipartite symmetric digraph with bicomponents of size 1>
<span class="GAPprompt">gap></span> <span class="GAPinput">StackedBookGraph(1, 2);</span>
<immutable bipartite symmetric digraph with bicomponents of size 2>
<span class="GAPprompt">gap></span> <span class="GAPinput">StackedBookGraph(3, 4);</span>
<immutable bipartite symmetric digraph with bicomponents of size 8>
<span class="GAPprompt">gap></span> <span class="GAPinput">StackedBookGraph(IsMutable, 12, 5);</span>
<mutable digraph with 65 vertices, 224 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">StackedBookGraph(5, 5);</span>
<immutable bipartite symmetric digraph with bicomponent sizes 13 and 1\
7>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsSymmetricDigraph(StackedBookGraph(24, 8));</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsBipartiteDigraph(StackedBookGraph(24, 8));</span>
true
</pre></div>

<p><a id="X870594FC866AC88E" name="X870594FC866AC88E"></a></p>

<h5>3.5-11 ChainDigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ChainDigraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is a positive integer, this function returns a chain with <var class="Arg">n</var> vertices and <code class="code"><var class="Arg">n</var> - 1</code> edges. Specifically, for each vertex <code class="code">i</code> (with <code class="code">i</code> < <code class="code">n</code>), there is a directed edge with source <code class="code">i</code> and range <code class="code">i + 1</code>.</p>

<p>The <code class="func">DigraphReflexiveTransitiveClosure</code> (<a href="chap3.html#X7A6C419080AD41DE"><span class="RefLink">3.3-13</span></a>) of a chain represents a total order.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">ChainDigraph(42);</span>
<immutable chain digraph with 42 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">ChainDigraph(IsMutableDigraph, 10);</span>
<mutable digraph with 10 vertices, 9 edges>
</pre></div>

<p><a id="X7DB5AB657A797CF2" name="X7DB5AB657A797CF2"></a></p>

<h5>3.5-12 CirculantGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ CirculantGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var>, <var class="Arg">par</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is an integer greater than 1, and <var class="Arg">par</var> is a list of integers that are contained in <code class="code">[1..<var class="Arg">n</var>]</code> then this operation returns a <em>circulant graph</em>. The circulant graph is a graph on <var class="Arg">n</var> vertices, where for each element <span class="SimpleMath">j</span> of <var class="Arg">par</var>, the <span class="SimpleMath">i</span>th vertex is adjacent to the <span class="SimpleMath">(i + j)</span>th and <span class="SimpleMath">(i - j)</span>th vertices.</p>

<p>If <var class="Arg">par</var> is <span class="SimpleMath">[1]</span>, then the graph is the <var class="Arg">n</var>th cyclic graph. If <var class="Arg">par</var> is <code class="code">[1,2,...,Int(<var class="Arg">n</var>/2)]</code>, then the graph is the complete graph on <var class="Arg">n</var> vertices. If <var class="Arg">n</var> is at least 4 and <var class="Arg">par</var> is <code class="code">[1,<var class="Arg">n</var>]</code> then the graph is the <var class="Arg">n</var>th Mobius ladder graph.</p>

<p>A circulant graph is vertex transitive, but is not necessarily connected (consider <code class="code">CirculantGraph(4, [2])</code>, for example). However, a <em>connected</em> circulant graph is also Hamiltonian and biconnected.</p>

<p>See <span class="URL"><a href="https://mathworld.wolfram.com/CirculantGraph.html">https://mathworld.wolfram.com/CirculantGraph.html</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CirculantGraph(6, [2]);</span>
<immutable vertex-transitive symmetric digraph with 6 vertices, 12 edg\
es>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphNrConnectedComponents(D);</span>
2
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CirculantGraph(6, [2, 3]);</span>
<immutable Hamiltonian biconnected vertex-transitive symmetric digraph\
 with 6 vertices, 18 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">AutomorphismGroup(D) = DihedralGroup(IsPermGroup, 12);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">HamiltonianPath(D);</span>
[ 1, 3, 5, 2, 6, 4 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">IsCompleteDigraph(CirculantGraph(6, [1, 2, 3]));</span>
true</pre></div>

<p><a id="X812417E278198D9C" name="X812417E278198D9C"></a></p>

<h5>3.5-13 CompleteDigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ CompleteDigraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is a non-negative integer, this function returns the complete digraph with <var class="Arg">n</var> vertices. See <code class="func">IsCompleteDigraph</code> (<a href="chap6.html#X81F28D4D879FE3B2"><span class="RefLink">6.2-5</span></a>).</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">CompleteDigraph(20);</span>
<immutable complete digraph with 20 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">CompleteDigraph(IsMutableDigraph, 10);</span>
<mutable digraph with 10 vertices, 90 edges>
</pre></div>

<p><a id="X8795B0AD856014FA" name="X8795B0AD856014FA"></a></p>

<h5>3.5-14 CompleteBipartiteDigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ CompleteBipartiteDigraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">m</var>, <var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>A complete bipartite digraph is a digraph whose vertices can be partitioned into two non-empty vertex sets, such there exists a unique edge with source <code class="code">i</code> and range <code class="code">j</code> if and only if <code class="code">i</code> and <code class="code">j</code> lie in different vertex sets.</p>

<p>If <var class="Arg">m</var> and <var class="Arg">n</var> are positive integers, this function returns the complete bipartite digraph with vertex sets of sizes <var class="Arg">m</var> (containing the vertices <code class="code">[1 .. m]</code>) and <var class="Arg">n</var> (containing the vertices <code class="code">[m + 1 .. m + n]</code>).</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">CompleteBipartiteDigraph(2, 3);</span>
<immutable complete bipartite digraph with bicomponent sizes 2 and 3>
<span class="GAPprompt">gap></span> <span class="GAPinput">CompleteBipartiteDigraph(IsMutableDigraph, 3, 2);</span>
<mutable digraph with 5 vertices, 12 edges>
</pre></div>

<p><a id="X873F29CC863241F8" name="X873F29CC863241F8"></a></p>

<h5>3.5-15 CompleteMultipartiteDigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ CompleteMultipartiteDigraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">orders</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>For a list <var class="Arg">orders</var> of <code class="code">n</code> positive integers, this function returns the digraph containing <code class="code">n</code> independent sets of vertices of orders <code class="code">[<var class="Arg">l</var>[1] .. <var class="Arg">l</var>[n]]</code>. Moreover, each vertex is adjacent to every other not contained in the same independent set.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">CompleteMultipartiteDigraph([5, 4, 2]);</span>
<immutable complete multipartite digraph with 11 vertices, 76 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">CompleteMultipartiteDigraph(IsMutableDigraph, [5, 4, 2]);</span>
<mutable digraph with 11 vertices, 76 edges>
</pre></div>

<p><a id="X80C29DDE876FFBEB" name="X80C29DDE876FFBEB"></a></p>

<h5>3.5-16 CycleDigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ CycleDigraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphCycle</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is a positive integer, then these functions return a <em>cycle digraph</em> with <var class="Arg">n</var> vertices and <var class="Arg">n</var> edges. Specifically, for each vertex <code class="code">i</code> (with <code class="code">i</code> < <code class="code">n</code>), there is a directed edge with source <code class="code">i</code> and range <code class="code">i + 1</code>. In addition, there is an edge with source <code class="code">n</code> and range <code class="code">1</code>.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">CycleDigraph(1);</span>
<immutable digraph with 1 vertex, 1 edge>
<span class="GAPprompt">gap></span> <span class="GAPinput">CycleDigraph(123);</span>
<immutable cycle digraph with 123 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">CycleDigraph(IsMutableDigraph, 10);</span>
<mutable digraph with 10 vertices, 10 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphCycle(4) = CycleDigraph(4);</span>
true
</pre></div>

<p><a id="X7F6EC0AE81531C3C" name="X7F6EC0AE81531C3C"></a></p>

<h5>3.5-17 CycleGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ CycleGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is an integer greater than 2 then this operation returns the <var class="Arg">n</var>th <em>cycle graph</em>, consisting of the cycle on <var class="Arg">n</var> vertices. The cycle graph, unlike the cycle digraph, is symmetric. The cycle graph has <var class="Arg">n</varvertices and <var class="Arg">n</var> undirected edges. The cycle graph is simple so the non-simple graphs with a single vertex and single loop and with two vertices and two edges between them are excluded.</p>

<p>See <span class="URL"><a href="https://mathworld.wolfram.com/CycleGraph.html">https://mathworld.wolfram.com/CycleGraph.html</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CycleGraph(7);</span>
<immutable symmetric digraph with 7 vertices, 14 edges></pre></div>

<p><a id="X80DAE31A79FEFD40" name="X80DAE31A79FEFD40"></a></p>

<h5>3.5-18 EmptyDigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ EmptyDigraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ NullDigraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is a non-negative integer, this function returns the <em>empty</em> or <em>null</em> digraph with <var class="Arg">n</var> vertices. An empty digraph is one with no edges.</p>

<p><code class="code">NullDigraph</code> is a synonym for <code class="code">EmptyDigraph</code>.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">EmptyDigraph(20);</span>
<immutable empty digraph with 20 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">NullDigraph(10);</span>
<immutable empty digraph with 10 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">EmptyDigraph(IsMutableDigraph, 10);</span>
<mutable empty digraph with 10 vertices></pre></div>

<p><a id="X7CE45E2B782ADE9A" name="X7CE45E2B782ADE9A"></a></p>

<h5>3.5-19 GearGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ GearGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is a positive integer at least 3, then this operation returns the <em>gear graph</em> with <code class="code">2<var class="Arg">n</var> + 1</code> vertices and <code class="code">3<var class="Arg">n</var></code> undirected edges. The <var class="Arg">n</var>th gear graph is the <code class="code">2<var class="Arg"></var></code>th cycle graph with one additional central vertex, to which every other vertex of the cycle is connected. The gear graph is a symmetric digraph. A gear graph is a Matchstick graph, that is it is simple with a planar graph embedding, and is a unit-distance graph (that is, it can be embedded into the Euclidean plane with vertices being distinct points and edges having length 1).</p>

<p>See <span class="URL"><a href="https://mathworld.wolfram.com/GearGraph.html">https://mathworld.wolfram.com/GearGraph.html</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := GearGraph(4);</span>
<immutable symmetric digraph with 9 vertices, 24 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">ChromaticNumber(D);</span>
2
<span class="GAPprompt">gap></span> <span class="GAPinput">IsVertexTransitive(D);</span>
false</pre></div>

<p><a id="X795B62398767E313" name="X795B62398767E313"></a></p>

<h5>3.5-20 HaarGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ HaarGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is a positive integer then this operation returns the <em>Haar graph</em> <span class="SimpleMath">H(<var class="Arg">n</var>)</span>.</p>

<p>The number of vertices in the Haar graph <span class="SimpleMath">H(<var class="Arg">n</var>)</span> is equal to twice <span class="SimpleMath">m</span>, where <span class="SimpleMath">m</span> is the number of digits required to represent <var class="Arg">n</var> in binary. These vertices are arranged into bicomponents <code class="code">[1..m]</code> and <code class="code">[m+1..2*m]</code>. Vertices <span class="SimpleMath">i</span> and <span class="SimpleMath">j</span> in different bicomponents are adjacent by a symmetric pair of edges if and only if the binary representation of <var class="Arg">n</var> has a 1 in position (<span class="SimpleMath">j-i</span> modulo <span class="SimpleMath">m</span>) + 1 from the left.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">HaarGraph(3);</span>
<immutable bipartite vertex-transitive symmetric digraph with bicompon\
ents of size 2>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := HaarGraph(16);</span>
<immutable bipartite vertex-transitive symmetric digraph with bicompon\
ents of size 5>
</pre></div>

<p><a id="X801024F57DDC8A39" name="X801024F57DDC8A39"></a></p>

<h5>3.5-21 HalvedCubeGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ HalvedCubeGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is a positive integer at least 1, then this operation returns the <var class="Arg">n</var>th <em>halved cube graph</em>, the graph of the <var class="Arg">n</var>- demihypercube. The vertices of the graph are those of the <var class="Arg">n</var>th- hypercube, with two vertices adjacent if and only if they are at distance 1 or 2 from each other. Equivalent constructions are as the second graph power of the <code class="code"><var class="Arg">n</var>-1</code>th hypercube graph, or as with vertices labelled as the binary numbers where two vertices are adjacent if they differ in a single bit, or with vertices labelled with the subset of binary numbers with even Hamming weight, with edges connecting vertices with Hamming distance exactly 2. The Halved Cube graph is distance regular and contains a Hamiltonian cycle.</p>

<p>See <span class="URL"><a href="https://mathworld.wolfram.com/HalvedCubeGraph.html">https://mathworld.wolfram.com/HalvedCubeGraph.html</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := HalvedCubeGraph(3);</span>
<immutable Hamiltonian symmetric digraph with 4 vertices, 12 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsDistanceRegularDigraph(D);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsHamiltonianDigraph(D);</span>
true</pre></div>

<p><a id="X7C43BDE47DF6553A" name="X7C43BDE47DF6553A"></a></p>

<h5>3.5-22 HanoiGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ HanoiGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is positive integer then this operation returns the <var class="Arg">n</var>th <em>Hanoi graph</em>. The Hanoi graph's vertices represent the possible states of the 'Tower of Hanoi' puzzle on three 'towers', while its edges represent possible moves. The Hanoi graph has <code class="code">3^<var class="Arg">n</var></code> vertices, and <code class="code">3 * (3^<var class="Arg">n</var> - 1) / 2</code> undirected edges.</p>

<p>The Hanoi graph is Hamiltonian. The graph superficially resembles the Sierpinski triangle. The graph is also a 'penny graph' - a graph whose vertices can be considered to be non-overlapping unit circles on a flat surface, with two vertices adjacent only if the unit circles touch at a single point. Thus the Hanoi graph is planar.</p>

<p>See <span class="URL"><a href="https://mathworld.wolfram.com/HanoiGraph.html">https://mathworld.wolfram.com/HanoiGraph.html</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := HanoiGraph(5);</span>
<immutable planar Hamiltonian symmetric digraph with 243 vertices, 726\
 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsPlanarDigraph(D);</span>
true</pre></div>

<p><a id="X782ABFCE812B020A" name="X782ABFCE812B020A"></a></p>

<h5>3.5-23 HelmGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ HelmGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is a positive integer at least 3, then this operation returns the <var class="Arg">n</var>th <em>helm graph</em>. The helm graph is the <var class="Arg">n</var>-1th wheel graph with, for each external vertex of the 'wheel', adjoining a new vertex incident only to the first vertex. That is, the graph looks similar to a ship's helm.</p>

<p>See <span class="URL"><a href="https://mathworld.wolfram.com/WheelGraph.html">https://mathworld.wolfram.com/WheelGraph.html</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := HelmGraph(4);</span>
<immutable symmetric digraph with 9 vertices, 24 edges></pre></div>

<p><a id="X7EE552F88609B1A2" name="X7EE552F88609B1A2"></a></p>

<h5>3.5-24 HypercubeGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ HypercubeGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is a non-negative integer, then this operation returns the <var class="Arg">n</var>th <em>hypercube graph</em>. The graph has <code class="code">2^<var class="Arg">n</var></code> vertices and <code class="code">2^(<var class="Arg">n</var>-1)<var class="Arg">n</var></codeedges. It is formed from the vertices and edges of the <var class="Arg">n</var>-dimensional hypercube. Alternatively, the graph can be constructed by labelling each vertex with the binary numbers, with two vertices adjacent if they have Hamming distance exactly one. The hypercube graphs are Hamiltonian, distance-transitive and therefore distance-regular, and bipartite.</p>

<p>See <span class="URL"><a href="https://mathworld.wolfram.com/HypercubeGraph.html">https://mathworld.wolfram.com/HypercubeGraph.html</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := HypercubeGraph(5);</span>
<immutable Hamiltonian bipartite symmetric digraph with bicomponents o\
f size 16>
</pre></div>

<p><a id="X80ED9CE785819607" name="X80ED9CE785819607"></a></p>

<h5>3.5-25 JohnsonDigraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ JohnsonDigraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var>, <var class="Arg">k</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> and <var class="Arg">k</var> are non-negative integers, then this operation returns a symmetric digraph which corresponds to the undirected <em>Johnson graph</em> <span class="SimpleMath">J(n, k)</span>.</p>

<p>The <em>Johnson graph</em> <span class="SimpleMath">J(n, k)</span> has vertices given by all the <var class="Arg">k</var>-subsets of the range <code class="code">[1 .. <var class="Arg">n</var>]</code>, and two vertices are connected by an edge if and only if their intersection has size <span class="SimpleMath"><var class="Arg">k</var> - 1</span>.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">gr := JohnsonDigraph(3, 1);</span>
<immutable symmetric digraph with 3 vertices, 6 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(gr);</span>
[ [ 2, 3 ], [ 1, 3 ], [ 1, 2 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">gr := JohnsonDigraph(4, 2);</span>
<immutable symmetric digraph with 6 vertices, 24 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbours(gr);</span>
[ [ 2, 3, 4, 5 ], [ 1, 3, 4, 6 ], [ 1, 2, 5, 6 ], [ 1, 2, 5, 6 ], 
  [ 1, 3, 4, 6 ], [ 2, 3, 4, 5 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">JohnsonDigraph(1, 0);</span>
<immutable empty digraph with 1 vertex>
<span class="GAPprompt">gap></span> <span class="GAPinput">JohnsonDigraph(IsMutableDigraph, 1, 0);</span>
<mutable empty digraph with 1 vertex>
</pre></div>

<p><a id="X79483C677AF65688" name="X79483C677AF65688"></a></p>

<h5>3.5-26 KellerGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ KellerGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is a nonnegative integer then this operation returns the <var class="Arg">n</var>th or <var class="Arg">n</var>-dimensional <em>Keller graph</em>. The graph has vertices given by the <var class="Arg">n</var>-tuples on the set <span class="SimpleMath">[0, 1, 2, 3]</span>. Two vertices are adjacent if their respective tuples are such that they differ in at least two coordinates and in at least one coordinate the difference between the two is <code class="code">2</code> mod <code class="code">4</code>. The Keller graph has <code class="code">4^<var class="Arg">n</var></code> vertices.</p>

<p>The Keller graphs were constructed with the intention of finding counterexamples to Keller's conjecture (<span class="URL"><a href="https://mathworld.wolfram.com/KellersConjecture.html">https://mathworld.wolfram.com/KellersConjecture.html</a></span>), and has been used since for testing maximum clique algorithms.</p>

<p>If <var class="Arg">n</var> is 1 then the graph is empty, for <var class="Arg">n</var> greater than 1 the chromatic number of the Keller graph is <code class="code">2^<var class="Arg">n</var></code> and the graph is Hamiltonian.</p>

<p>See <span class="URL"><a href="https://mathworld.wolfram.com/KellerGraph.html">https://mathworld.wolfram.com/KellerGraph.html</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := KellerGraph(3);</span>
<immutable Hamiltonian symmetric digraph with 64 vertices, 2176 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">ChromaticNumber(D);</span>
8</pre></div>

<p><a id="X80576A8C861512FD" name="X80576A8C861512FD"></a></p>

<h5>3.5-27 KingsGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ KingsGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">m</var>, <var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">m</var> and <var class="Arg">n</var> are positive integers, then this operation returns the <em>king's graph</em> of an <var class="Arg">m</var> by <var class="Arg">n</var> chessboard, as a symmetric digraph.</p>

<p>The king's graph represents all possible moves of the king chess piece across a chessboard. An <var class="Arg">m</var> by <var class="Arg">n</var> chessboard is a grid of <var class="Arg">m</var> columns ("files") and <var class="Arg">n</var> rows ("ranks") that intersect in squares. Orthogonally adjacent squares are alternately colored light and dark, with the square in the first rank and file being dark.</p>

<p>The king can move only to any orthogonally or diagonally adjacent square. Thus the <code class="code"><var class="Arg">m</var> * <var class="Arg">n</var></code> vertices of the king's graph can be placed onto the <code class="code"><var class="Arg">m</var> * <var class="Arg">n</var></code> squares of an <var class="Arg">m</var> by <var class="Arg">n</var> chessboard, such that two vertices are adjacent in the digraph if and only if the corresponding squares are orthogonally or diagonally adjacent on the chessboard.</p>

<p>The chosen correspondence between vertices and chess squares is given by <code class="func">DigraphVertexLabels</code> (<a href="chap5.html#X7E51F2FE87140B32"><span class="RefLink">5.1-12</span></a>). In more detail, the vertices of the digraph are labelled by elements of the Cartesian product <code class="code">[1..<var class="Arg">m</var>] x [1..<var class="Arg">n</var>]</code>, where the first entry indexes the column (file) of the square in the chessboard, and the second entry indexes the row (rank) of the square. (Note that the files are traditionally indexed by the lowercase letters of the alphabet). The vertices are sorted in ascending order, first by row (second component) and then column (first component). See <span class="URL"><a href="https://en.wikipedia.org/wiki/King's_graph">Wikipedia</a></span> for further information. See also <code class="func">SquareGridGraph</code> (<a href="chap3.html#X8404987F849D7CF2"><span class="RefLink">3.5-43</span></a>), <code class="func">TriangularGridGraph</code> (<a href="chap3.html#X8234361278E8816F"><span class="RefLink">3.5-44</span></a>), and <code class="func">StrongProduct</code> (<a href="chap3.html#X82E200F07FEFAF27"><span class="RefLink">3.3-38</span></a>).</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">KingsGraph(8, 8);</span>
<immutable connected symmetric digraph with 64 vertices, 420 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := KingsGraph(IsMutable, 2, 7);</span>
<mutable digraph with 14 vertices, 62 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsPlanarDigraph(D);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">D := KingsGraph(3, 3);</span>
<immutable planar connected symmetric digraph with 9 vertices, 40 edge\
s>
<span class="GAPprompt">gap></span> <span class="GAPinput">OutNeighbors(D);</span>
[ [ 2, 4, 5 ], [ 1, 3, 5, 4, 6 ], [ 2, 6, 5 ], [ 5, 1, 7, 2, 8 ], 
  [ 4, 6, 2, 8, 3, 7, 1, 9 ], [ 5, 3, 9, 8, 2 ], [ 8, 4, 5 ], 
  [ 7, 9, 5, 6, 4 ], [ 8, 6, 5 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">IsSubdigraph(QueensGraph(3, 4), KingsGraph(3, 4));</span>
true
</pre></div>

<p><a id="X8655BA8584B3ACD0" name="X8655BA8584B3ACD0"></a></p>

<h5>3.5-28 KneserGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ KneserGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var>, <var class="Arg">k</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> and <var class="Arg">k</var> are integers greater than 0, with <var class="Arg">k</var> less than <var class="Arg">n</var>, then this operation returns the <code class="code">(<var class="Arg">n</var>,<var class="Arg">k</var>)</code>-th <em>Kneser graph</em>. The Kneser graph's vertices correspond to the <var class="Arg">k</var>- element subsets of a set of <var class="Arg">n</var> elements, with two vertices being adjacent if and only if the subsets are disjoint. The graph has <code class="code">Binomial(<var class="Arg">n</var>, <var class="Arg">k</var>)</code> vertices and <code class="code">Binomial(<var class="Arg">n</var>, <var class="Arg">k</var>) * Binomial(<var class="Arg">n</var> - <var class="Arg">k</var>, <var class="Arg">k</var>)</code> edges. Kneser graphs are regular, edge transitive, and vertex transitive. If <var class="Arg">k</var> is 1, then the graph is the complete graph on <var class="Arg">n</var> vertices. If <code class="code">(<var class="Arg">n</var>, <var class="Arg">k</var>)</code> is <code class="code">(2m-1, <var class="Arg">n</var>-1)</code>, then the graph is the <code class="code">m</code>th Odd graph. The Petersen graph is the <span class="SimpleMath">(5, 2)</span>th Kneser graph.</p>

<p>If <code class="code"><var class="Arg">n</var> >= 2<var class="Arg">k</var></code> then the graph's chromatic number is <code class="code"><var class="Arg">n</var> - 2<var class="Arg">k</var> + 2</code>, and otherwise is 1. The Kneser graph contains a Hamiltonian cycle if <code class="code"><var class="Arg">n</var> >= ((3 + 5 ^ 0.5) / 2)<var class="Arg">k</var> + 1</code>. The graph has clique number equal to the floor of <code class="code"><var class="Arg">n</var> / <var class="Arg">k</var></code>.</p>

<p>See <span class="URL"><a href="https://mathworld.wolfram.com/KneserGraph.html">https://mathworld.wolfram.com/KneserGraph.html</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := KneserGraph(7, 3);</span>
<immutable edge- and vertex-transitive symmetric digraph with 35 verti\
ces, 140 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsRegularDigraph(D);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">ChromaticNumber(D);</span>
3
<span class="GAPprompt">gap></span> <span class="GAPinput">CliqueNumber(D);</span>
2</pre></div>

<p><a id="X84609DCA79FD9B56" name="X84609DCA79FD9B56"></a></p>

<h5>3.5-29 KnightsGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ KnightsGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">m</var>, <var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">m</var> and <var class="Arg">n</var> are positive integers, then this operation returns the <em>knight's graph</em> of an <var class="Arg">m</var> by <var class="Arg">n</var> chessboard, as a symmetric digraph.</p>

<p>A knight's graph represents all possible moves of the knight chess piece across a chessboard. An <var class="Arg">m</var> by <var class="Arg">n</var> chessboard is a grid of <var class="Arg">m</var> columns ("files") and <var class="Arg">n</var> rows ("ranks") that intersect in squares. Orthogonally adjacent squares are alternately colored light and dark, with the square in the first rank and file being dark.</p>

<p>The <code class="code"><var class="Arg">m</var> * <var class="Arg">n</var></code> vertices of the knight's graph can be placed onto the <code class="code"><var class="Arg">m</var> * <var class="Arg">n</var></code> squares of an <var class="Arg">m</var> by <var class="Arg">n</var> chessboard, such that two vertices are adjacent in the digraph if and only if a knight can move between the corresponding squares in a single turn.</p>

<p>The chosen correspondence between vertices and chess squares is given by <code class="func">DigraphVertexLabels</code> (<a href="chap5.html#X7E51F2FE87140B32"><span class="RefLink">5.1-12</span></a>). In more detail, the vertices of the digraph are labelled by elements of the Cartesian product <code class="code">[1..<var class="Arg">m</var>] x [1..<var class="Arg">n</var>]</code>, where the first entry indexes the column (file) of the square in the chessboard, and the second entry indexes the row (rank) of the square. (Note that the files are traditionally indexed by the lowercase letters of the alphabet). The vertices are sorted in ascending order, first by row (second component) and then column (first component). See <span class="URL"><a href="https://en.wikipedia.org/wiki/Knight's_graph">Wikipedia</a></span> for further information.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := KnightsGraph(8, 8);</span>
<immutable connected symmetric digraph with 64 vertices, 336 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsConnectedDigraph(D);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">D := KnightsGraph(3, 3);</span>
<immutable symmetric digraph with 9 vertices, 16 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsConnectedDigraph(D);</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">KnightsGraph(IsMutable, 3, 9);</span>
<mutable digraph with 27 vertices, 88 edges>
</pre></div>

<p><a id="X7F61140C822880DA" name="X7F61140C822880DA"></a></p>

<h5>3.5-30 LindgrenSousselierGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ LindgrenSousselierGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is an integer greater than 0, then this operation returns the <var class="Arg">n</var>th <em>Lindgren-Sousselier graph</em>, an infinite family of hyophamiltonian graphs - a graph that is non-Hamiltonian but removing any vector gives a Hamiltonian graph. The graph has <code class="code">6<var class="Arg">n</var>+4</code> vertices and <code class="code">15 + 10(<var class="Arg">n</var>-1)</code> undirected edges. The first Lindgren-Sousselier graph is the Petersen graph, and is in fact the smallest hyophamiltonian graph.</p>

<p>See <span class="URL"><a href="https://mathworld.wolfram.com/HypohamiltonianGraph.html">https://mathworld.wolfram.com/HypohamiltonianGraph.html</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := LindgrenSousselierGraph(3);</span>
<immutable symmetric digraph with 22 vertices, 70 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsHamiltonianDigraph(D);</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">IsHamiltonianDigraph(DigraphRemoveVertex(D, 1));</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIsomorphicDigraph(LindgrenSousselierGraph(1), PetersenGraph());</span>
true</pre></div>

<p><a id="X832E82CF87BF5D43" name="X832E82CF87BF5D43"></a></p>

<h5>3.5-31 LollipopGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ LollipopGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">m</var>, <var class="Arg">n</var)</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">m</var> and <var class="Arg">n</var> are positive integers, then this operation returns the <em>(<var class="Arg">m</var>,<var class="Arg">n</var>)-lollipop graph</em>. As defined at <span class="URL"><a href="https://en.wikipedia.org/wiki/Lollipop_graph">https://en.wikipedia.org/wiki/Lollipop_graph</a></span>, this consists of a complete digraph on the vertices <code class="code">[1..<var class="Arg">m</var>]</code> (the 'head' of the lollipop), and the symmetric closure of a chain digraph on the remaining <var class="Arg">n</var> vertices (the 'stick'), connected by a bridge (the edge <code class="code">[<var class="Arg">m</var>, <var class="Arg">m</var>+1]</code> and its reverse).</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := LollipopGraph(5, 3);</span>
<immutable connected symmetric digraph with 8 vertices, 26 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">CliqueNumber(D);</span>
5
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphUndirectedGirth(D);</span>
3
<span class="GAPprompt">gap></span> <span class="GAPinput">LollipopGraph(IsMutableDigraph, 3, 8);</span>
<mutable digraph with 11 vertices, 22 edges>
</pre></div>

<p><a id="X853613228110588E" name="X853613228110588E"></a></p>

<h5>3.5-32 MobiusLadderGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ MobiusLadderGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is a positive integer at least 4, then this operation returns the <em>Mobius ladder graph</em> that is obtained by introducing a 'twist' in the <var class="Arg">n</var>th prism graph, similar to the construction of a Mobius strip. The Mobius ladder graph is isomorphic to the circulant graph <code class="code">Ci(2<var class="Arg">n</var>, [1, <var class="Arg">n</var>])</code>. The Mobius ladders are cubic, symmetric, Hamiltonian, vertex-transitive, and graceful. They are also non-planar and apex, meaning removing a single vertex produces a planar graph.</p>

<p>See <span class="URL"><a href="https://mathworld.wolfram.com/MoebiusLadder.html">https://mathworld.wolfram.com/MoebiusLadder.html</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := MobiusLadderGraph(7);</span>
<immutable symmetric digraph with 14 vertices, 42 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsHamiltonianDigraph(D);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsVertexTransitive(D);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsPlanarDigraph(D);</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">D2 := DigraphRemoveVertex(D, 1);</span>
<immutable digraph with 13 vertices, 36 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsPlanarDigraph(D2);</span>
true</pre></div>

<p><a id="X825943547FD7A687" name="X825943547FD7A687"></a></p>

<h5>3.5-33 MycielskiGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ MycielskiGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is an integer greater than 1, then this operation returns the <var class="Arg">n</var>th <em>Mycielski graph</em>. The Mycielskian of a triangle-free graph is a construction that adds vertices and edges to produce a new graph that is still triangle-free but has a larger chromatic number. The Mycielski graphs are a series of graphs with this construction repeated, starting with the complete graph on two vertices. The graph has <code class="code">3 * 2^(<var class="Arg">n</var>-2) - 1</code> vertices, with the number of edges being <code class="code">(18 - 27 * 2 ^ <var class="Arg">n</var> + 14 * 3 ^ <var class="Arg">n</var>) / 36</code>.</p>

<p>The Mycielski graph has chromatic number equal to <var class="Arg">n</var>, clique number equal to <span class="SimpleMath">2</span>, and is Hamiltonian. The graph is in fact the graph with chromatic number <var class="Arg">n</var> with the least possible vertices.</p>

<p>See <span class="URL"><a href="https://mathworld.wolfram.com/MycielskiGraph.html">https://mathworld.wolfram.com/MycielskiGraph.html</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := MycielskiGraph(4);</span>
<immutable Hamiltonian symmetric digraph with 11 vertices, 40 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">ChromaticNumber(D);</span>
4
<span class="GAPprompt">gap></span> <span class="GAPinput">CliqueNumber(D);</span>
2</pre></div>

<p><a id="X7904BB2982014ADA" name="X7904BB2982014ADA"></a></p>

<h5>3.5-34 OddGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ OddGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is an integer greater than 0, then this operation returns the <var class="Arg">n</var>th <em>odd graph</em>. The odd graph has vertices labelled with the <code class="code"><var class="Arg">n</var>-1</code>-subsets of a <code class="code">2<var class="Arg">n</var>-1</code>-set, with two vertices adjacent if and only if their subsets are disjoint. The <var class="Arg">n</var>th odd graph is the <code class="code">(2<var class="Arg">n</var>-1, <var class="Arg">n</var>-1)</code>-th Kneser graph. The graph has <code class="code">Binomial(2<var class="Arg">n</var>-1, <var class="Arg">n</var>-1)</code> vertices and <code class="code"><var class="Arg">n</var> * Binomial(2<var class="Arg">n</var>-1, <var class="Arg">n</var>-1) / 2</code> edges.</p>

<p>The odd graph is regular and distance transitive (and therefore distance regular). They have chromatic number equal to 3, and all Odd graphs with <var class="Arg">n</var> greater than 3 are Hamiltonian. They are also vertex and edge transitive.</p>

<p>See <span class="URL"><a href="https://mathworld.wolfram.com/OddGraph.html">https://mathworld.wolfram.com/OddGraph.html</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := OddGraph(4);</span>
<immutable edge- and vertex-transitive symmetric digraph with 35 verti\
ces, 140 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIsomorphicDigraph(D, KneserGraph(7, 3));</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">ChromaticNumber(D);</span>
3</pre></div>

<p><a id="X815055168405B7F0" name="X815055168405B7F0"></a></p>

<h5>3.5-35 PathGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ PathGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is a non-negative integer then this operation returns the <var class="Arg">n</var>th <em>path graph</em>, consisting of the path on <var class="Arg">n</var> vertices. This is the symmetric closure of the <code class="func">ChainDigraph</code> (<a href="chap3.html#X870594FC866AC88E"><span class="RefLink">3.5-11</span></a>). The path graph has <var class="Arg">n</var> vertices and <code class="code"><var class="Arg">n</var>-1</code> edges. The path graph is an undirected tree.</p>

<p>See <span class="URL"><a href="https://mathworld.wolfram.com/PathGraph.html">https://mathworld.wolfram.com/PathGraph.html</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := PathGraph(12);</span>
<immutable undirected tree with 12 vertices></pre></div>

<p><a id="X7A38DFC47AAE4A96" name="X7A38DFC47AAE4A96"></a></p>

<h5>3.5-36 PermutationStarGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ PermutationStarGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var>, <var class="Arg">k</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is an integer at greater than 0 and <var class="Arg">k</var> is an integer greater than 1, and <var class="Arg">k</var> less than or equal to <var class="Arg">n</var>, then this operation returns the <code class="code">(<var class="Arg">n</var>, <var class="Arg">k</var>)</code>-th <em>permutation star graph</em>. The vertices of the graph are given by the <var class="Arg">k</var>-length ordered subsets of an <var class="Arg">n</var>-set, with two vertices being adjacent if one is labelled <code class="code">p1 p2 p3 ... pi ... p<var class="Arg">k</var></code>, and the other is either labelled <code class="code">pi p2 p3 ... p1 ... p<var class="Arg">k</var></code>, or labelled <code class="code">x p2 p3 ... pi ... p<var class="Arg">k</var></code> where <code class="code">x</code> is in <code class="code">[1..<var class="Arg">n</var>]</code> and is not equal to <code class="code">p1</code>. The graph has <code class="code"><var class="Arg">n</var>! / (<var class="Arg">n</var> - <var class="Arg">k</var>)!</code> vertices.</p>

<p>The permutation star graph is regular and vertex transitive. It has diameter <code class="code">2<var class="Arg">k</var> - 1</code> if <var class="Arg">k</var> less than or equal to <code class="code">Int(<var class="Arg">n</var> / 2)</code>, and diameter <code class="code">Int((<var class="Arg">n</var> - 1) / 2) + <var class="Arg">k</var></code> if <code class="code"><var class="Arg">k</var> >= Int(<var class="Arg">n</var> / 2) + 1</code>.</p>

<p>See <span class="URL"><a href="https://mathworld.wolfram.com/PermutationStarGraph.html">https://mathworld.wolfram.com/PermutationStarGraph.html</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := PermutationStarGraph(6, 2);</span>
<immutable vertex-transitive symmetric digraph with 30 vertices, 150 e\
dges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphDiameter(D);</span>
3</pre></div>

<p><a id="X823F43217A6C375D" name="X823F43217A6C375D"></a></p>

<h5>3.5-37 PetersenGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ PetersenGraph</code>( [<var class="Arg">filt</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>From <span class="URL"><a href="https://en.wikipedia.org/wiki/Petersen_graph">https://en.wikipedia.org/wiki/Petersen_graph</a></span>:</p>

<p><q>The Petersen graph is an undirected graph with 10 vertices and 15 edges. It is a small graph that serves as a useful example and counterexample for many problems in graph theory. The Petersen graph is named after Julius Petersen, who in 1898 constructed it to be the smallest bridgeless cubic graph with no three-edge-coloring.</q></p>

<p>See also <code class="func">GeneralisedPetersenGraph</code> (<a href="chap3.html#X7B5441F386BD105E"><span class="RefLink">3.5-38</span></a>).</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">ChromaticNumber(PetersenGraph());</span>
3
<span class="GAPprompt">gap></span> <span class="GAPinput">PetersenGraph(IsMutableDigraph);</span>
<mutable digraph with 10 vertices, 30 edges>
</pre></div>

<p><a id="X7B5441F386BD105E" name="X7B5441F386BD105E"></a></p>

<h5>3.5-38 GeneralisedPetersenGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ GeneralisedPetersenGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var>, <var class="Arg">k</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is a positive integer and <var class="Arg">k</var> is a non-negative integer less than <code class="code"><var class="Arg">n</var> / 2</code>, then this operation returns the <em>generalised Petersen graph</em> <span class="SimpleMath">GPG(<var class="Arg">n</var>, k)</span>.</p>

<p>From <span class="URL"><a href="https://en.wikipedia.org/wiki/Generalized_Petersen_graph">https://en.wikipedia.org/wiki/Generalized_Petersen_graph</a></span>:</p>

<p><q>The generalized Petersen graphs are a family of cubic graphs formed by connecting the vertices of a regular polygon to the corresponding vertices of a star polygon. They include the Petersen graph and generalize one of the ways of constructing the Petersen graph. The generalized Petersen graph family was introduced in 1950 by H. S. M. Coxeter and was given its name in 1969 by Mark Watkins.</q></p>

<p>See also <code class="func">PetersenGraph</code> (<a href="chap3.html#X823F43217A6C375D"><span class="RefLink">3.5-37</span></a>).</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">GeneralisedPetersenGraph(7, 2);</span>
<immutable symmetric digraph with 14 vertices, 42 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">GeneralisedPetersenGraph(40, 1);</span>
<immutable symmetric digraph with 80 vertices, 240 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := GeneralisedPetersenGraph(5, 2);</span>
<immutable symmetric digraph with 10 vertices, 30 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIsomorphicDigraph(D, PetersenGraph());</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">GeneralisedPetersenGraph(IsMutableDigraph, 9, 4);</span>
<mutable digraph with 18 vertices, 54 edges>
</pre></div>

<p><a id="X85425DC5847E6D20" name="X85425DC5847E6D20"></a></p>

<h5>3.5-39 PrismGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ PrismGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is a positive integer at least 3, then this operation returns the <em>prism graph</em> that is the skeleton of the <var class="Arg">n</var>-prism. It has <code class="code">2<var class="Arg">n</var></code> vertices and <code class="code">3<var class="Arg">n</var></code> undirected edges. The prism graph is a symmetric digraph. The <var class="Arg">n</var>th prism graph is isomorphic to the graph Cartesian product of the second path graph and the <var class="Arg">n</var>th cycle graph, isomorphic to the generalised Petersen graph <code class="code">GP(<var class="Arg">n</var>,1)</code>. If <var class="Arg">n</var> is odd then the prism graph is isomorphic to the Circulant graph <code class="code">Ci(2<var class="Arg">n</var>, [2,<var class="Arg">n</var>])</code>. The prism graph is Hamiltonian.</p>

<p>See <span class="URL"><a href="https://mathworld.wolfram.com/PrismGraph.html">https://mathworld.wolfram.com/PrismGraph.html</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := PrismGraph(4);</span>
<immutable symmetric digraph with 8 vertices, 24 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsHamiltonianDigraph(D);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">D := PrismGraph(5);</span>
<immutable symmetric digraph with 10 vertices, 30 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIsomorphicDigraph(D, CirculantGraph(10, [2, 5]));</span>
true</pre></div>

<p><a id="X817982877B48D5BD" name="X817982877B48D5BD"></a></p>

<h5>3.5-40 StackedPrismGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ StackedPrismGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var>, <var class="Arg">k</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is an integer at least 3 and <var class="Arg">k</var> is a positive integer then this operation returns the <code class="code">(<var class="Arg">n</var>,<var class="Arg">k</var>)</code>-th <em>stacked prism graph</em>. The graph is <var class="Arg">k</var> concentric <var class="Arg">n</var>-Cycle graphs connected by spokes. The stacked prism is the graph Cartesian product of the <var class="Arg">n</var>th cycle graph and the <var class="Arg">k</var>th path graph. The graph has <code class="code"><var class="Arg">n</var><var class="Arg">k</var></code> vertices and <code class="code"><var class="Arg">n</var>(2<var class="Arg">k</var> - 1)</code> undirected edges. If <var class="Arg">k</var> is 1 then the graph is the <var class="Arg">n</var>th cycle graph, if <var class="Arg">k</var> is 2 then the graph is the prism graph.</p>

<p>See <span class="URL"><a href="https://mathworld.wolfram.com/StackedPrismGraph.html">https://mathworld.wolfram.com/StackedPrismGraph.html</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := StackedPrismGraph(5, 2);</span>
<immutable symmetric digraph with 10 vertices, 30 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsIsomorphicDigraph(D, PrismGraph(5));</span>
true</pre></div>

<p><a id="X785C3F1F7D690151" name="X785C3F1F7D690151"></a></p>

<h5>3.5-41 QueensGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ QueensGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">m</var>, <var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ QueenGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">m</var>, <var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">m</var> and <var class="Arg">n</var> are positive integers, then this operation returns the <em>queen's graph</em> of an <var class="Arg">m</var> by <var class="Arg">n</var> chessboard, as a symmetric digraph.</p>

<p>The queen's graph represents all possible moves of the queen chess piece across a chessboard. An <var class="Arg">m</var> by <var class="Arg">n</var> chessboard is a grid of <var class="Arg">m</var> columns ("files") and <var class="Arg">n</var> rows ("ranks") that intersect in squares. Orthogonally adjacent squares are alternately colored light and dark, with the square in the first rank and file being dark.</p>

<p>The <code class="code"><var class="Arg">m</var> * <var class="Arg">n</var></code> vertices of the queen's graph can be placed onto the <code class="code"><var class="Arg">m</var> * <var class="Arg">n</var></code> squares of an <var class="Arg">m</var> by <var class="Arg">n</var> chessboard, such that two vertices are adjacent in the digraph if and only if the queen can move between the corresponding squares in a single turn. A legal queen's move is defined as one which moves the queen to an (orthogonally or diagonally) adjacent square, or to a square which can be reached through a series of such moves, with all of the small moves being in the same direction.</p>

<p>Note that the <code class="func">QueensGraph</code> is the <code class="func">DigraphEdgeUnion</code> (<a href="chap3.html#X7DA997697D310E44"><span class="RefLink">3.3-30</span></a>) of the <code class="func">RooksGraph</code> (<a href="chap3.html#X7A6DD11881874F51"><span class="RefLink">3.5-42</span></a>) and the <code class="func">BishopsGraph</code> (<a href="chap3.html#X7E3240047C92733F"><span class="RefLink">3.5-5</span></a>) of the same dimensions.</p>

<p>The chosen correspondence between vertices and chess squares is given by <code class="func">DigraphVertexLabels</code> (<a href="chap5.html#X7E51F2FE87140B32"><span class="RefLink">5.1-12</span></a>). In more detail, the vertices of the digraph are labelled by elements of the Cartesian product <code class="code">[1..<var class="Arg">m</var>] x [1..<var class="Arg">n</var>]</code>, where the first entry indexes the column (file) of the square in the chessboard, and the second entry indexes the row (rank) of the square. (Note that the files are traditionally indexed by the lowercase letters of the alphabet). The vertices are sorted in ascending order, first by row (second component) and then column (first component). If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">QueensGraph(2, 5);</span>
<immutable connected symmetric digraph with 10 vertices, 66 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := QueensGraph(4, 3);</span>
<immutable connected symmetric digraph with 12 vertices, 92 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsRegularDigraph(D);</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">QueensGraph(6, 9) =</span>
<span class="GAPprompt">></span> <span class="GAPinput">   DigraphEdgeUnion(RooksGraph(6, 9), BishopsGraph(6, 9));</span>
true
</pre></div>

<p><a id="X7A6DD11881874F51" name="X7A6DD11881874F51"></a></p>

<h5>3.5-42 RooksGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ RooksGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">m</var>, <var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ RookGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">m</var>, <var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">m</var> and <var class="Arg">n</var> are positive integers, then this operation returns the <em>rook's graph</em> of an <var class="Arg">m</var> by <var class="Arg">n</var> chessboard, as a symmetric digraph.</p>

<p>A rook's graph represents all possible moves of the rook chess piece across a chessboard. An <var class="Arg">m</var> by <var class="Arg">n</var> chessboard is a grid of <var class="Arg">m</var> columns ("files") and <var class="Arg">n</var> rows ("ranks") that intersect in squares. Orthogonally adjacent squares are alternately colored light and dark, with the square in the first rank and file being dark.</p>

<p>The <code class="code"><var class="Arg">m</var> * <var class="Arg">n</var></code> vertices of the rook's graph can be placed onto the <code class="code"><var class="Arg">m</var> * <var class="Arg">n</var></code> squares of an <var class="Arg">m</var> by <var class="Arg">n</var> chessboard, such that two vertices are adjacent in the digraph if and only if a rook can move between the corresponding squares in a single turn. A legal rook's move is defined as one which moves the rook to an orthogonally adjacent square, or to a square which can be reached through a series of such moves, with all of the small moves being in the same direction.</p>

<p>The chosen correspondence between vertices and chess squares is given by <code class="func">DigraphVertexLabels</code> (<a href="chap5.html#X7E51F2FE87140B32"><span class="RefLink">5.1-12</span></a>). In more detail, the vertices of the digraph are labelled by elements of the Cartesian product <code class="code">[1..<var class="Arg">m</var>] x [1..<var class="Arg">n</var>]</code>, where the first entry indexes the column (file) of the square in the chessboard, and the second entry indexes the row (rank) of the square. (Note that the files are traditionally indexed by the lowercase letters of the alphabet). The vertices are sorted in ascending order, first by row (second component) and then column (first component). See <span class="URL"><a href="https://en.wikipedia.org/wiki/Rook's_graph">Wikipedia</a></span> for further information. See also <code class="func">DigraphCartesianProduct</code> (<a href="chap3.html#X7D625CC87DBFFDED"><span class="RefLink">3.3-32</span></a>) and <code class="func">LineDigraph</code> (<a href="chap3.html#X8595BF937B749F22"><span class="RefLink">3.3-41</span></a>).</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := RooksGraph(7, 4);</span>
<immutable connected regular symmetric digraph with 28 vertices, 252 e\
dges>
<span class="GAPprompt">gap></span> <span class="GAPinput">RooksGraph(1, 8);</span>
<immutable connected regular symmetric digraph with 8 vertices, 56 edg\
es>
</pre></div>

<p><a id="X8404987F849D7CF2" name="X8404987F849D7CF2"></a></p>

<h5>3.5-43 SquareGridGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ SquareGridGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var>, <var class="Arg">k</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ GridGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var>, <var class="Arg">k</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> and <var class="Arg">k</var> are positive integers, then this operation returns a square grid graph of dimension <var class="Arg">n</var> by <var class="Arg">k</var>.</p>

<p>A <em>square grid graph</em> of dimension <var class="Arg">n</var> by <var class="Arg">k</var> is the <code class="func">DigraphCartesianProduct</code> (<a href="chap3.html#X7D625CC87DBFFDED"><span class="RefLink">3.3-32</span></a>) of the symmetric closures of the chain digraphs with <var class="Arg">n</var> and <var class="Arg">k</var> vertices; see <code class="func">DigraphSymmetricClosure</code> (<a href="chap3.html#X874883DD7DD450C4"><span class="RefLink">3.3-12</span></a>) and <code class="func">ChainDigraph</code> (<a href="chap3.html#X870594FC866AC88E"><span class="RefLink">3.5-11</span></a>).</p>

<p>In particular, the <code class="code"><var class="Arg">n</var> * <var class="Arg">k</var></code> vertices can be arranged into an <var class="Arg">n</var> by <var class="Arg">k</var> grid such that two vertices are adjacent in the digraph if and only if they are orthogonally adjacent in the grid. The correspondence between vertices and grid positions is given by <code class="func">DigraphVertexLabels</code> (<a href="chap5.html#X7E51F2FE87140B32"><span class="RefLink">5.1-12</span></a>).</p>

<p>See <span class="URL"><a href="https://en.wikipedia.org/wiki/Lattice_graph">https://en.wikipedia.org/wiki/Lattice_graph</a></span> for more information.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">SquareGridGraph(5, 5);</span>
<immutable planar connected bipartite symmetric digraph with bicompone\
nt sizes 13 and 12>
<span class="GAPprompt">gap></span> <span class="GAPinput">GridGraph(IsMutable, 3, 4);</span>
<mutable digraph with 12 vertices, 34 edges>
</pre></div>

<p><a id="X8234361278E8816F" name="X8234361278E8816F"></a></p>

<h5>3.5-44 TriangularGridGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ TriangularGridGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var>, <var class="Arg">k</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> and <var class="Arg">k</var> are positive integers, then this operation returns a triangular grid graph of dimension <var class="Arg">n</var> by <var class="Arg">k</var>.</p>

<p>A <em>triangular grid graph</em> of dimension <var class="Arg">n</var> by <var class="Arg">k</var> is a symmetric digraph constructed from the <code class="func">SquareGridGraph</code> (<a href="chap3.html#X8404987F849D7CF2"><span class="RefLink">3.5-43</span></a>) of the same dimensions, where additionally two vertices are adjacent in the digraph if they are diagonally adjacent in the grid, on a particular one of the diagonals. The correspondence between vertices and grid positions is given by <code class="func">DigraphVertexLabels</code> (<a href="chap5.html#X7E51F2FE87140B32"><span class="RefLink">5.1-12</span></a>). More specifically, the particular diagonal is the one such that, the vertices corresponding to the grid positions <code class="code">[2,1]</code> and <code class="code">[1,2]</code> are adjacent (if they exist), but those corresponding to <code class="code">[1,1]</code> and <code class="code">[2,2]</code> are not.</p>

<p>See <span class="URL"><a href="https://en.wikipedia.org/wiki/Lattice_graph#Other_kinds">https://en.wikipedia.org/wiki/Lattice_graph#Other_kinds</a></span> for more information.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">TriangularGridGraph(3, 3);</span>
<immutable planar connected symmetric digraph with 9 vertices, 32 edge\
s>
<span class="GAPprompt">gap></span> <span class="GAPinput">TriangularGridGraph(IsMutable, 3, 3);</span>
<mutable digraph with 9 vertices, 32 edges>
</pre></div>

<p><a id="X78F78C077CBAE1EC" name="X78F78C077CBAE1EC"></a></p>

<h5>3.5-45 StarGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ StarGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">k</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">k</var> is a positive integer, then this operation returns the <em>star graph</em> with <var class="Arg">k</var> vertices, which is the undirected tree in which vertex <code class="code">1</code> is adjacent to all other vertices. If <var class="Arg">k</var> is at least <code class="code">2</code>, then this is the complete bipartite digraph with bicomponents <code class="code">[1]</code> and <code class="code">[2 .. <var class="Arg">k</var>]</code>.</p>

<p>See <code class="func">IsUndirectedTree</code> (<a href="chap6.html#X80FC20FA7AC4BC2A"><span class="RefLink">6.6-9</span></a>), <code class="func">IsCompleteBipartiteDigraph</code> (<a href="chap6.html#X790A4DBF8533516E"><span class="RefLink">6.2-4</span></a>), and <code class="func">DigraphBicomponents</code> (<a href="chap5.html#X7F1B5A2782F598B1"><span class="RefLink">5.4-13</span></a>).</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">StarGraph(IsMutable, 10);</span>
<mutable digraph with 10 vertices, 18 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">StarGraph(5);</span>
<immutable complete bipartite digraph with bicomponent sizes 1 and 4>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsSymmetricDigraph(StarGraph(3));</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsUndirectedTree(StarGraph(3));</span>
true
</pre></div>

<p><a id="X81D59C4D809F4AD3" name="X81D59C4D809F4AD3"></a></p>

<h5>3.5-46 TadpoleGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ TadpoleGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">m</var>, <var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>The <em>tadpole graph</em> is the symmetric closure of the disjoint union of the cycle digraph on <code class="code">[1..<var class="Arg">m</var>]</code> (the 'head' of the tadpole) and the chain digraph on <code class="code">[<var class="Arg">m</var>+1..<var class="Arg">m</var>+<var class="Arg">n</var>]</code> (the 'tail' of the tadpole), along with the additional edges <code class="code">[1, <var class="Arg">m</var>+1]</code> and <code class="code">[1, <var class="Arg">m</var>+1]</code> which connect the 'head' and the 'tail'. For more details on the tadpole graph please refer to <span class="URL"><a href="https://en.wikipedia.org/wiki/Tadpole_graph">https://en.wikipedia.org/wiki/Tadpole_graph</a></span>.</p>

<p>See <code class="func">DigraphSymmetricClosure</code> (<a href="chap3.html#X874883DD7DD450C4"><span class="RefLink">3.3-12</span></a>), <code class="func">DigraphDisjointUnion</code> (<a href="chap3.html#X814F1DFC83DB273F"><span class="RefLink">3.3-29</span></a>), <code class="func">CycleDigraph</code> (<a href="chap3.html#X80C29DDE876FFBEB"><span class="RefLink">3.5-16</span></a>), and <code class="func">ChainDigraph</code> (<a href="chap3.html#X870594FC866AC88E"><span class="RefLink">3.5-11</span></a>).</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">TadpoleGraph(10, 15);</span>
<immutable symmetric digraph with 25 vertices, 50 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">TadpoleGraph(IsMutableDigraph, 5, 6);</span>
<mutable digraph with 11 vertices, 22 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsSymmetricDigraph(TadpoleGraph(3, 5));</span>
true
</pre></div>

<p><a id="X7BFA33067F83F8B0" name="X7BFA33067F83F8B0"></a></p>

<h5>3.5-47 WalshHadamardGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ WalshHadamardGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is a positive integer at least 1, then this operation returns the <em>Hadamard graph</em> constructed from the <var class="Arg">n</var>th Hadamard matrix (of dimension <code class="code">2^<var class="Arg">n</var></code>) as constructed by Joseph Walsh. A Hadamard matrix is a square matrix with entries either <span class="SimpleMath">1</span> or <span class="SimpleMath">-1</span>, such that all the rows are mutually orthogonal. The <var class="Arg">n</var>th Walsh Hadamard graph is a graph on <code class="code">4<var class="Arg">n</var></code> matrices split into four categories <span class="SimpleMath">r_i+, r_i-, c_i+, c_i-</span>. If <span class="SimpleMath">h_ij</span> are the elements of the <var class="Arg">n</var>th Walsh matrix, then if <span class="SimpleMath">h_ij = 1</span> then <span class="SimpleMath">(r_i+, c_j+)</span> and <span class="SimpleMath">(r_i-, c_j-)</span> are edges, if <span class="SimpleMath">h_ij = -1</span> then <span class="SimpleMath">(r_i+, c_j-)</span> and <span class="SimpleMath">(r_i-, c_j+)</span> are edges. Walsh Hadamard graphs are distance transitive and distance regular.</p>

<p>See <span class="URL"><a href="https://mathworld.wolfram.com/HadamardGraph.html">https://mathworld.wolfram.com/HadamardGraph.html</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := WalshHadamardGraph(5);</span>
<immutable symmetric digraph with 64 vertices, 1024 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsDistanceRegularDigraph(D);</span>
true</pre></div>

<p><a id="X84F3B70A82EEE780" name="X84F3B70A82EEE780"></a></p>

<h5>3.5-48 WebGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ WebGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is an integer at least 3 then this operation returns the <var class="Arg">n</var>th <em>web graph</em>. The web graph is the <code class="code">(<var class="Arg">n</var>,3)</code>-th stacked prism graph with the edges of the outer cycle removed. The graph has <code class="code">3<var class="Arg">n</var></code> vertices and <code class="code">4<var class="Arg">n</var></code> undirected edges.</p>

<p>See <span class="URL"><a href="https://mathworld.wolfram.com/WebGraph.html">https://mathworld.wolfram.com/WebGraph.html</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := WebGraph(5);</span>
<immutable symmetric digraph with 15 vertices, 40 edges></pre></div>

<p><a id="X817EA60D828A765E" name="X817EA60D828A765E"></a></p>

<h5>3.5-49 WheelGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ WheelGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> is a positive integer at least 4, then this operation returns the <var class="Arg">n</var>th <em>wheel graph</em>. The Wheel graph is formed from an <code class="code"><var class="Arg">n</var>-1</code> cycle graph with a single additional vertex adjacent to all vertices of the cycle. The graph has <var class="Arg">n</var> vertices and <code class="code">2(<var class="Arg">n</var>-1)</code> edges. Wheel graphs are the skeletons of <code class="code"><var class="Arg">n</var>-1</code> pyramids, and are self-dual. If <var class="Arg">n</var> is odd, then the chromatic number of the wheel graph is 3 and the Wheel graph is perfect, and it is 4 otherwise. The wheel graph is also Hamiltonian and planar.</p>

<p>See <span class="URL"><a href="https://mathworld.wolfram.com/WheelGraph.html">https://mathworld.wolfram.com/WheelGraph.html</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := WheelGraph(8);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">ChromaticNumber(D);</span>
4
<span class="GAPprompt">gap></span> <span class="GAPinput">IsHamiltonianDigraph(D);</span>
true</pre></div>

<p><a id="X7BE44CA27AA5F8DB" name="X7BE44CA27AA5F8DB"></a></p>

<h5>3.5-50 WindmillGraph</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ WindmillGraph</code>( [<var class="Arg">filt</var>, ]<var class="Arg">n</var>, <var class="Arg">m</var)</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>

<p>If <var class="Arg">n</var> and <var class="Arg">m</var> are integers greater than 1 then this operation returns the <code class="code">(<var class="Arg">n</var>, <var class="Arg">m</var>)</code>-th <em>windmill graph</em>. The windmill graph is formed from <var class="Arg">m</var> copies of the complete graph on <var class="Arg">n</var> vertices with one shared vertex. The graph has <code class="code"><var class="Arg">m</var>(<var class="Arg">n</var> - 1) + 1</code> vertices and <code class="code"><var class="Arg">m</var> * <var class="Arg">n</var> * (<var class="Arg">n</var> - 1) / 2</code> undirected edges. The windmill graph has chromatic number <var class="Arg">n</var> and diameter 2.</p>

<p>See <span class="URL"><a href="https://mathworld.wolfram.com/WindmillGraph.html">https://mathworld.wolfram.com/WindmillGraph.html</a></span> for further details.</p>

<p>If the optional first argument <var class="Arg">filt</var> is present, then this should specify the category or representation the digraph being created will belong to. For example, if <var class="Arg">filt</var> is <code class="func">IsMutableDigraph</code> (<a href="chap3.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>), then the digraph being created will be mutable, if <var class="Arg">filt</var> is <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), then the digraph will be immutable. If the optional first argument <var class="Arg">filt</var> is not present, then <code class="func">IsImmutableDigraph</code> (<a href="chap3.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>) is used by default.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := WindmillGraph(4, 3);</span>
<immutable symmetric digraph with 10 vertices, 36 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">ChromaticNumber(D);</span>
4</pre></div>


<div class="chlinkprevnextbot"> <a href="chap0.html">[Top of Book]</a>   <a href="chap0.html#contents">[Contents]</a>    <a href="chap2.html">[Previous Chapter]</a>    <a href="chap4.html">[Next Chapter]</a>   </div>


<div class="chlinkbot"><span class="chlink1">Goto Chapter: </span><a href="chap0.html">Top</a>  <a href="chap1.html">1</a>  <a href="chap2.html">2</a>  <a href="chap3.html">3</a>  <a href="chap4.html">4</a>  <a href="chap5.html">5</a>  <a href="chap6.html">6</a>  <a href="chap7.html">7</a>  <a href="chap8.html">8</a>  <a href="chap9.html">9</a>  <a href="chapA.html">A</a>  <a href="chapB.html">B</a>  <a href="chapBib.html">Bib</a>  <a href="chapInd.html">Ind</a>  </div>

<hr />
<p class="foot">generated by <a href="https://www.math.rwth-aachen.de/~Frank.Luebeck/GAPDoc">GAPDoc2HTML</a></p>
</body>
</html>

Messung V0.5 in Prozent
C=100 H=100 G=100

¤ Dauer der Verarbeitung: 0.180 Sekunden  (vorverarbeitet am  2026-04-29) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.