Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions doc/digraph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ gap> List(D, Size);

<#GAPDoc Label="RandomDigraph">
<ManSection>
<Oper Name="RandomDigraph" Arg="[filt, ]n[, p]"/>
<Oper Name="RandomDigraph" Arg="[filt, ][rs, ]n[, p]"/>
<Returns>A digraph.</Returns>
<Description>
&STANDARD_FILT_TEXT;
Expand All @@ -788,12 +788,18 @@ gap> List(D, Size);
For <Ref Filt='IsAcyclicDigraph'/> and <Ref Filt='IsSymmetricDigraph'/>, edges are added between any
pairs of vertices with probability approximately <A>p</A>.<P/>

If the optional second argument <A>rs</A> is a random source (see <Ref Sect="Random Sources"/>) then it
is used to generate the random choices made when creating the digraph. If <A>rs<A/> is not specified, then the
global random source <C>GlobalMersenneTwister<C/> is used. Two calls with the same arguments and random sources
in the same state return the same digraph, which makes it possible to reproduce a random digraph by resetting the
random source. <P/>

If <A>n</A> is a positive integer, then this function returns a random
digraph with <A>n</A> vertices and without multiple edges. The result
may or may not have loops. If using <Ref Filt='IsAcyclicDigraph'/>, the resulting graph
will not have any loops by definition.<P/>

If the optional second argument <A>p</A> is a float with value
If the optional fourth argument <A>p</A> is a float with value
<M>0 \leq </M> <A> p </A> <M> \leq 1</M>, then an edge will exist between each
pair of vertices with probability approximately <A>p</A>.
If <A>p</A> is not specified, then a random probability will be assumed
Expand All @@ -803,6 +809,14 @@ gap> RandomDigraph(1000);
<immutable digraph with 1000 vertices, 364444 edges>
gap> RandomDigraph(10000, 0.023);
<immutable digraph with 10000 vertices, 2300438 edges>
gap> RandomDigraph(GlobalMersenneTwister, 1000);
<immutable digraph with 1000 vertices, 529323 edges>
gap> RandomDigraph(IsMutableDigraph, GlobalMersenneTwister, 1000);
<mutable digraph with 1000 vertices, 438926 edges>
gap> RandomDigraph(IsMutableDigraph, GlobalMersenneTwister, 1000, 1/2);
<mutable digraph with 1000 vertices, 501219 edges>
gap> RandomDigraph(IsMutableDigraph, GlobalMersenneTwister, 1000, 0.5);
<mutable digraph with 1000 vertices, 499943 edges>
gap> RandomDigraph(IsMutableDigraph, 1000, 1 / 2);
<mutable digraph with 1000 vertices, 499739 edges>
gap> RandomDigraph(IsConnectedDigraph, 1000, 0.75);
Expand Down
19 changes: 17 additions & 2 deletions gap/digraph.gd
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,32 @@ DeclareOperation("AsMonoid", [IsFunction, IsDigraph]);
DeclareOperation("AsSemigroup",
[IsFunction, IsDigraph, IsDenseList, IsDenseList]);

# 10. Random digraphs . . .
# 10. ``Random digraphs . . .
DeclareOperation("RandomDigraphOutNeighbours", [IsInt, IsFloat]);
DeclareOperation("RandomDigraphOutNeighbours",
[IsRandomSource, IsInt, IsFloat]);

DeclareConstructor("RandomDigraphCons", [IsDigraph, IsInt]);
DeclareConstructor("RandomDigraphCons", [IsDigraph, IsInt, IsRat]);
DeclareConstructor("RandomDigraphCons", [IsDigraph, IsInt, IsFloat]);
DeclareConstructor("RandomDigraphCons", [IsDigraph, IsRandomSource, IsInt]);
DeclareConstructor("RandomDigraphCons",
[IsDigraph, IsRandomSource, IsInt, IsRat]);
DeclareConstructor("RandomDigraphCons",
[IsDigraph, IsRandomSource, IsInt, IsFloat]);

DeclareOperation("RandomDigraph", [IsInt]);
DeclareOperation("RandomDigraph", [IsInt, IsRat]);
DeclareOperation("RandomDigraph", [IsInt, IsFloat]);
DeclareOperation("RandomDigraph", [IsFunction, IsInt]);
DeclareOperation("RandomDigraph", [IsRandomSource, IsInt]);
DeclareOperation("RandomDigraph", [IsRandomSource, IsInt, IsRat]);
DeclareOperation("RandomDigraph", [IsRandomSource, IsInt, IsFloat]);
DeclareOperation("RandomDigraph", [IsFunction, IsInt]);
DeclareOperation("RandomDigraph", [IsFunction, IsInt, IsRat]);
DeclareOperation("RandomDigraph", [IsFunction, IsInt, IsFloat]);
DeclareOperation("RandomDigraph", [IsFunction, IsRandomSource, IsInt]);
DeclareOperation("RandomDigraph", [IsFunction, IsRandomSource, IsInt, IsRat]);
DeclareOperation("RandomDigraph", [IsFunction, IsRandomSource, IsInt, IsFloat]);

DeclareConstructor("RandomTournamentCons", [IsDigraph, IsInt]);
DeclareOperation("RandomTournament", [IsInt]);
Expand Down
Loading
Loading