Skip to content

Commit 24c7756

Browse files
authored
Fix DotDigraph documentation #759 (#880)
* Change all Logs to Examples * Make edge and vertices colouring lists more efficient, and add examples of DotVertexLabelledDigraph, DotVertexColoredDigraph and DotEdgeColoredDigraph * Remove EmptyDigraph example * Remove duplicated DotSymmetricDigraph example from next section * Make vertcolors and edgecolors more efficient * Remove Mutable Digraph example * Merge CompleteDigraph(4) examples at the end of the section with the first instance * Move FileString command * Remove star example and repeated instances of defining the digraph used in the next example * Rewrite symmetric digraph examples to streamline color assignments and remove repeated examples * Fix syntax errors in examples for IsPartialOrderDigraph and IsPreorderDigraph * Edited FileString outputs and edited some typos in later poset and preset examples * Add in terminal outputs for preset and poset definitions * Update file paths in FileString commands to remove 'dot/' prefix, and fix minor typos * Change 'digraph' to 'immutable digraph' in some outputs * Fixed outputs to FileString commands * Swap node colors 'green' and 'red' in DotColoredDigraph example, causing issues * Fix line length issues
1 parent 814cd1a commit 24c7756

1 file changed

Lines changed: 92 additions & 204 deletions

File tree

doc/display.xml

Lines changed: 92 additions & 204 deletions
Original file line numberDiff line numberDiff line change
@@ -152,158 +152,38 @@ gap> Splash(DotDigraph(RandomDigraph(4)));
152152
The string returned by <C>DotDigraph</C> or
153153
<C>DotVertexLabelledDigraph</C> can be written to a file using
154154
the command <Ref Func="FileString" BookName="GAPDoc"/>.<P/>
155-
<Log><![CDATA[
156-
gap> adj := List([1 .. 4], x -> [1, 1, 1, 1]);
157-
[ [ 1, 1, 1, 1 ], [ 1, 1, 1, 1 ], [ 1, 1, 1, 1 ], [ 1, 1, 1, 1 ] ]
158-
gap> adj[1][3] := 0;
159-
0
160-
gap> gr := DigraphByAdjacencyMatrix(adj);
161-
<immutable digraph with 4 vertices, 15 edges>
155+
<Example><![CDATA[
162156
gap> D := CompleteDigraph(4);
163157
<immutable complete digraph with 4 vertices>
164-
gap> vertcolors := [];;
165-
gap> vertcolors[1] := "blue";; vertcolors[2] := "red";;
166-
gap> vertcolors[3] := "green";; vertcolors[4] := "yellow";;
167-
gap> edgecolors := [];;
168-
gap> edgecolors[1] := [];; edgecolors[2] := [];;
169-
gap> edgecolors[3] := [];; edgecolors[4] := [];;
170-
gap> edgecolors[1][2] := "lightblue";;
171-
gap> edgecolors[1][3] := "pink";;
172-
gap> edgecolors[1][4] := "purple";;
173-
gap> edgecolors[2][1] := "lightblue";;
174-
gap> edgecolors[2][3] := "pink";;
175-
gap> edgecolors[2][4] := "purple";;
176-
gap> edgecolors[3][1] := "lightblue";;
177-
gap> edgecolors[3][2] := "pink";;
178-
gap> edgecolors[3][4] := "purple";;
179-
gap> edgecolors[4][1] := "lightblue";;
180-
gap> edgecolors[4][2] := "pink";;
181-
gap> edgecolors[4][3] := "purple";;
182-
gap> Print(DotColoredDigraph(D, vertcolors, edgecolors));
158+
gap> vertcolors := ["blue", "green", "red", "yellow"];;
159+
gap> Print(DotVertexLabelledDigraph(D));
183160
//dot
184161
digraph hgn{
185162
node [shape=circle]
186-
1[color=blue, style=filled]
187-
2[color=red, style=filled]
188-
3[color=green, style=filled]
189-
4[color=yellow, style=filled]
190-
1 -> 2[color=lightblue]
191-
1 -> 3[color=pink]
192-
1 -> 4[color=purple]
193-
2 -> 1[color=lightblue]
194-
2 -> 3[color=pink]
195-
2 -> 4[color=purple]
196-
3 -> 1[color=lightblue]
197-
3 -> 2[color=pink]
198-
3 -> 4[color=purple]
199-
4 -> 1[color=lightblue]
200-
4 -> 2[color=pink]
201-
4 -> 3[color=purple]
202-
}
203-
gap> D := EmptyDigraph(3);
204-
<immutable empty digraph with 3 vertices>
205-
gap> vertcolors := [];;
206-
gap> vertcolors[1] := "blue";; vertcolors[2] := "red";;
207-
gap> vertcolors[3] := "green";;
208-
gap> edgecolors := [];;
209-
gap> edgecolors[1] := [];; edgecolors[2] := [];;
210-
gap> edgecolors[3] := [];;
211-
gap> Print(DotColoredDigraph(D, vertcolors, edgecolors));
212-
//dot
213-
digraph hgn{
214-
node [shape=circle]
215-
1[color=blue, style=filled]
216-
2[color=red, style=filled]
217-
3[color=green, style=filled]
218-
}
219-
gap> D := Digraph([[2], [1, 3], [2]]);
220-
<immutable digraph with 3 vertices, 4 edges>
221-
gap> vertcolors := [];;
222-
gap> vertcolors[1] := "blue";;
223-
gap> vertcolors[2] := "pink";;
224-
gap> vertcolors[3] := "purple";;
225-
gap> edgecolors := [];;
226-
gap> edgecolors[1] := [];; edgecolors[2] := [];;
227-
gap> edgecolors[3] := [];;
228-
gap> edgecolors[1][2] := "green";; edgecolors[2][1] := "green";;
229-
gap> edgecolors[2][3] := "red";; edgecolors[3][2] := "red";;
230-
gap> Print(DotSymmetricColoredDigraph(D, vertcolors, edgecolors));
231-
//dot
232-
graph hgn{
233-
node [shape=circle]
234-
235-
1[color=blue, style=filled]
236-
2[color=pink, style=filled]
237-
3[color=purple, style=filled]
238-
1 -- 2[color=green]
239-
2 -- 3[color=red]
240-
}
241-
gap> D := Digraph([[2, 3], [1, 3], [1]]);
242-
<immutable digraph with 3 vertices, 5 edges>
243-
gap> vertcolors := [];;
244-
gap> vertcolors[1] := "blue";; vertcolors[2] := "red";;
245-
gap> vertcolors[3] := "green";;
246-
gap> edgecolors := [];;
247-
gap> edgecolors[1] := [];; edgecolors[2] := [];;
248-
gap> edgecolors[3] := [];;
249-
gap> edgecolors[1][2] := "orange";; edgecolors[1][3] := "yellow";;
250-
gap> edgecolors[2][1] := "orange";; edgecolors[2][3] := "pink";;
251-
gap> edgecolors[3][1] := "yellow";;
252-
gap> Print(DotColoredDigraph(D, vertcolors, edgecolors));;
253-
//dot
254-
digraph hgn{
255-
node [shape=circle]
256-
1[color=blue, style=filled]
257-
2[color=red, style=filled]
258-
3[color=green, style=filled]
259-
1 -> 2[color=orange]
260-
1 -> 3[color=yellow]
261-
2 -> 1[color=orange]
262-
2 -> 3[color=pink]
263-
3 -> 1[color=yellow]
264-
}
265-
gap> D := Digraph(IsMutableDigraph, [[2, 3], [1, 3], [1]]);
266-
<mutable digraph with 3 vertices, 5 edges>
267-
gap> vertcolors := [];;
268-
gap> vertcolors[1] := "blue";; vertcolors[2] := "red";;
269-
gap> vertcolors[3] := "green";;
270-
gap> edgecolors := [];;
271-
gap> edgecolors[1] := [];; edgecolors[2] := [];;
272-
gap> edgecolors[3] := [];;
273-
gap> edgecolors[1][2] := "orange";; edgecolors[1][3] := "yellow";;
274-
gap> edgecolors[2][1] := "orange";; edgecolors[2][3] := "pink";;
275-
gap> edgecolors[3][1] := "yellow";;
276-
gap> Print(DotColoredDigraph(D, vertcolors, edgecolors));;
277-
//dot
278-
digraph hgn{
279-
node [shape=circle]
280-
1[color=blue, style=filled]
281-
2[color=red, style=filled]
282-
3[color=green, style=filled]
283-
1 -> 2[color=orange]
284-
1 -> 3[color=yellow]
285-
2 -> 1[color=orange]
286-
2 -> 3[color=pink]
287-
3 -> 1[color=yellow]
163+
1 [label="1"]
164+
2 [label="2"]
165+
3 [label="3"]
166+
4 [label="4"]
167+
1 -> 2
168+
1 -> 3
169+
1 -> 4
170+
2 -> 1
171+
2 -> 3
172+
2 -> 4
173+
3 -> 1
174+
3 -> 2
175+
3 -> 4
176+
4 -> 1
177+
4 -> 2
178+
4 -> 3
288179
}
289-
gap> D;
290-
<mutable digraph with 3 vertices, 5 edges>
291-
gap> DotSymmetricDigraph(gr2){[12 .. 70]};
292-
" hgn{\nnode [shape=circle]\n\n1\n2\n3\n4\n1 -- 2\n2 -- 3\n3 -- 3\n3 -"
293-
gap> DotSymmetricDigraph(gr1);
294-
Error, the argument <D> must be a symmetric digraph,
295-
gap> D := CompleteDigraph(4);
296-
<immutable complete digraph with 4 vertices>
297-
gap> vertcolors := [];;
298-
gap> vertcolors[1] := "blue";; vertcolors[2] := "red";;
299-
gap> vertcolors[3] := "green";; vertcolors[4] := "yellow";;
300180
gap> Print(DotVertexColoredDigraph(D, vertcolors));
301181
//dot
302182
digraph hgn{
303183
node [shape=circle]
304184
1[color=blue, style=filled]
305-
2[color=red, style=filled]
306-
3[color=green, style=filled]
185+
2[color=green, style=filled]
186+
3[color=red, style=filled]
307187
4[color=yellow, style=filled]
308188
1 -> 2
309189
1 -> 3
@@ -318,23 +198,8 @@ node [shape=circle]
318198
4 -> 2
319199
4 -> 3
320200
}
321-
gap> D := CompleteDigraph(4);
322-
<immutable complete digraph with 4 vertices>
323-
gap> edgecolors := [];;
324-
gap> edgecolors[1] := [];; edgecolors[2] := [];;
325-
gap> edgecolors[3] := [];; edgecolors[4] := [];;
326-
gap> edgecolors[1][2] := "lightblue";;
327-
gap> edgecolors[1][3] := "pink";;
328-
gap> edgecolors[1][4] := "purple";;
329-
gap> edgecolors[2][1] := "lightblue";;
330-
gap> edgecolors[2][3] := "pink";;
331-
gap> edgecolors[2][4] := "purple";;
332-
gap> edgecolors[3][1] := "lightblue";;
333-
gap> edgecolors[3][2] := "pink";;
334-
gap> edgecolors[3][4] := "purple";;
335-
gap> edgecolors[4][1] := "lightblue";;
336-
gap> edgecolors[4][2] := "pink";;
337-
gap> edgecolors[4][3] := "purple";;
201+
gap> colors := ["lightblue", "pink", "purple"];;
202+
gap> edgecolors := ListWithIdenticalEntries(4, colors);;
338203
gap> Print(DotEdgeColoredDigraph(D, edgecolors));
339204
//dot
340205
digraph hgn{
@@ -356,8 +221,49 @@ node [shape=circle]
356221
4 -> 2[color=pink]
357222
4 -> 3[color=purple]
358223
}
359-
gap> FileString("dot/k4.dot", DotDigraph(gr));
360-
154]]></Log>
224+
gap> Print(DotColoredDigraph(D, vertcolors, edgecolors));
225+
//dot
226+
digraph hgn{
227+
node [shape=circle]
228+
1[color=blue, style=filled]
229+
2[color=green, style=filled]
230+
3[color=red, style=filled]
231+
4[color=yellow, style=filled]
232+
1 -> 2[color=lightblue]
233+
1 -> 3[color=pink]
234+
1 -> 4[color=purple]
235+
2 -> 1[color=lightblue]
236+
2 -> 3[color=pink]
237+
2 -> 4[color=purple]
238+
3 -> 1[color=lightblue]
239+
3 -> 2[color=pink]
240+
3 -> 4[color=purple]
241+
4 -> 1[color=lightblue]
242+
4 -> 2[color=pink]
243+
4 -> 3[color=purple]
244+
}
245+
gap> FileString("k4.dot", DotDigraph(D));
246+
133
247+
gap> D := Digraph([[2, 3], [1, 3], [1]]);
248+
<immutable digraph with 3 vertices, 5 edges>
249+
gap> vertcolors := ["blue", "red", "green"];;
250+
gap> edgecolors := [["orange", "yellow"], ["orange",
251+
> "pink"], ["yellow"]];;
252+
gap> Print(DotColoredDigraph(D, vertcolors, edgecolors));
253+
//dot
254+
digraph hgn{
255+
node [shape=circle]
256+
1[color=blue, style=filled]
257+
2[color=red, style=filled]
258+
3[color=green, style=filled]
259+
1 -> 2[color=orange]
260+
1 -> 3[color=yellow]
261+
2 -> 1[color=orange]
262+
2 -> 3[color=pink]
263+
3 -> 1[color=yellow]
264+
}
265+
gap> FileString("digraph.dot", DotDigraph(D));
266+
82]]></Example>
361267
</Description>
362268
</ManSection>
363269
<#/GAPDoc>
@@ -416,23 +322,14 @@ gap> FileString("dot/k4.dot", DotDigraph(gr));
416322
The string returned by <C>DotSymmetricDigraph</C> can be written to a
417323
file using the command <Ref Func="FileString" BookName="GAPDoc"/>.<P/>
418324

419-
<Log><![CDATA[
420-
gap> star := Digraph([[2, 2, 3, 4], [1, 1], [1], [1, 4]]);
421-
<immutable multidigraph with 4 vertices, 9 edges>
422-
gap> IsSymmetricDigraph(star);
423-
true
424-
gap> FileString("dot/star.dot", DotSymmetricDigraph(gr));
325+
<Example><![CDATA[
326+
425327
gap> D := Digraph([[2], [1, 3], [2]]);
426328
<immutable digraph with 3 vertices, 4 edges>
427-
gap> vertcolors := [];;
428-
gap> vertcolors[1] := "blue";;
429-
gap> vertcolors[2] := "pink";;
430-
gap> vertcolors[3] := "purple";;
431-
gap> edgecolors := [];;
432-
gap> edgecolors[1] := [];; edgecolors[2] := [];;
433-
gap> edgecolors[3] := [];;
434-
gap> edgecolors[1][2] := "green";; edgecolors[2][1] := "green";;
435-
gap> edgecolors[2][3] := "red";; edgecolors[3][2] := "red";;
329+
gap> IsSymmetricDigraph(D);
330+
true
331+
gap> vertcolors := ["blue", "pink", "purple"];;
332+
gap> edgecolors := [["green"], ["green", "red"], ["red"]];;
436333
gap> Print(DotSymmetricColoredDigraph(D, vertcolors, edgecolors));
437334
//dot
438335
graph hgn{
@@ -444,12 +341,6 @@ node [shape=circle]
444341
1 -- 2[color=green]
445342
2 -- 3[color=red]
446343
}
447-
gap> D := Digraph([[2], [1, 3], [2]]);
448-
<immutable digraph with 3 vertices, 4 edges>
449-
gap> vertcolors := [];;
450-
gap> vertcolors[1] := "blue";;
451-
gap> vertcolors[2] := "pink";;
452-
gap> vertcolors[3] := "purple";;
453344
gap> Print(DotSymmetricVertexColoredDigraph(D, vertcolors));
454345
//dot
455346
graph hgn{
@@ -461,13 +352,7 @@ node [shape=circle]
461352
1 -- 2
462353
2 -- 3
463354
}
464-
gap> D := Digraph([[2], [1, 3], [2]]);
465-
<immutable digraph with 3 vertices, 4 edges>
466-
gap> edgecolors := [];;
467-
gap> edgecolors[1] := [];; edgecolors[2] := [];;
468-
gap> edgecolors[3] := [];;
469-
gap> edgecolors[1][2] := "green";; edgecolors[2][1] := "green";;
470-
gap> edgecolors[2][3] := "red";; edgecolors[3][2] := "red";;
355+
471356
gap> Print(DotSymmetricEdgeColoredDigraph(D, edgecolors));
472357
//dot
473358
graph hgn{
@@ -479,7 +364,7 @@ node [shape=circle]
479364
1 -- 2[color=green]
480365
2 -- 3[color=red]
481366
}
482-
83]]></Log>
367+
]]></Example>
483368
</Description>
484369
</ManSection>
485370
<#/GAPDoc>
@@ -507,12 +392,13 @@ node [shape=circle]
507392
The string returned by <C>DotPartialOrderDigraph</C> can be written to a
508393
file using the command <Ref Func="FileString" BookName="GAPDoc"/>.<P/>
509394

510-
<Log><![CDATA[
511-
gap> poset := Digraph([[1, 4], [2], [2, 3, 4], [4]);
512-
gap> IsPartialOrderDigraph(gr);
395+
<Example><![CDATA[
396+
gap> poset := Digraph([[1, 4], [2], [2, 3, 4], [4]]);
397+
<immutable digraph with 4 vertices, 7 edges>
398+
gap> IsPartialOrderDigraph(poset);
513399
true
514-
gap> FileString("dot/poset.dot", DotPartialOrderDigraph(gr));
515-
83]]></Log>
400+
gap> FileString("poset.dot", DotPartialOrderDigraph(poset));
401+
70]]></Example>
516402
</Description>
517403
</ManSection>
518404
<#/GAPDoc>
@@ -548,12 +434,14 @@ gap> FileString("dot/poset.dot", DotPartialOrderDigraph(gr));
548434
The string returned by <C>DotPreorderDigraph</C> can be written to a
549435
file using the command <Ref Func="FileString" BookName="GAPDoc"/>.<P/>
550436

551-
<Log><![CDATA[
552-
gap> preset := Digraph([[1, 2, 4, 5], [1, 2, 4, 5], [3, 4], [4], [1, 2, 4, 5]);
553-
gap> IsPreorderDigraph(gr);
437+
<Example><![CDATA[
438+
gap> preset := Digraph([[1, 2, 4, 5], [1, 2, 4, 5], [3, 4], [4],
439+
> [1, 2, 4, 5]]);
440+
<immutable digraph with 5 vertices, 15 edges>
441+
gap> IsPreorderDigraph(preset);
554442
true
555-
gap> FileString("dot/preset.dot", DotProrderDigraph(gr));
556-
83]]></Log>
443+
gap> FileString("preset.dot", DotPreorderDigraph(preset));
444+
179]]></Example>
557445
</Description>
558446
</ManSection>
559447
<#/GAPDoc>
@@ -576,12 +464,12 @@ gap> FileString("dot/preset.dot", DotProrderDigraph(gr));
576464

577465
See <Ref Attr="DotDigraph"/> for more details on the output.<P/>
578466

579-
<Log><![CDATA[
467+
<Example><![CDATA[
580468
gap> digraph := Digraph([[2, 3], [2], [1, 3]]);
581-
<digraph with 3 vertices, 5 edges>
582-
gap> FileString("dot/my_digraph.dot",
583-
> DotHighlightedDigraph(digraph, [1, 2], "red", "black"));
584-
264]]></Log>
469+
<immutable digraph with 3 vertices, 5 edges>
470+
gap> FileString("my_digraph.dot", DotHighlightedDigraph(digraph,
471+
> [1, 2], "red", "black"));
472+
264]]></Example>
585473
</Description>
586474
</ManSection>
587475
<#/GAPDoc>

0 commit comments

Comments
 (0)