@@ -22,9 +22,9 @@ gap> DIGRAPHS_StartTest();
2222
2323# create edge-weighted digraph
2424gap> d := EdgeWeightedDigraph([[ 2 ] , []] , [[ 5 ] , []] );
25- < immutable digraph with 2 vertices, 1 edge>
25+ < immutable edge - weighted digraph with 2 vertices, 1 edge>
2626gap> d := EdgeWeightedDigraph(Digraph([[ 2 ] , []] ), [[ 5 ] , []] );
27- < immutable digraph with 2 vertices, 1 edge>
27+ < immutable edge - weighted digraph with 2 vertices, 1 edge>
2828gap> EdgeWeightedDigraphTotalWeight(d);
29295
3030
@@ -71,7 +71,7 @@ Error, the number of out-neighbours and weights for the vertex 1 must be equal\
7171
7272# changing edge weights mutable copy
7373gap> d := EdgeWeightedDigraph([[ 2 ] , [ 1 ]] , [[ 5 ] , [ 10 ]] );
74- < immutable digraph with 2 vertices, 2 edges>
74+ < immutable edge - weighted digraph with 2 vertices, 2 edges>
7575gap> m := EdgeWeightsMutableCopy(d);
7676[ [ 5 ] , [ 10 ] ]
7777gap> m[ 1 ] := [ 25 ] ;
@@ -89,11 +89,11 @@ Error, List Assignment: <list> must be a mutable list
8989
9090# negative edge weights
9191gap> d := EdgeWeightedDigraph([[ 2 ] , [ 1 ]] , [[ 5 ] , [ 10 ]] );
92- < immutable digraph with 2 vertices, 2 edges>
92+ < immutable edge - weighted digraph with 2 vertices, 2 edges>
9393gap> IsNegativeEdgeWeightedDigraph(d);
9494false
9595gap> d := EdgeWeightedDigraph([[ 2 ] , [ 1 ]] , [[ - 5 ] , [ 10 ]] );
96- < immutable digraph with 2 vertices, 2 edges>
96+ < immutable edge - weighted digraph with 2 vertices, 2 edges>
9797gap> IsNegativeEdgeWeightedDigraph(d);
9898true
9999
@@ -103,57 +103,57 @@ true
103103
104104# not connnected digraph
105105gap> d := EdgeWeightedDigraph([[ 1 ] , [ 2 ]] , [[ 5 ] , [ 10 ]] );
106- < immutable digraph with 2 vertices, 2 edges>
106+ < immutable edge - weighted digraph with 2 vertices, 2 edges>
107107gap> EdgeWeightedDigraphMinimumSpanningTree(d);
108108Error, the argument < D> must be a connected digraph,
109109
110110# digraph with one node
111111gap> d := EdgeWeightedDigraph([[]] , [[]] );
112- < immutable empty digraph with 1 vertex>
112+ < immutable empty edge - weighted digraph with 1 vertex>
113113gap> tree := EdgeWeightedDigraphMinimumSpanningTree(d);
114- < immutable empty digraph with 1 vertex>
114+ < immutable empty edge - weighted digraph with 1 vertex>
115115gap> EdgeWeightedDigraphTotalWeight(tree);
1161160
117117
118118# digraph with loop
119119gap> d := EdgeWeightedDigraph([[ 1 ]] , [[ 5 ]] );
120- < immutable digraph with 1 vertex, 1 edge>
120+ < immutable edge - weighted digraph with 1 vertex, 1 edge>
121121gap> EdgeWeightedDigraphMinimumSpanningTree(d);
122- < immutable empty digraph with 1 vertex>
122+ < immutable empty edge - weighted digraph with 1 vertex>
123123
124124# digraph with cycle
125125gap> d := EdgeWeightedDigraph([[ 2 ] , [ 3 ] , [ 1 ]] , [[ 5 ] , [ 10 ] , [ 15 ]] );
126- < immutable digraph with 3 vertices, 3 edges>
126+ < immutable edge - weighted digraph with 3 vertices, 3 edges>
127127gap> tree := EdgeWeightedDigraphMinimumSpanningTree(d);
128- < immutable digraph with 3 vertices, 2 edges>
128+ < immutable edge - weighted digraph with 3 vertices, 2 edges>
129129gap> EdgeWeightedDigraphTotalWeight(tree);
13013015
131131
132132# digraph with negative edge
133133gap> d := EdgeWeightedDigraph([[ 2 ] , []] , [[ - 5 ] , []] );
134- < immutable digraph with 2 vertices, 1 edge>
134+ < immutable edge - weighted digraph with 2 vertices, 1 edge>
135135gap> EdgeWeightedDigraphMinimumSpanningTree(d);
136- < immutable digraph with 2 vertices, 1 edge>
136+ < immutable edge - weighted digraph with 2 vertices, 1 edge>
137137
138138# digraph with negative cycle
139139gap> d := EdgeWeightedDigraph([[ 2 ] , [ 3 ] , [ 1 ]] , [[ - 5 ] , [ - 10 ] , [ - 15 ]] );
140- < immutable digraph with 3 vertices, 3 edges>
140+ < immutable edge - weighted digraph with 3 vertices, 3 edges>
141141gap> EdgeWeightedDigraphMinimumSpanningTree(d);
142- < immutable digraph with 3 vertices, 2 edges>
142+ < immutable edge - weighted digraph with 3 vertices, 2 edges>
143143
144144# digraph with parallel edges
145145gap> d := EdgeWeightedDigraph([[ 2 , 2 , 2 ] , [ 1 ]] , [[ 10 , 5 , 15 ] , [ 7 ]] );
146- < immutable multidigraph with 2 vertices, 4 edges>
146+ < immutable edge - weighted multidigraph with 2 vertices, 4 edges>
147147gap> EdgeWeightedDigraphMinimumSpanningTree(d);
148- < immutable digraph with 2 vertices, 1 edge>
148+ < immutable edge - weighted digraph with 2 vertices, 1 edge>
149149
150150# ############################################################################
151151# 4. Shortest Path
152152# ############################################################################
153153
154154# Shortest paths: one node
155155gap> d := EdgeWeightedDigraph([[]] , [[]] );
156- < immutable empty digraph with 1 vertex>
156+ < immutable empty edge - weighted digraph with 1 vertex>
157157gap> EdgeWeightedDigraphShortestPaths(d, 1 );
158158rec ( distances := [ 0 ] , edges := [ fail ] , parents := [ fail ] )
159159
@@ -165,52 +165,52 @@ rec( distances := [ 0, fail ], edges := [ fail, fail ],
165165
166166# Shortest paths: one node and loop
167167gap> d := EdgeWeightedDigraph([[ 1 ]] , [[ 5 ]] );
168- < immutable digraph with 1 vertex, 1 edge>
168+ < immutable edge - weighted digraph with 1 vertex, 1 edge>
169169gap> EdgeWeightedDigraphShortestPaths(d, 1 );
170170rec ( distances := [ 0 ] , edges := [ fail ] , parents := [ fail ] )
171171
172172# Shortest paths: two nodes and loop on second node
173173gap> d := EdgeWeightedDigraph([[ 2 ] , [ 1 , 2 ]] , [[ 5 ] , [ 5 , 5 ]] );
174- < immutable digraph with 2 vertices, 3 edges>
174+ < immutable edge - weighted digraph with 2 vertices, 3 edges>
175175gap> EdgeWeightedDigraphShortestPaths(d, 1 );
176176rec ( distances := [ 0 , 5 ] , edges := [ fail , 1 ] , parents := [ fail , 1 ] )
177177
178178# Shortest paths: cycle
179179gap> d := EdgeWeightedDigraph([[ 2 ] , [ 3 ] , [ 1 ]] , [[ 2 ] , [ 3 ] , [ 4 ]] );
180- < immutable digraph with 3 vertices, 3 edges>
180+ < immutable edge - weighted digraph with 3 vertices, 3 edges>
181181gap> EdgeWeightedDigraphShortestPaths(d, 1 );
182182rec ( distances := [ 0 , 2 , 5 ] , edges := [ fail , 1 , 1 ] ,
183183 parents := [ fail , 1 , 2 ] )
184184
185185# Shortest paths: parallel edges
186186gap> d := EdgeWeightedDigraph([[ 2 , 2 , 2 ] , [ 1 ]] , [[ 10 , 5 , 15 ] , [ 7 ]] );
187- < immutable multidigraph with 2 vertices, 4 edges>
187+ < immutable edge - weighted multidigraph with 2 vertices, 4 edges>
188188gap> EdgeWeightedDigraphShortestPaths(d, 1 );
189189rec ( distances := [ 0 , 5 ] , edges := [ fail , 2 ] , parents := [ fail , 1 ] )
190190
191191# Shortest paths: negative edges
192192gap> d := EdgeWeightedDigraph([[ 2 ] , [ 1 ]] , [[ - 2 ] , [ 7 ]] );
193- < immutable digraph with 2 vertices, 2 edges>
193+ < immutable edge - weighted digraph with 2 vertices, 2 edges>
194194gap> EdgeWeightedDigraphShortestPaths(d, 1 );
195195rec ( distances := [ 0 , - 2 ] , edges := [ fail , 1 ] , parents := [ fail , 1 ] )
196196
197197# Shortest paths: parallel negative edges
198198gap> d := EdgeWeightedDigraph([[ 2 , 2 , 2 ] , [ 1 ]] , [[ - 2 , - 3 , - 4 ] , [ 7 ]] );
199- < immutable multidigraph with 2 vertices, 4 edges>
199+ < immutable edge - weighted multidigraph with 2 vertices, 4 edges>
200200gap> EdgeWeightedDigraphShortestPaths(d, 1 );
201201rec ( distances := [ 0 , - 4 ] , edges := [ fail , 3 ] , parents := [ fail , 1 ] )
202202
203203# Shortest paths: negative cycle
204204gap> d := EdgeWeightedDigraph([[ 2 , 2 , 2 ] , [ 1 ]] , [[ - 10 , 5 , - 15 ] , [ 7 ]] );
205- < immutable multidigraph with 2 vertices, 4 edges>
205+ < immutable edge - weighted multidigraph with 2 vertices, 4 edges>
206206gap> EdgeWeightedDigraphShortestPaths(d, 1 );
207207Error, no method found! For debugging hints type ?Recovery from NoMethodFound
208208Error, no 2nd choice method found for `EdgeWeightedDigraphShortestPaths' on 2 \
209209arguments
210210
211211# Shortest paths: source not in graph
212212gap> d := EdgeWeightedDigraph([[2], [1]], [[2], [7]]);
213- <immutable digraph with 2 vertices, 2 edges>
213+ <immutable edge-weighted digraph with 2 vertices, 2 edges>
214214gap> EdgeWeightedDigraphShortestPaths(d, 3);
215215Error, the 2nd argument <source> must be a vertex of the 1st argument <D>,
216216gap> EdgeWeightedDigraphShortestPath(d, 3, 1);
@@ -220,7 +220,7 @@ Error, the 3rd argument <dest> must be a vertex of the 1st argument <D>,
220220
221221# Shortest paths: no path exists
222222gap> d := EdgeWeightedDigraph([[1], [2]], [[5], [10]]);
223- <immutable digraph with 2 vertices, 2 edges>
223+ <immutable edge-weighted digraph with 2 vertices, 2 edges>
224224gap> EdgeWeightedDigraphShortestPaths(d, 1);
225225rec( distances := [ 0, fail ], edges := [ fail, fail ],
226226 parents := [ fail, fail ] )
229229
230230# Shortest paths: no path exists with negative edge weight
231231gap> d := EdgeWeightedDigraph([[2], [2], []], [[-5], [10], []]);
232- <immutable digraph with 3 vertices, 2 edges>
232+ <immutable edge-weighted digraph with 3 vertices, 2 edges>
233233gap> r := EdgeWeightedDigraphShortestPaths(d, 1);;
234234gap> r.distances = [0, -5, fail];
235235true
240240
241241# Shortest paths: parallel edges
242242gap> d := EdgeWeightedDigraph([[2, 2, 2], []], [[3, 2, 1], []]);
243- <immutable multidigraph with 2 vertices, 3 edges>
243+ <immutable edge-weighted multidigraph with 2 vertices, 3 edges>
244244gap> EdgeWeightedDigraphShortestPaths(d, 1);
245245rec( distances := [ 0, 1 ], edges := [ fail, 3 ], parents := [ fail, 1 ] )
246246gap> EdgeWeightedDigraphShortestPaths(d);
@@ -252,7 +252,7 @@ gap> EdgeWeightedDigraphShortestPath(d, 1, 2);
252252
253253# Shortest paths: negative cycle
254254gap> d := EdgeWeightedDigraph([[2], [3], [1]], [[-3], [-5], [-7]]);
255- <immutable digraph with 3 vertices, 3 edges>
255+ <immutable edge-weighted digraph with 3 vertices, 3 edges>
256256gap> EdgeWeightedDigraphShortestPaths(d);
257257Error, no method found! For debugging hints type ?Recovery from NoMethodFound
258258Error, no 2nd choice method found for `EdgeWeightedDigraphShortestPaths' on 1 \
271271
272272# Shortest paths: Johnson
273273gap> d := EdgeWeightedDigraph([[2], [3], [], [], []], [[3], [5], [], [], []]);
274- <immutable digraph with 5 vertices, 2 edges>
274+ <immutable edge-weighted digraph with 5 vertices, 2 edges>
275275gap> EdgeWeightedDigraphShortestPaths(d, 1);
276276rec( distances := [ 0, 3, 8, fail, fail ], edges := [ fail, 1, 1, fail, fail ]
277277 , parents := [ fail, 1, 2, fail, fail ] )
@@ -296,61 +296,61 @@ gap> EdgeWeightedDigraphShortestPath(d, 1, 3);
296296
297297# Maximum flow: empty digraphs
298298gap> d := EdgeWeightedDigraph([], []);
299- <immutable empty digraph with 0 vertices>
299+ <immutable empty edge-weighted digraph with 0 vertices>
300300gap> DigraphMaximumFlow(d, 1, 1);
301301Error, <start> must be a vertex of <D>,
302302
303303# Maximum flow: single vertex (also empty digraphs)
304304gap> d := EdgeWeightedDigraph([[]], [[]]);
305- <immutable empty digraph with 1 vertex>
305+ <immutable empty edge-weighted digraph with 1 vertex>
306306gap> DigraphMaximumFlow(d, 1, 1);
307307[ [ ] ]
308308
309309# Maximum flow: source = dest
310310gap> d := EdgeWeightedDigraph([[2], []], [[5], []]);
311- <immutable digraph with 2 vertices, 1 edge>
311+ <immutable edge-weighted digraph with 2 vertices, 1 edge>
312312gap> DigraphMaximumFlow(d, 1, 1);
313313[ [ 0 ], [ ] ]
314314
315315# Maximum flow: has loop
316316gap> d := EdgeWeightedDigraph([[1, 2], []], [[5, 10], []]);
317- <immutable digraph with 2 vertices, 2 edges>
317+ <immutable edge-weighted digraph with 2 vertices, 2 edges>
318318gap> DigraphMaximumFlow(d, 1, 2);
319319[ [ 0, 10 ], [ ] ]
320320
321321# Maximum flow: invalid source
322322gap> d := EdgeWeightedDigraph([[1, 2], []], [[5, 10], []]);
323- <immutable digraph with 2 vertices, 2 edges>
323+ <immutable edge-weighted digraph with 2 vertices, 2 edges>
324324gap> DigraphMaximumFlow(d, 5, 2);
325325Error, <start> must be a vertex of <D>,
326326
327327# Maximum flow: invalid sink
328328gap> d := EdgeWeightedDigraph([[1, 2], []], [[5, 10], []]);
329- <immutable digraph with 2 vertices, 2 edges>
329+ <immutable edge-weighted digraph with 2 vertices, 2 edges>
330330gap> DigraphMaximumFlow(d, 1, 5);
331331Error, <destination> must be a vertex of <D>,
332332
333333# Maximum flow: sink not reachable
334334gap> d := EdgeWeightedDigraph([[1], []], [[5], []]);
335- <immutable digraph with 2 vertices, 1 edge>
335+ <immutable edge-weighted digraph with 2 vertices, 1 edge>
336336gap> DigraphMaximumFlow(d, 1, 2);
337337[ [ 0 ], [ ] ]
338338
339339# Maximum flow: source has in neighbours
340340gap> d := EdgeWeightedDigraph([[2], [3], []], [[5], [10], []]);
341- <immutable digraph with 3 vertices, 2 edges>
341+ <immutable edge-weighted digraph with 3 vertices, 2 edges>
342342gap> DigraphMaximumFlow(d, 2, 3);
343343[ [ 0 ], [ 10 ], [ ] ]
344344
345345# Maximum flow: sink has out-neighbours
346346gap> d := EdgeWeightedDigraph([[2], [3], [2]], [[5], [10], [7]]);
347- <immutable digraph with 3 vertices, 3 edges>
347+ <immutable edge-weighted digraph with 3 vertices, 3 edges>
348348gap> DigraphMaximumFlow(d, 2, 3);
349349[ [ 0 ], [ 10 ], [ 0 ] ]
350350
351351# Maximum flow: cycle
352352gap> d := EdgeWeightedDigraph([[2], [3], [1]], [[5], [10], [7]]);
353- <immutable digraph with 3 vertices, 3 edges>
353+ <immutable edge-weighted digraph with 3 vertices, 3 edges>
354354gap> DigraphMaximumFlow(d, 1, 3);
355355[ [ 5 ], [ 5 ], [ 0 ] ]
356356
0 commit comments