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 100 kB image not shown  

Quelle  chap9.html   Sprache: HTML

 
 products/Sources/formale Sprachen/GAP/pkg/digraphs/doc/chap9.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 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.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="chap8.html">[Previous Chapter]</a>    <a href="chapA.html">[Next Chapter]</a>   </div>

<p id="mathjaxlink" class="pcenter"><a href="chap9_mj.html">[MathJax on]</a></p>
<p><a id="X81714DBC80CC4BCB" name="X81714DBC80CC4BCB"></a></p>
<div class="ChapSects"><a href="chap9.html#X81714DBC80CC4BCB">9 <span class="Heading">Visualising and IO</span></a>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap9.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.html#X83B3318784E78415">9.1-1 Splash</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X7F9B99C478EE093A">9.1-2 DotDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X78DA31D1869D2F94">9.1-3 DotSymmetricDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X84120D447E2CAC23">9.1-4 DotPartialOrderDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X7F5653C8854FAEA6">9.1-5 DotPreorderDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X808D12CF81E2C19F">9.1-6 DotHighlightedDigraph</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap9.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.html#X81FB5BE27903EC32">9.2-1 String</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X873D6EB8836A3C61">9.2-2 DigraphFromGraph6String</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X782A052979EA2376">9.2-3 Graph6String</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X87DD8B1E867760A5">9.2-4 DigraphFromDreadnautString</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X7923733D86767CE1">9.2-5 DIMACSString</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X7845ACDA7D4D333D">9.2-6 DigraphFile</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X7E8142007ED0CB9F">9.2-7 ReadDigraphs</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X82A4F0767C9EFC87">9.2-8 WriteDigraphs</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X86D531B287733561">9.2-9 IteratorFromDigraphFile</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X7AAA35867B5D8BF4">9.2-10 DigraphPlainTextLineEncoder</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X7808D99079295C22">9.2-11 TournamentLineDecoder</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X7DF22D1687D096D6">9.2-12 AdjacencyMatrixUpperTriangleLineDecoder</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X875393338486D77D">9.2-13 TCodeDecoder</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X8540FC21796A793F">9.2-14 PlainTextString</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X81BD23697857B244">9.2-15 WritePlainTextDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X804FDF6A7ED64049">9.2-16 WriteDIMACSDigraph</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.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.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.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.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.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.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.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.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. Thoutput of <code class="code">DotPartialOrderDigraph</code> is the <code class="func">DotDigraph</code> (<a href="chap9.html#X7F9B99C478EE093A"><span class="RefLink">9.1-2</span></a>) of the <code class="func">DigraphReflexiveTransitiveReduction</code> (<a href="chap3.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.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.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.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.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.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.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.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 </emformat 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.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.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.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.html#X7D7EDF83820ED6F5"><span class="RefLink">3.1-2</span></a>) or <code class="func">IsImmutableDigraph</code> (<a href="chap3.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.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 )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DreadnautString</code>( <var class="Arg">digraph</var>[, <var class="Arg">partition</var>] )</td><td class="tdright">( operation )</td></tr></table></div>
<p>These operations read or write a single digraph to or from a string in the dreadnaut format, as appropriate.</p>

<p><code class="code">DigraphFromDreadnautString</code> expects the argument <var class="Arg">s</var> to be a string, containing a single graph in dreadnaut format, and returns a digraph.</p>

<p>If the vertices are not already 1-indexed, their labels will be reindexed by subtracting a constant offset so that the smallest label becomes 1, with the relative ordering of vertex labels being preserved. If a partition is explicitly specified, each vertex will be assigned a label corresponding to its part in the partition. Should the graph be undirected, the symmetric closure of the graph will be returned. See <code class="func">DigraphVertexLabels</code> (<a href="chap5.html#X7E51F2FE87140B32"><span class="RefLink">5.1-12</span></a>) and <code class="func">DigraphSymmetricClosure</code> (<a href="chap3.html#X874883DD7DD450C4"><span class="RefLink">3.3-12</span></a>).</p>

<p><code class="code">DreadnautString</code> expects a digraph <var class="Arg">digraph</var> and returns a string in dreadnaut format. An optional second argument <var class="Arg">partition</var> may be provided, which should be a list of length equal to the number of vertices in <var class="Arg">digraph</var>. Each entry in the list assigns the corresponding vertex to a group, allowing you to specify a vertex partition. For example, if the digraph has three vertices and <var class="Arg">partition</var> is <code class="code">["a""b""a"]</code>, this would mean that the first and third vertices belong to the same part, and the second vertex belongs to a separate part. This partition will appear in the resulting string as a line of the form <code class="code">f = [...]</code>.</p>

<p>Note that <code class="func">WriteDigraphs</code> (<a href="chap9.html#X82A4F0767C9EFC87"><span class="RefLink">9.2-8</span></a>) does not support specifying a partition when writing a digraph to a file in dreadnaut format. To include a partition when writing to a file, use <code class="code">DreadnautString</code> to generate the string, then write it to a file using standard I/O functions. If <var class="Arg">digraph</var> has multiple edges, then <code class="code">DreadnautString</code> returns a digraph constructed from <var class="Arg">digraph</var> by removing all multiple edges.</p>

<p>A detailed description of commands and options in dreadnaut format can be found at <span class="URL"><a href="
http://pallini.di.uniroma1.it/Guide.html"
>nauty and Traces User's Guide. Of those commands, the following are supported: n, g (and all available subcommands), _ (underscore), __ (double underscore), f, $=#, $$, d, -d, "...", !




<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">gr := Digraph([[2], [1, 3, 4], [2, 4], [2, 3]]);</span>
<immutable digraph with 4 vertices, 8 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">s := DreadnautString(gr);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphFromDreadnautString(s) = gr;</span>
true
<span class="GAPprompt">gap></span> <span class="GAPinput">DreadnautString(gr, ["a""b""b""a"]);</span>
"n=4 $=1 d g\n1 : 2;\n2 : 1 3 4;\n3 : 2 4;\n4 : 2 3.\nf = [1 4 | 2 3]"</pre></div>

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

<h5>9.2-5 DIMACSString</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DIMACSString</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">‣ DigraphFromDIMACSString</code>( <var class="Arg">s</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Returns: A string.</p>

<p><code class="code">DIMACSString</code> takes a single symmetric digraph <var class="Arg">digraph</var>, and returns a string representation of <var class="Arg">digraph</var> in the DIMACS format.</p>

<p><code class="code">DigraphFromDIMACSString</code> takes such a string and returns the single symmetric digraph which it describes.</p>

<p>For more information on the DIMACS format, see <code class="func">WriteDIMACSDigraph</code> (<a href="chap9.html#X804FDF6A7ED64049"><span class="RefLink">9.2-16</span></a>).</p>

<p>These functions support file-based DIMACS encoding and decoding through <code class="func">WriteDigraphs</code> (<a href="chap9.html#X82A4F0767C9EFC87"><span class="RefLink">9.2-8</span></a>) and <code class="func">ReadDigraphs</code> (<a href="chap9.html#X7E8142007ED0CB9F"><span class="RefLink">9.2-7</span></a>), for consistency with other encoders and decoders. Alternatively, <code class="func">WriteDIMACSDigraph</code> (<a href="chap9.html#X804FDF6A7ED64049"><span class="RefLink">9.2-16</span></a>) and <code class="func">ReadDIMACSDigraph</code> (<a href="chap9.html#X804FDF6A7ED64049"><span class="RefLink">9.2-16</span></a>) may be used for direct DIMACS I/O.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">gr := Digraph([[2], [1, 3, 4], [2, 4], [2, 3]]);</span>
<immutable digraph with 4 vertices, 8 edges>
<span class="GAPprompt">gap></span> <span class="GAPinput">DIMACSString(gr);</span>
"p edge 4 4\ne 1 2\ne 2 3\ne 2 4\ne 3 4\nn 1 1\nn 2 2\nn 3 3\nn 4 4"
<span class="GAPprompt">gap></span> <span class="GAPinput">DigraphFromDIMACSString(last);</span>
<immutable digraph with 4 vertices, 8 edges></pre></div>

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

<h5>9.2-6 DigraphFile</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DigraphFile</code>( <var class="Arg">filename</var>[, <var class="Arg">coder</var>][, <var class="Arg">mode</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: An IO file object.</p>

<p>If <var class="Arg">filename</var> is a string representing the name of a file, then <code class="code">DigraphFile</code> returns an <span class="URL"><a href="https://gap-packages.github.io/io">IO</a></span> package file object for that file.</p>

<p>If the optional argument <var class="Arg">coder</var> is specified and is a function which either encodes a digraph as a string, or decodes a string into a digraph, then this function will be used when reading or writing to the returned file object. If the optional argument <var class="Arg">coder</var> is not specified, then the encoding of the digraphs in the returned file object must be specified in the the file extension. The file extension must be one of: <code class="code">.g6</code>, <code class="code">.s6</code>, <code class="code">.d6</code>, <code class="code">.ds6</code>, <code class="code">.txt</code>, <code class="code">.p</code>, or <code class="code">.pickle</code>; more details of these file formats is given below.</p>

<p>If the optional argument <var class="Arg">mode</var> is specified, then it must be one of: <code class="code">"w"</code> (for write), <code class="code">"a"</code> (for append), or <code class="code">"r"</code> (for read). If <var class="Arg">mode</var> is not specified, then <code class="code">"r"</code> is used by default.</p>

<p>If <var class="Arg">filename</var> ends in one of: <code class="code">.gz</code>, <code class="code">.bz2</code>, or <code class="code">.xz</code>, then the digraphs which are read from, or written to, the returned file object are decompressed, or compressed, appropriately.</p>

<p>The file object returned by <code class="code">DigraphFile</code> can be given as the first argument for either of the functions <code class="func">ReadDigraphs</code> (<a href="chap9.html#X7E8142007ED0CB9F"><span class="RefLink">9.2-7</span></a>) or <code class="func">WriteDigraphs</code> (<a href="chap9.html#X82A4F0767C9EFC87"><span class="RefLink">9.2-8</span></a>). The purpose of this is to reduce the overhead of recreating the file object inside the functions <code class="func">ReadDigraphs</code> (<a href="chap9.html#X7E8142007ED0CB9F"><span class="RefLink">9.2-7</span></a>) or <code class="func">WriteDigraphs</code> (<a href="chap9.html#X82A4F0767C9EFC87"><span class="RefLink">9.2-8</span></a>) when, for example, reading or writing many digraphs in a loop.</p>

<p>The currently supported file formats, and associated filename extensions, are:</p>


<dl>
<dt><strong class="Mark">graph6 (.g6)</strong></dt>
<dd><p>A standard and widely-used format for undirected graphs, with no support for loops or multiple edges. Only symmetric graphs are allowed -- each edge is combined with its converse edge to produce a single undirected edge. This format is best used for "dense" graphs -- those with many edges per vertex.</p>

</dd>
<dt><strong class="Mark">sparse6 (.s6)</strong></dt>
<dd><p>Unlike graph6, sparse6 has support for loops and multiple edges. However, its use is still limited to symmetric graphs. This format is better-suited to "sparse" graphs -- those with few edges per vertex.</p>

</dd>
<dt><strong class="Mark">digraph6 (.d6)</strong></dt>
<dd><p>This format is based on graph6, but stores direction information - therefore is not limited to symmetric graphs. Loops are allowed, but multiple edges are not. Best compression with "dense" graphs.</p>

</dd>
<dt><strong class="Mark">disparse6 (.ds6)</strong></dt>
<dd><p>Any type of digraph can be encoded in disparse6: directions, loops, and multiple edges are all allowed. Similar to sparse6, this has the best compression rate with "sparse" graphs.</p>

</dd>
<dt><strong class="Mark">plain text (.txt)</strong></dt>
<dd><p>This is a human-readable format which stores graphs in the form <code class="code">0 7 0 8 1 7 2 8 3 8 4 8 5 8 6 8</code> i.e. pairs of vertices describing edges in a graph. More specifically, the vertices making up one edge must be separated by a single space, and pairs of vertices must be separated by two spaces.</p>

<p>See <code class="func">ReadPlainTextDigraph</code> (<a href="chap9.html#X81BD23697857B244"><span class="RefLink">9.2-15</span></a>) for a more flexible way to store digraphs in a plain text file.</p>

</dd>
<dt><strong class="Mark">pickled (<code class="file">.p</code> or <code class="file">.pickle</code>)</strong></dt>
<dd><p>Digraphs are pickled using the <span class="URL"><a href="https://gap-packages.github.io/io">IO</a></span> package. This is particularly good when the <code class="func">DigraphGroup</code> (<a href="chap7.html#X803ACEDA7BBAC5B3"><span class="RefLink">7.2-10</span></a>) is non-trivial.</p>

</dd>
<dt><strong class="Mark">dreadnaut (.dre)</strong></dt>
<dd><p>A graph 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 (.dimacs) </strong></dt>
<dd><p>A graph format that can be used for symmetric digraphs. For a more detailed description, see <code class="func">WriteDIMACSDigraph</code> (<a href="chap9.html#X804FDF6A7ED64049"><span class="RefLink">9.2-16</span></a>)</p>

</dd>
</dl>

<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">filename := Concatenation(DIGRAPHS_Dir(), "/tst/out/man.d6.gz");;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">file := DigraphFile(filename, "w");;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">for i in [1 .. 10] do</span>
--> --------------------

--> maximum size reached

--> --------------------

100%


¤ Dauer der Verarbeitung: 0.40 Sekunden  (vorverarbeitet)  ¤

*© 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 ist noch experimentell.