Skip to content

Commit f10e594

Browse files
committed
Merge branch 'amalgamDigraphs' of github.com:finnbuck/Digraphs into amalgamDigraphs
2 parents 781dcb9 + 53716a0 commit f10e594

File tree

15 files changed

+144
-32
lines changed

15 files changed

+144
-32
lines changed

.VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.5.0
1+
1.5.2

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
# CHANGELOG – Digraphs package for GAP
2-
Copyright © 2014-21 by Jan De Beule, Julius Jonušas, James D. Mitchell,
2+
Copyright © 2014-22 by Jan De Beule, Julius Jonušas, James D. Mitchell,
33
Wilf A. Wilson, Michael Young et al.
44

55
Licensing information can be found in the `LICENSE` file.
66

7+
## Version 1.5.2 (released 30/03/2022)
8+
9+
This is a very minor release containing technical changes for maintaining compatibility with other GAP packages.
10+
11+
## Version 1.5.1 (released 29/03/2022)
12+
13+
This minor release contains several bugfixes and technical changes. This includes:
14+
15+
* Bugfix: vertex labels are no longer wrongly retained when using `DigraphEdgeUnion`. This was reported by [Wilf A. Wilson][] in [Issue #496](https://github.com/digraphs/Digraphs/issues/496) and fixed by Joseph Edwards in [PR #507](https://github.com/digraphs/Digraphs/pull/507).
16+
* Bugfix: a segfault could be caused by calling `OutNeighbours` with an inappropriate argument. This was reported by [Wilf A. Wilson][] in [Issue #518](https://github.com/digraphs/Digraphs/issues/518) and fixed by [James D. Mitchell][] in [PR #519](https://github.com/digraphs/Digraphs/pull/519).
17+
* [Wilf A. Wilson][] improved the performance of `DigraphAddEdge` for digraphs without edge labels in [PR #509](https://github.com/digraphs/Digraphs/pull/509).
18+
* [Max Horn][] changed the declaration of the variable `Vertices` to improve compatibility with Grape in [PR #530](https://github.com/digraphs/Digraphs/pull/530).
19+
720
## Version 1.5.0 (released 27/10/2021)
821

922
This is a fairly major release of the Digraphs package, containing some bugfixes and several new features.

PackageInfo.g

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
#############################################################################
22
##
33
## PackageInfo.g
4-
## Copyright (C) 2015-21 James D. Mitchell
4+
## Copyright (C) 2015-22 James D. Mitchell
55
##
66
## Licensing information can be found in the README.md file of this package.
77
##
88
#############################################################################
99
##
1010

1111
## <#GAPDoc Label="PKGVERSIONDATA">
12-
## <!ENTITY VERSION "1.5.0">
12+
## <!ENTITY VERSION "1.5.2">
1313
## <!ENTITY GAPVERS "4.10.0">
1414
## <!ENTITY GRAPEVERS "4.8.1">
1515
## <!ENTITY IOVERS "4.5.1">
1616
## <!ENTITY ORBVERS "4.8.2">
1717
## <!ENTITY DATASTRUCTURESVERS "0.2.5">
1818
## <!ENTITY NAUTYTRACESINTERFACEVERS "0.2">
19-
## <!ENTITY ARCHIVENAME "digraphs-1.5.0">
20-
## <!ENTITY COPYRIGHTYEARS "2014-21">
19+
## <!ENTITY ARCHIVENAME "digraphs-1.5.2">
20+
## <!ENTITY COPYRIGHTYEARS "2014-22">
2121
## <#/GAPDoc>
2222

2323
_STANDREWSMATHS := Concatenation(["Mathematical Institute, North Haugh, ",
@@ -28,8 +28,8 @@ _STANDREWSCS := Concatenation(["Jack Cole Building, North Haugh, ",
2828
SetPackageInfo(rec(
2929
PackageName := "Digraphs",
3030
Subtitle := "Graphs, digraphs, and multidigraphs in GAP",
31-
Version := "1.5.0",
32-
Date := "27/10/2021", # dd/mm/yyyy format
31+
Version := "1.5.2",
32+
Date := "30/03/2022", # dd/mm/yyyy format
3333
License := "GPL-3.0-or-later",
3434
ArchiveFormats := ".tar.gz",
3535

VERSIONS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
#############################################################################
22
##
33
#W VERSIONS
4-
#Y Copyright (C) 2015-21 James D. Mitchell
4+
#Y Copyright (C) 2015-22 James D. Mitchell
55
##
66
## Licensing information can be found in the README.md file of this package.
77
##
88
#############################################################################
99
##
1010

11+
release 1.5.2 - 30/03/2022
12+
release 1.5.1 - 29/03/2022
1113
release 1.5.0 - 27/10/2021
1214
release 1.4.1 - 14/05/2021
1315
release 1.4.0 - 27/01/2021

doc/oper.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,36 @@ gap> DigraphShortestPath(D, 1, 1);
15351535
</ManSection>
15361536
<#/GAPDoc>
15371537

1538+
<#GAPDoc Label="DigraphRandomWalk">
1539+
<ManSection>
1540+
<Oper Name="DigraphRandomWalk" Arg="digraph, v, t"/>
1541+
<Returns>A pair of lists.</Returns>
1542+
<Description>
1543+
Returns a directed path corresponding to a <E>random walk</E> in the digraph
1544+
<A>digraph</A>, starting at vertex <A>v</A> and having length no more than
1545+
<A>t</A>.
1546+
<P/>
1547+
1548+
A random walk is defined as follows. The path begins at <A>v</A>, and at
1549+
each step it follows a random edge leaving the current vertex. It continues
1550+
through the digraph in this way until it has traversed <A>t</A> edges, or
1551+
until it reaches a vertex with no out-edges (a <E>sink</E>) and therefore
1552+
cannot continue.
1553+
<P/>
1554+
1555+
The output has the same form as that of <Ref Oper="DigraphPath"/>.
1556+
<P/>
1557+
1558+
<Log><![CDATA[
1559+
gap> D := Digraph([[1, 2], [3], [2, 4], [1], [2, 4]]);
1560+
<immutable digraph with 5 vertices, 8 edges>
1561+
gap> DigraphRandomWalk(D, 1, 4);
1562+
[ [ 1, 2, 3, 2, 3 ], [ 2, 1, 1, 1 ] ]
1563+
]]></Log>
1564+
</Description>
1565+
</ManSection>
1566+
<#/GAPDoc>
1567+
15381568
<#GAPDoc Label="IteratorOfPaths">
15391569
<ManSection>
15401570
<Oper Name="IteratorOfPaths" Arg="digraph, u, v"/>

doc/z-chap4.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
<#Include Label="VerticesReachableFrom">
6969
<#Include Label="DigraphPath">
7070
<#Include Label="DigraphShortestPath">
71+
<#Include Label="DigraphRandomWalk">
7172
<#Include Label="Dominators">
7273
<#Include Label="DominatorTree">
7374
<#Include Label="IteratorOfPaths">

gap/grape.gi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function(D)
132132
"the Grape graph will have fewer\n#I edges than the original,");
133133
fi;
134134

135-
if not DIGRAPHS_IsGrapeLoaded then
135+
if not DIGRAPHS_IsGrapeLoaded() then
136136
Info(InfoWarning, 1, "Grape is not loaded,");
137137
fi;
138138

gap/oper.gd

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ DeclareOperation("LexicographicProduct", [IsDigraph, IsDigraph]);
4949
DeclareOperation("AmalgamDigraphs",
5050
[IsDigraph, IsDigraph, IsDigraph,
5151
IsTransformation, IsTransformation]);
52-
DeclareOperation("AmalgamDigraphs",
52+
DeclareOperation("AmalgamDigraphs",
5353
[IsDigraph, IsDigraph, IsDigraph, IsTransformation]);
54-
DeclareOperation("AmalgamDigraphs",
55-
[IsDigraph, IsDigraph, IsDigraph,]);
54+
DeclareOperation("AmalgamDigraphs",
55+
[IsDigraph, IsDigraph, IsDigraph]);
5656

5757
DeclareSynonym("DigraphModularProduct", ModularProduct);
5858
DeclareSynonym("DigraphStrongProduct", StrongProduct);
@@ -62,7 +62,7 @@ DeclareSynonym("DigraphLexicographicProduct", LexicographicProduct);
6262

6363
DeclareGlobalFunction("DIGRAPHS_CombinationOperProcessArgs");
6464
DeclareOperation("DIGRAPHS_GraphProduct", [IsDigraph, IsDigraph, IsFunction]);
65-
DeclareOperation("NOCHECKS_AmalgamDigraphs",
65+
DeclareOperation("NOCHECKS_AmalgamDigraphs",
6666
[IsDigraph, IsDigraph, IsDigraph,
6767
IsTransformation, IsTransformation]);
6868

@@ -135,6 +135,7 @@ DeclareOperation("IteratorOfPaths", [IsList, IsPosInt, IsPosInt]);
135135
DeclareOperation("IteratorOfPathsNC", [IsList, IsPosInt, IsPosInt]);
136136
DeclareOperation("IsReachable", [IsDigraph, IsPosInt, IsPosInt]);
137137
DeclareOperation("DigraphLongestDistanceFromVertex", [IsDigraph, IsPosInt]);
138+
DeclareOperation("DigraphRandomWalk", [IsDigraph, IsPosInt, IsInt]);
138139

139140
DeclareOperation("DigraphLayers", [IsDigraph, IsPosInt]);
140141
DeclareAttribute("DIGRAPHS_Layers", IsDigraph, "mutable");

gap/oper.gi

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ function(D1, D2, S, map1, map2)
802802

803803
n := DigraphNrVertices(D2) + DigraphNrVertices(D1) - DigraphNrVertices(S);
804804

805-
# 'map' is an embedding of D2 into the final output graph.
805+
# 'map' is an embedding of D2 into the final output graph.
806806
# The embedding of D1 into the final output graph is the identity mapping.
807807

808808
map := [1 .. n];
@@ -856,7 +856,7 @@ function(D1, D2, S, map1)
856856
if map2 = fail then
857857
ErrorNoReturn(
858858
"no embeddings could be found from the 3rd argument ",
859-
"(a digraph) to the 2nd argument (a digraph)");
859+
"(a digraph) to the 2nd argument (a digraph)");
860860
fi;
861861

862862
return NOCHECKS_AmalgamDigraphs(D1, D2, S, map1, map2);
@@ -890,7 +890,7 @@ function(D1, D2, S)
890890
if map2 = fail then
891891
ErrorNoReturn(
892892
"no embeddings could be found from the 3rd argument ",
893-
"(a digraph) to the 2nd argument (a digraph)");
893+
"(a digraph) to the 2nd argument (a digraph)");
894894
fi;
895895

896896
return NOCHECKS_AmalgamDigraphs(D1, D2, S, map1, map2);
@@ -1891,6 +1891,41 @@ function(D, v)
18911891
return dist;
18921892
end);
18931893

1894+
InstallMethod(DigraphRandomWalk,
1895+
"for a digraph, a pos int and a non-negative int",
1896+
[IsDigraph, IsPosInt, IsInt],
1897+
function(D, v, t)
1898+
local vertices, edge_indices, i, neighbours, index;
1899+
1900+
# Check input
1901+
if v > DigraphNrVertices(D) then
1902+
ErrorNoReturn("the 2nd argument <v> must be ",
1903+
"a vertex of the 1st argument <D>,");
1904+
elif t < 0 then
1905+
ErrorNoReturn("the 3rd argument <t> must be a non-negative int,");
1906+
fi;
1907+
1908+
# Prepare output lists
1909+
vertices := [v];
1910+
edge_indices := [];
1911+
1912+
# Iterate to desired length
1913+
for i in [1 .. t] do
1914+
neighbours := OutNeighboursOfVertex(D, v);
1915+
if IsEmpty(neighbours) then
1916+
break; # Sink: path ends here
1917+
fi;
1918+
# Follow a random edge
1919+
index := Random(1, Length(neighbours));
1920+
v := neighbours[index];
1921+
vertices[i + 1] := v;
1922+
edge_indices[i] := index;
1923+
od;
1924+
1925+
# Format matches that of DigraphPath
1926+
return [vertices, edge_indices];
1927+
end);
1928+
18941929
InstallMethod(DigraphLayers, "for a digraph, and a positive integer",
18951930
[IsDigraph, IsPosInt],
18961931
function(D, v)

init.g

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ if not IsBound(DIGRAPH_OUT_NBS) and
2525
fi;
2626

2727
BindGlobal("DIGRAPHS_IsGrapeLoaded",
28-
IsPackageMarkedForLoading("grape", "4.8.1"));
28+
{} -> IsPackageMarkedForLoading("grape", "4.8.1"));
2929

3030
# To avoid warnings when GRAPE is not loaded
3131
if not IsBound(IsGraph) then
3232
IsGraph := ReturnFalse;
3333
fi;
3434
if not IsBound(Vertices) then
35-
Vertices := IdFunc;
35+
DeclareOperation("Vertices", [IsRecord]);
3636
fi;
3737
if not IsBound(Adjacency) then
3838
Adjacency := IdFunc;

0 commit comments

Comments
 (0)