SSL chap9_mj.html
Sprache: HTML
|
|
| products/sources/formale Sprachen/GAP/pkg/digraphs/doc/chap9_mj.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>
<script type="text/javascript"
src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<title>GAP (Digraphs) - Chapter 9: Visualising and IO</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="chap9" onload="jscontent()">
<div class="chlinktop"><span class="chlink1">Goto Chapter: </span><a href="chap0_mj.html">Top</a> <a href="chap1_mj.html">1</a> <a href="chap2_mj.html">2</a> <a href="chap3_mj.html">3</a> <a href="chap4_mj.html">4</a> <a href="chap5_mj.html">5</a> <a href="chap6_mj.html">6</a> <a href="chap7_mj.html">7</a> <a href="chap8_mj.html">8</a> <a href="chap9_mj.html">9</a> <a href="chapA_mj.html">A</a> <a href="chapB_mj.html">B</a> <a href="chapBib_mj.html">Bib</a> <a href="chapInd_mj.html">Ind</a> </div>
<div class="chlinkprevnexttop"> <a href="chap0_mj.html">[Top of Book]</a> <a href="chap0_mj.html#contents">[Contents]</a> <a href="chap8_mj.html">[Previous Chapter]</a> <a href="chapA_mj.html">[Next Chapter]</a> </div>
<p id="mathjaxlink" class="pcenter"><a href="chap9.html">[MathJax off]</a></p>
<p><a id="X81714DBC80CC4BCB" name="X81714DBC80CC4BCB"></a></p>
<div class="ChapSects"><a href="chap9_mj.html#X81714DBC80CC4BCB">9 <span class="Heading">Visualising and IO</span></a>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap9_mj.html#X7CF67F8278D9469C">9.1 <span class="Heading">Visualising a digraph</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap9_mj.html#X83B3318784E78415">9.1-1 Splash</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap9_mj.html#X7F9B99C478EE093A">9.1-2 DotDigraph</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap9_mj.html#X78DA31D1869D2F94">9.1-3 DotSymmetricDigraph</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap9_mj.html#X84120D447E2CAC23">9.1-4 DotPartialOrderDigraph</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap9_mj.html#X7F5653C8854FAEA6">9.1-5 DotPreorderDigraph</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap9_mj.html#X808D12CF81E2C19F">9.1-6 DotHighlightedDigraph</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap9_mj.html#X81C9B1DC791C0BBD">9.2 <span class="Heading">Reading and writing digraphs to a file</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap9_mj.html#X81FB5BE27903EC32">9.2-1 String</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap9_mj.html#X873D6EB8836A3C61">9.2-2 DigraphFromGraph6String</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap9_mj.html#X782A052979EA2376">9.2-3 Graph6String</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap9_mj.html#X87DD8B1E867760A5">9.2-4 DigraphFromDreadnautString</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap9_mj.html#X7923733D86767CE1">9.2-5 DIMACSString</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap9_mj.html#X7845ACDA7D4D333D">9.2-6 DigraphFile</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap9_mj.html#X7E8142007ED0CB9F">9.2-7 ReadDigraphs</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap9_mj.html#X82A4F0767C9EFC87">9.2-8 WriteDigraphs</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap9_mj.html#X86D531B287733561">9.2-9 IteratorFromDigraphFile</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap9_mj.html#X7AAA35867B5D8BF4">9.2-10 DigraphPlainTextLineEncoder</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap9_mj.html#X7808D99079295C22">9.2-11 TournamentLineDecoder</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap9_mj.html#X7DF22D1687D096D6">9.2-12 AdjacencyMatrixUpperTriangleLineDecoder</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap9_mj.html#X875393338486D77D">9.2-13 TCodeDecoder</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap9_mj.html#X8540FC21796A793F">9.2-14 PlainTextString</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap9_mj.html#X81BD23697857B244">9.2-15 WritePlainTextDigraph</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap9_mj.html#X804FDF6A7ED64049">9.2-16 WriteDIMACSDigraph</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap9_mj.html#X7BC595AF841B78A9">9.2-17 WholeFileEncoders</a></span>
</div></div>
</div>
<h3>9 <span class="Heading">Visualising and IO</span></h3>
<p><a id="X7CF67F8278D9469C" name="X7CF67F8278D9469C"></a></p>
<h4>9.1 <span class="Heading">Visualising a digraph</span></h4>
<p><a id="X83B3318784E78415" name="X83B3318784E78415"></a></p>
<h5>9.1-1 Splash</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Splash</code>( <var class="Arg">str</var>[, <var class="Arg">opts</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: Nothing.</p>
<p>This function attempts to convert the string <var class="Arg">str</var> into a pdf document and open this document, i.e. to splash it all over your monitor.</p>
<p>The string <var class="Arg">str</var> must correspond to a valid <code class="code">dot</code> or <code class="code">LaTeX</code> text file and you must have have <code class="code">GraphViz</code> and <code class="code">pdflatex</code> installed on your computer. For details about these file formats, see <span class="URL"><a href="https://www.latex-project.org">https://www.latex-project.org</a></span> and <span class="URL"><a href="https://www.graphviz.org">https://www.graphviz.org</a></span>.</p>
<p>This function is provided to allow convenient, immediate viewing of the pictures produced by the function <code class="func">DotDigraph</code> (<a href="chap9_mj.html#X7F9B99C478EE093A"><span class="RefLink">9.1-2</span></a>).</p>
<p>The optional second argument <var class="Arg">opts</var> should be a record with components corresponding to various options, given below.</p>
<dl>
<dt><strong class="Mark">path</strong></dt>
<dd><p>this should be a string representing the path to the directory where you want <code class="code">Splash</code> to do its work. The default value of this option is <code class="code">"~/"</code>.</p>
</dd>
<dt><strong class="Mark">directory</strong></dt>
<dd><p>this should be a string representing the name of the directory in <code class="code">path</code> where you want <code class="code">Splash</code> to do its work. This function will create this directory if does not already exist.</p>
<p>The default value of this option is <code class="code">"tmp.viz"</code> if the option <code class="code">path</code> is present, and the result of <code class="func">DirectoryTemporary</code> (<a href="/home/runner/gap/doc/ref/chap9_mj.html#X8222B1A886E6195E"><span class="RefLink">Reference: DirectoryTemporary</span></a>) is used otherwise.</p>
</dd>
<dt><strong class="Mark">filename</strong></dt>
<dd><p>this should be a string representing the name of the file where <var class="Arg">str</var> will be written. The default value of this option is <code class="code">"vizpicture"</code>.</p>
</dd>
<dt><strong class="Mark">viewer</strong></dt>
<dd><p>this should be a string representing the name of the program which should open the files produced by <code class="code">GraphViz</code> or <code class="code">pdflatex</code>.</p>
</dd>
<dt><strong class="Mark">type</strong></dt>
<dd><p>this option can be used to specify that the string <var class="Arg">str</var> contains a LaTeX or <code class="code">dot</code> document. You can specify this option in <var class="Arg">str</var> directly by making the first line <code class="code">"%latex"</code> or <code class="code">"//dot"</code>. There is no default value for this option, this option must be specified in <var class="Arg">str</var> or in <var class="Arg">opt.type</var>.</p>
</dd>
<dt><strong class="Mark">engine</strong></dt>
<dd><p>this option can be used to specify the GraphViz engine to use to render a <code class="code">dot</code> document. The valid choices are <code class="code">"dot"</code>, <code class="code">"neato"</code>, <code class="code">"circo"</code>, <code class="code">"twopi"</code>, <code class="code">"fdp"</code>, <code class="code">"sfdp"</code>, and <code class="code">"patchwork"</code>. Please refer to the GraphViz documentation for details on these engines. The default value for this option is <code class="code">"dot"</code>, and it must be specified in <var class="Arg">opt.engine</var>.</p>
</dd>
<dt><strong class="Mark">filetype</strong></dt>
<dd><p>this should be a string representing the type of file which <code class="code">Splash</code> should produce. For LaTeX files, this option is ignored and the default value <code class="code">"pdf"</code> is used.</p>
</dd>
</dl>
<p>This function was written by Attila Egri-Nagy and Manuel Delgado with some minor changes by J. D. Mitchell.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">Splash(DotDigraph(RandomDigraph(4)));</span>
</pre></div>
<p><a id="X7F9B99C478EE093A" name="X7F9B99C478EE093A"></a></p>
<h5>9.1-2 DotDigraph</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DotDigraph</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">‣ DotColoredDigraph</code>( <var class="Arg">digraph</var>, <var class="Arg">vert</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">‣ DotVertexLabelledDigraph</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">‣ DotVertexColoredDigraph</code>( <var class="Arg">digraph</var>, <var class="Arg">vert</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">‣ DotEdgeColoredDigraph</code>( <var class="Arg">digraph</var>, <var class="Arg">edge</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A string.</p>
<p><code class="code">DotDigraph</code> produces a graphical representation of the digraph <var class="Arg">digraph</var>. Vertices are displayed as circles, numbered consistently with <var class="Arg">digraph</var>. Edges are displayed as arrowed lines between vertices, with the arrowhead of each line pointing towards the range of the edge.</p>
<p><code class="code">DotColoredDigraph</code> differs from <code class="code">DotDigraph</code> only in that the values in given in the two lists are used to color the vertices and edges of the graph when displayed. The list for vertex colours should be a list of length equal to the number of vertices, containing strings that are accepted by the graphviz software, which is the one used for graph representation. The list for edge colours should be a list of lists with the same shape of the outneighbours of the digraph that contains strings that correspond to colours accepted by the graphviz software. If the lists are not the appropriate size, or have holes then the function will return an error.</p>
<p><code class="code">DotVertexColoredDigraph</code> differs from <code class="code">DotDigraph</code> only in that the values in given in the list are used to color the vertices of the graph when displayed. The list for vertex colours should be a list of length equal to the number of vertices, containing strings that are accepted by the graphviz software, which is the one used for graph representation. If the list is not the appropriate size, or has holes then the function will return an error.</p>
<p><code class="code">DotEdgeColoredDigraph</code> differs from <code class="code">DotDigraph</code> only in that the values in given in the list are used to color the vertices and edges of the graph when displayed. The list for edge colours should be a list of lists with the same shape of the outneighbours of the digraph that contains strings that correspond to colours accepted by the graphviz software. If the list is not the appropriate size, or has holes then the function will return an error.</p>
<p><code class="code">DotVertexLabelledDigraph</code> differs from <code class="code">DotDigraph</code> only in that the values in <code class="func">DigraphVertexLabels</code> (<a href="chap5_mj.html#X7E51F2FE87140B32"><span class="RefLink">5.1-12</span></a>) are used to label the vertices in the produced picture rather than the numbers <code class="code">1</code> to the number of vertices of the digraph.</p>
<p>The output is in <code class="code">dot</code> format (also known as <code class="code">GraphViz</code>) format. For details about this file format, and information about how to display or edit this format see <span class="URL"><a href="https://www.graphviz.org">https://www.graphviz.org</a></span>.</p>
<p>The string returned by <code class="code">DotDigraph</code> or <code class="code">DotVertexLabelledDigraph</code> can be written to a file using the command <code class="func">FileString</code> (<a href="/home/runner/gap/pkg/gapdoc/doc/chap6_mj.html#X7E14D32181FBC3C3"><span class="RefLink">GAPDoc: FileString</span></a>).</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">adj := List([1 .. 4], x -> [1, 1, 1, 1]);</span>
[ [ 1, 1, 1, 1 ], [ 1, 1, 1, 1 ], [ 1, 1, 1, 1 ], [ 1, 1, 1, 1 ] ]
<span class="GAPprompt">gap></span> <span class="GAPinput">adj[1][3] := 0;</span>
0
<span class="GAPprompt">gap></span> <span class="GAPinput">gr := DigraphByAdjacencyMatrix(adj);</span>
<immutable digraph with 4 vertices, 15 edges>
<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">vertcolors := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors[1] := "blue";; vertcolors[2] := "red";; </span>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors[3] := "green";; vertcolors[4] := "yellow";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[1] := [];; edgecolors[2] := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[3] := [];; edgecolors[4] := [];; </span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[1][2] := "lightblue";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[1][3] := "pink";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[1][4] := "purple";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[2][1] := "lightblue";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[2][3] := "pink";; </span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[2][4] := "purple";; </span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[3][1] := "lightblue";; </span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[3][2] := "pink";; </span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[3][4] := "purple";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[4][1] := "lightblue";; </span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[4][2] := "pink";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[4][3] := "purple";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">Print(DotColoredDigraph(D, vertcolors, edgecolors));</span>
//dot
digraph hgn{
node [shape=circle]
1[color=blue, style=filled]
2[color=red, style=filled]
3[color=green, style=filled]
4[color=yellow, style=filled]
1 -> 2[color=lightblue]
1 -> 3[color=pink]
1 -> 4[color=purple]
2 -> 1[color=lightblue]
2 -> 3[color=pink]
2 -> 4[color=purple]
3 -> 1[color=lightblue]
3 -> 2[color=pink]
3 -> 4[color=purple]
4 -> 1[color=lightblue]
4 -> 2[color=pink]
4 -> 3[color=purple]
}
<span class="GAPprompt">gap></span> <span class="GAPinput">D := EmptyDigraph(3);</span>
<immutable empty digraph with 3 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors[1] := "blue";; vertcolors[2] := "red";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors[3] := "green";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[1] := [];; edgecolors[2] := [];; </span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[3] := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">Print(DotColoredDigraph(D, vertcolors, edgecolors));</span>
//dot
digraph hgn{
node [shape=circle]
1[color=blue, style=filled]
2[color=red, style=filled]
3[color=green, style=filled]
}
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[2], [1, 3], [2]]);</span>
<immutable digraph with 3 vertices, 4 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors[1] := "blue";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors[2] := "pink";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors[3] := "purple";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[1] := [];; edgecolors[2] := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[3] := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[1][2] := "green";; edgecolors[2][1] := "green";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[2][3] := "red";; edgecolors[3][2] := "red";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">Print(DotSymmetricColoredDigraph(D, vertcolors, edgecolors));</span>
//dot
graph hgn{
node [shape=circle]
1[color=blue, style=filled]
2[color=pink, style=filled]
3[color=purple, style=filled]
1 -- 2[color=green]
2 -- 3[color=red]
}
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[2, 3], [1, 3], [1]]);</span>
<immutable digraph with 3 vertices, 5 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors[1] := "blue";; vertcolors[2] := "red";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors[3] := "green";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[1] := [];; edgecolors[2] := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[3] := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[1][2] := "orange";; edgecolors[1][3] := "yellow";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[2][1] := "orange";; edgecolors[2][3] := "pink";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[3][1] := "yellow";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">Print(DotColoredDigraph(D, vertcolors, edgecolors));;</span>
//dot
digraph hgn{
node [shape=circle]
1[color=blue, style=filled]
2[color=red, style=filled]
3[color=green, style=filled]
1 -> 2[color=orange]
1 -> 3[color=yellow]
2 -> 1[color=orange]
2 -> 3[color=pink]
3 -> 1[color=yellow]
}
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph(IsMutableDigraph, [[2, 3], [1, 3], [1]]);</span>
<mutable digraph with 3 vertices, 5 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors[1] := "blue";; vertcolors[2] := "red";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors[3] := "green";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[1] := [];; edgecolors[2] := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[3] := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[1][2] := "orange";; edgecolors[1][3] := "yellow";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[2][1] := "orange";; edgecolors[2][3] := "pink";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[3][1] := "yellow";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">Print(DotColoredDigraph(D, vertcolors, edgecolors));;</span>
//dot
digraph hgn{
node [shape=circle]
1[color=blue, style=filled]
2[color=red, style=filled]
3[color=green, style=filled]
1 -> 2[color=orange]
1 -> 3[color=yellow]
2 -> 1[color=orange]
2 -> 3[color=pink]
3 -> 1[color=yellow]
}
<span class="GAPprompt">gap></span> <span class="GAPinput">D;</span>
<mutable digraph with 3 vertices, 5 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DotSymmetricDigraph(gr2){[12 .. 70]};</span>
" hgn{\nnode [shape=circle]\n\n1\n2\n3\n4\n1 -- 2\n2 -- 3\n3 -- 3\n3 -"
<span class="GAPprompt">gap></span> <span class="GAPinput">DotSymmetricDigraph(gr1);</span>
Error, the argument <D> must be a symmetric digraph,
<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">vertcolors := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors[1] := "blue";; vertcolors[2] := "red";; </span>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors[3] := "green";; vertcolors[4] := "yellow";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">Print(DotVertexColoredDigraph(D, vertcolors));</span>
//dot
digraph hgn{
node [shape=circle]
1[color=blue, style=filled]
2[color=red, style=filled]
3[color=green, style=filled]
4[color=yellow, style=filled]
1 -> 2
1 -> 3
1 -> 4
2 -> 1
2 -> 3
2 -> 4
3 -> 1
3 -> 2
3 -> 4
4 -> 1
4 -> 2
4 -> 3
}
<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">edgecolors := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[1] := [];; edgecolors[2] := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[3] := [];; edgecolors[4] := [];; </span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[1][2] := "lightblue";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[1][3] := "pink";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[1][4] := "purple";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[2][1] := "lightblue";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[2][3] := "pink";; </span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[2][4] := "purple";; </span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[3][1] := "lightblue";; </span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[3][2] := "pink";; </span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[3][4] := "purple";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[4][1] := "lightblue";; </span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[4][2] := "pink";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[4][3] := "purple";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">Print(DotEdgeColoredDigraph(D, edgecolors));</span>
//dot
digraph hgn{
node [shape=circle]
1
2
3
4
1 -> 2[color=lightblue]
1 -> 3[color=pink]
1 -> 4[color=purple]
2 -> 1[color=lightblue]
2 -> 3[color=pink]
2 -> 4[color=purple]
3 -> 1[color=lightblue]
3 -> 2[color=pink]
3 -> 4[color=purple]
4 -> 1[color=lightblue]
4 -> 2[color=pink]
4 -> 3[color=purple]
}
<span class="GAPprompt">gap></span> <span class="GAPinput">FileString("dot/k4.dot", DotDigraph(gr));</span>
154</pre></div>
<p><a id="X78DA31D1869D2F94" name="X78DA31D1869D2F94"></a></p>
<h5>9.1-3 DotSymmetricDigraph</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DotSymmetricDigraph</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">‣ DotSymmetricColoredDigraph</code>( <var class="Arg">digraph</var>, <var class="Arg">vert</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">‣ DotSymmetricVertexColoredDigraph</code>( <var class="Arg">digraph</var>, <var class="Arg">vert</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">‣ DotSymmetricEdgeColoredDigraph</code>( <var class="Arg">digraph</var>, <var class="Arg">edge</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A string.</p>
<p>This function produces a graphical representation of the symmetric digraph <var class="Arg">digraph</var>. <code class="code">DotSymmetricDigraph</code> will return an error if <var class="Arg">digraph</var> is not a symmetric digraph. See <code class="func">IsSymmetricDigraph</code> (<a href="chap6_mj.html#X81B3EA7887219860"><span class="RefLink">6.2-14</span></a>).</p>
<p>The function <code class="code">DotSymmetricColoredDigraph</code> differs from <code class="code">DotDigraph</code> only in that the values given in the two lists are used to color the vertices and edges of the graph when displayed. The list for vertex colours should be a list of length equal to the number of vertices, containing strings that are accepted by the graphviz software, which is the one used for graph representation. The list for edge colours should be a list of lists with the same shape of the outneighbours of the digraph that contains strings that correspond to colours accepted by the graphviz software. If the list is not the appropriate size, or has holes then the function will return an error.</p>
<p>The function <code class="code">DotSymmetricVertexColoredDigraph</code> differs from <code class="code">DotDigraph</code> only in that the values in given in the list is used to color the vertices of the graph when displayed. The list for vertex colours should be a list of length equal to the number of vertices, containing strings that are accepted by the graphviz software, which is the one used for graph representation. If the list is not the appropriate size, or has holes then the function will return an error.</p>
<p>The function <code class="code">DotSymmetricEdgeColoredDigraph</code> differs from <code class="code">DotDigraph</code> only in that the values given in the list are used to color the edges of the graph when displayed. The list for edge colours should be a list of lists with the same shape of the outneighbours, containing strings that are accepted by the graphviz software, which is the one used for graph representation. If the list is not the appropriate size, or has holes then the function will return an error.</p>
<p>Vertices are displayed as circles, numbered consistently with <var class="Arg">digraph</var>. Since <var class="Arg">digraph</var> is symmetric, for every non-loop edge there is a complementary edge with opposite source and range. <code class="code">DotSymmetricDigraph</code> displays each pair of complementary edges as a single line between the relevant vertices, with no arrowhead.</p>
<p>The output is in <code class="code">dot</code> format (also known as <code class="code">GraphViz</code>) format. For details about this file format, and information about how to display or edit this format see <span class="URL"><a href="https://www.graphviz.org">https://www.graphviz.org</a></span>.</p>
<p>The string returned by <code class="code">DotSymmetricDigraph</code> can be written to a file using the command <code class="func">FileString</code> (<a href="/home/runner/gap/pkg/gapdoc/doc/chap6_mj.html#X7E14D32181FBC3C3"><span class="RefLink">GAPDoc: FileString</span></a>).</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">star := Digraph([[2, 2, 3, 4], [1, 1], [1], [1, 4]]);</span>
<immutable multidigraph with 4 vertices, 9 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsSymmetricDigraph(star);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">FileString("dot/star.dot", DotSymmetricDigraph(gr));</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[2], [1, 3], [2]]);</span>
<immutable digraph with 3 vertices, 4 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors[1] := "blue";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors[2] := "pink";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors[3] := "purple";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[1] := [];; edgecolors[2] := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[3] := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[1][2] := "green";; edgecolors[2][1] := "green";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[2][3] := "red";; edgecolors[3][2] := "red";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">Print(DotSymmetricColoredDigraph(D, vertcolors, edgecolors));</span>
//dot
graph hgn{
node [shape=circle]
1[color=blue, style=filled]
2[color=pink, style=filled]
3[color=purple, style=filled]
1 -- 2[color=green]
2 -- 3[color=red]
}
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[2], [1, 3], [2]]);</span>
<immutable digraph with 3 vertices, 4 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors[1] := "blue";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors[2] := "pink";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">vertcolors[3] := "purple";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">Print(DotSymmetricVertexColoredDigraph(D, vertcolors));</span>
//dot
graph hgn{
node [shape=circle]
1[color=blue, style=filled]
2[color=pink, style=filled]
3[color=purple, style=filled]
1 -- 2
2 -- 3
}
<span class="GAPprompt">gap></span> <span class="GAPinput">D := Digraph([[2], [1, 3], [2]]);</span>
<immutable digraph with 3 vertices, 4 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[1] := [];; edgecolors[2] := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[3] := [];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[1][2] := "green";; edgecolors[2][1] := "green";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">edgecolors[2][3] := "red";; edgecolors[3][2] := "red";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">Print(DotSymmetricEdgeColoredDigraph(D, edgecolors));</span>
//dot
graph hgn{
node [shape=circle]
1
2
3
1 -- 2[color=green]
2 -- 3[color=red]
}
83</pre></div>
<p><a id="X84120D447E2CAC23" name="X84120D447E2CAC23"></a></p>
<h5>9.1-4 DotPartialOrderDigraph</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DotPartialOrderDigraph</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>Returns: A string.</p>
<p>This function produces a graphical representation of a partial order digraph <var class="Arg">digraph</var>. <code class="code">DotPartialOrderDigraph</code> will return an error if <var class="Arg">digraph</var> is not a partial order digraph. See <code class="func">IsPartialOrderDigraph</code> (<a href="chap6_mj.html#X82BAE6D37D49A145"><span class="RefLink">6.4-2</span></a>).</p>
<p>Since <var class="Arg">digraph</var> is a partial order, it is both reflexive and transitive. The output of <code class="code">DotPartialOrderDigraph</code> is the <code class="func">DotDigraph</code> (<a href="chap9_mj.html#X7F9B99C478EE093A"><span class="RefLink">9.1-2</span></a>) of the <code class="func">DigraphReflexiveTransitiveReduction</code> (<a href="chap3_mj.html#X82AD17517E273600"><span class="RefLink">3.3-14</span></a>) of <var class="Arg">digraph</var>.</p>
<p>The output is in <code class="code">dot</code> format (also known as <code class="code">GraphViz</code>) format. For details about this file format, and information about how to display or edit this format see <span class="URL"><a href="https://www.graphviz.org">https://www.graphviz.org</a></span>.</p>
<p>The string returned by <code class="code">DotPartialOrderDigraph</code> can be written to a file using the command <code class="func">FileString</code> (<a href="/home/runner/gap/pkg/gapdoc/doc/chap6_mj.html#X7E14D32181FBC3C3"><span class="RefLink">GAPDoc: FileString</span></a>).</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">poset := Digraph([[1, 4], [2], [2, 3, 4], [4]);</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsPartialOrderDigraph(gr);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">FileString("dot/poset.dot", DotPartialOrderDigraph(gr));</span>
83</pre></div>
<p><a id="X7F5653C8854FAEA6" name="X7F5653C8854FAEA6"></a></p>
<h5>9.1-5 DotPreorderDigraph</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DotPreorderDigraph</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">‣ DotQuasiorderDigraph</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>Returns: A string.</p>
<p>This function produces a graphical representation of a preorder digraph <var class="Arg">digraph</var>. <code class="code">DotPreorderDigraph</code> will return an error if <var class="Arg">digraph</var> is not a preorder digraph. See <code class="func">IsPreorderDigraph</code> (<a href="chap6_mj.html#X8617726C7829F796"><span class="RefLink">6.4-1</span></a>).</p>
<p>A preorder digraph is reflexive and transitive but in general it is not anti-symmetric and may have strongly connected components containing more than one vertex. The <code class="func">QuotientDigraph</code> (<a href="chap3_mj.html#X7D1D26D27F5B56C2"><span class="RefLink">3.3-9</span></a>) <var class="Arg">Q</var> obtained by forming the quotient of <var class="Arg">digraph</var> by the partition of its vertices into the strongly connected components satisfies <code class="func">IsPartialOrderDigraph</code> (<a href="chap6_mj.html#X82BAE6D37D49A145"><span class="RefLink">6.4-2</span></a>). Thus every vertex of <var class="Arg">Q</var> corresponds to a strongly connected component of <var class="Arg">digraph</var>. The output of <code class="code">DotPreorderDigraph</code> displays the <code class="func">DigraphReflexiveTransitiveReduction</code> (<a href="chap3_mj.html#X82AD17517E273600"><span class="RefLink">3.3-14</span></a>) of <var class="Arg">Q</var> with vertices displayed as rounded rectangles labelled by all of the vertices of <var class="Arg">digraph</var> in the corresponding strongly connected component.</p>
<p>The output is in <code class="code">dot</code> format (also known as <code class="code">GraphViz</code>) format. For details about this file format, and information about how to display or edit this format see <span class="URL"><a href="https://www.graphviz.org">https://www.graphviz.org</a></span>.</p>
<p>The string returned by <code class="code">DotPreorderDigraph</code> can be written to a file using the command <code class="func">FileString</code> (<a href="/home/runner/gap/pkg/gapdoc/doc/chap6_mj.html#X7E14D32181FBC3C3"><span class="RefLink">GAPDoc: FileString</span></a>).</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">preset := Digraph([[1, 2, 4, 5], [1, 2, 4, 5], [3, 4], [4], [1, 2, 4, 5]);</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsPreorderDigraph(gr);</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">FileString("dot/preset.dot", DotProrderDigraph(gr));</span>
83</pre></div>
<p><a id="X808D12CF81E2C19F" name="X808D12CF81E2C19F"></a></p>
<h5>9.1-6 DotHighlightedDigraph</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DotHighlightedDigraph</code>( <var class="Arg">digraph</var>, <var class="Arg">verts</var>[, <var class="Arg">colour1</var>, <var class="Arg">colour2</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A string.</p>
<p><code class="code">DotHighlightedDigraph</code> produces a graphical representation of the digraph <var class="Arg">digraph</var>, where the vertices in the list <var class="Arg">verts</var>, and edges between them, are drawn with colour <var class="Arg">colour1</var> and all other vertices and edges in <var class="Arg">digraph</var> are drawn with colour <var class="Arg">colour2</var>. If <var class="Arg">colour1</var> and <var class="Arg">colour2</var> are not given then <code class="code">DotHighlightedDigraph</code> uses black and grey respectively.</p>
<p>Note that <code class="code">DotHighlightedDigraph</code> does not validate the colours <var class="Arg">colour1</var> and <var class="Arg">colour2</var> - consult the GraphViz documentation to see what is available. See <code class="func">DotDigraph</code> (<a href="chap9_mj.html#X7F9B99C478EE093A"><span class="RefLink">9.1-2</span></a>) for more details on the output.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">digraph := Digraph([[2, 3], [2], [1, 3]]);</span>
<digraph with 3 vertices, 5 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">FileString("dot/my_digraph.dot",</span>
<span class="GAPprompt">></span> <span class="GAPinput">DotHighlightedDigraph(digraph, [1, 2], "red", "black"));</span>
264</pre></div>
<p><a id="X81C9B1DC791C0BBD" name="X81C9B1DC791C0BBD"></a></p>
<h4>9.2 <span class="Heading">Reading and writing digraphs to a file</span></h4>
<p>This section describes different ways to store and read graphs from a file in the <strong class="pkg">Digraphs</strong> package.</p>
<dl>
<dt><strong class="Mark"> Graph6 </strong></dt>
<dd><p><em> Graph6 </em> is a graph data format for storing undirected graphs with no multiple edges nor loops of size up to <span class="SimpleMath">\( 2^{36} - 1 \)</span> in printable characters. The format consists of two parts. The first part uses one to eight bytes to store the number of vertices. And the second part is the upper half of the adjacency matrix converted into ASCII characters. For a more detail description see <span class="URL"><a href=" http://cs.anu.edu.au/~bdm/data/formats.txt">Graph6</a></span>.</p>
</dd>
<dt><strong class="Mark"> Sparse6 </strong></dt>
<dd><p><em> Sparse6 </em> is a graph data format for storing undirected graphs with possibly multiple edges or loops. The maximal number of vertices allowed is <span class="SimpleMath">\( 2^{36} - 1 \)</span>. The format consists of two parts. The first part uses one to eight bytes to store the number of vertices. And the second part only stores information about the edges. Therefore, the <em> Sparse6 </em> format return a more compact encoding then <em> Graph6 </em> for sparse graph, i.e. graphs where the number of edges is much less than the number of vertices squared. For a more detail description see <span class="URL"><a href=" http://cs.anu.edu.au/~bdm/data/formats.txt">Sparse6</a></span>.</p>
</dd>
<dt><strong class="Mark"> Digraph6 </strong></dt>
<dd><p><em>Digraph6</em> is a new format based on <em> Graph6 </em>, but designed for digraphs. The entire adjacency matrix is stored, and therefore there is support for directed edges and single-vertex loops. However, multiple edges are not supported.</p>
</dd>
<dt><strong class="Mark"> DiSparse6 </strong></dt>
<dd><p><em>DiSparse6</em> is a new format based on <em> Sparse6 </em>, but designed for digraphs. In this format the list of edges is partitioned into increasing and decreasing edges, depending whether the edge has its source bigger than the range. Then both sets of edges are written separately in <em> Sparse6 </em> format with a separation symbol in between.</p>
</dd>
<dt><strong class="Mark"> dreadnaut </strong></dt>
<dd><p><em>dreadnaut</em> is a graph data format designed for directed and undirected graphs. The format supports loops but multiple edges are ignored. The format consists of an initial section that defines the graph's structural properties, such as the number of vertices, the starting value for vertices, and whether the graph is directed. This is followed by a list of edges. For more information and examples of the format see nauty and Traces User's Guide</a></span>.</p>
</dd>
<dt><strong class="Mark"> DIMACS </strong></dt>
<dd><p><em>DIMACS</em> is a graph data format that can be used for symmetric digraphs. For a more detailed description, see <code class="func">WriteDIMACSDigraph</code> (<a href="chap9_mj.html#X804FDF6A7ED64049"><span class="RefLink">9.2-16</span></a>)</p>
</dd>
</dl>
<p><a id="X81FB5BE27903EC32" name="X81FB5BE27903EC32"></a></p>
<h5>9.2-1 String</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ String</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">‣ PrintString</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A string.</p>
<p>Returns a string <code class="code">string</code> such that <code class="code">EvalString(string)</code> is equal to <var class="Arg">digraph</var>, and has the same mutability. See <code class="func">EvalString</code> (<a href="/home/runner/gap/doc/ref/chap27_mj.html#X7DE4CCD285440659"><span class="RefLink">Reference: EvalString</span></a>).</p>
<p>The methods installed for <code class="code">String</code> make some attempts to ensure that <code class="code">string</code> has as short a length as possible, but there may exist shorter strings that also evaluate to <var class="Arg">digraph</var>.</p>
<p>It is possible that <code class="code">string</code> may contain escaped special characters. To obtain a representation of <var class="Arg">digraph</var> that can be entered as GAP input, please use <code class="func">Print</code> (<a href="/home/runner/gap/doc/ref/chap6_mj.html#X7AFA64D97A1F39A3"><span class="RefLink">Reference: Print</span></a>). Note that <code class="code">Print</code> for a digraph delegates to <code class="code">PrintString</code>, which delegates to <code class="code">String</code>.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">D := CycleDigraph(3);</span>
<immutable cycle digraph with 3 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">Print(D);</span>
CycleDigraph(3);
<span class="GAPprompt">gap></span> <span class="GAPinput">G := PetersenGraph(IsMutableDigraph);</span>
<mutable digraph with 10 vertices, 30 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">String(G);</span>
"DigraphFromGraph6String(IsMutableDigraph, \"IheA@GUAo\");"
<span class="GAPprompt">gap></span> <span class="GAPinput">Print(last);</span>
DigraphFromGraph6String(IsMutableDigraph, "IheA@GUAo");
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphFromGraph6String(IsMutableDigraph, "IheA@GUAo");</span>
<mutable digraph with 10 vertices, 30 edges>
</pre></div>
<p><a id="X873D6EB8836A3C61" name="X873D6EB8836A3C61"></a></p>
<h5>9.2-2 DigraphFromGraph6String</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphFromGraph6String</code>( [<var class="Arg">filt</var>, ]<var class="Arg">str</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">‣ DigraphFromDigraph6String</code>( [<var class="Arg">filt</var>, ]<var class="Arg">str</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">‣ DigraphFromSparse6String</code>( [<var class="Arg">filt</var>, ]<var class="Arg">str</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">‣ DigraphFromDiSparse6String</code>( [<var class="Arg">filt</var>, ]<var class="Arg">str</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A digraph.</p>
<p>If <var class="Arg">str</var> is a string encoding a graph in Graph6, Digraph6, Sparse6 or DiSparse6 format, then the corresponding function returns a digraph. In the case of either Graph6 or Sparse6, formats which do not support directed edges, this will be a digraph such that for every edge, the edge going in the opposite direction is also present.</p>
<p>Each of these functions takes an optional first argument <var class="Arg">filt</var>, which should be either <code class="func">IsMutableDigraph</code> (<a href="chap3_mj.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>) or <code class="func">IsImmutableDigraph</code> (<a href="chap3_mj.html#X7CAFAA89804F80BD"><span class="RefLink">3.1-3</span></a>), and which specifies whether the output digraph shall be mutable or immutable. If no first argument is provided, then an immutable digraph is returned by default.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphFromGraph6String("?");</span>
<immutable empty digraph with 0 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphFromGraph6String("C]");</span>
<immutable symmetric digraph with 4 vertices, 8 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphFromGraph6String("H?AAEM{");</span>
<immutable symmetric digraph with 9 vertices, 22 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphFromDigraph6String("&?");</span>
<immutable empty digraph with 0 vertices>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphFromDigraph6String(IsMutableDigraph, "&DOOOW?");</span>
<mutable digraph with 5 vertices, 5 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphFromDigraph6String("&CQFG");</span>
<immutable digraph with 4 vertices, 6 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphFromDigraph6String("&IM[SrKLc~lhesbU[F_");</span>
<immutable digraph with 10 vertices, 51 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphFromDiSparse6String(".CaWBGA?b");</span>
<immutable multidigraph with 4 vertices, 9 edges>
</pre></div>
<p><a id="X782A052979EA2376" name="X782A052979EA2376"></a></p>
<h5>9.2-3 Graph6String</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Graph6String</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">‣ Digraph6String</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">‣ Sparse6String</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">‣ DiSparse6String</code>( <var class="Arg">digraph</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A string.</p>
<p>These four functions return a highly compressed string fully describing the digraph <var class="Arg">digraph</var>.</p>
<p>Graph6 and Digraph6 are formats best used on small, dense graphs, if applicable. For larger, sparse graphs use <em>Sparse6</em> and <em>Disparse6</em> (this latter also preserves multiple edges).</p>
<p>See <code class="func">WriteDigraphs</code> (<a href="chap9_mj.html#X82A4F0767C9EFC87"><span class="RefLink">9.2-8</span></a>).</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">gr := Digraph([[2, 3], [1], [1]]);</span>
<immutable digraph with 3 vertices, 4 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">Sparse6String(gr);</span>
":Bc"
<span class="GAPprompt">gap></span> <span class="GAPinput">DiSparse6String(gr);</span>
".Bc{f"
</pre></div>
<p><a id="X87DD8B1E867760A5" name="X87DD8B1E867760A5"></a></p>
<h5>9.2-4 DigraphFromDreadnautString</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphFromDreadnautString</code>( <var class="Arg">s</var> )</td><td class="tdright">( operation )</ | |