Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added IsOrderFilter #707

Merged
merged 6 commits into from
Nov 27, 2024
Merged
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
29 changes: 25 additions & 4 deletions doc/oper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2414,14 +2414,12 @@ gap> List(res[2][3]);
order defined by <A>D</A>. The function can only be used on digraphs
satisfying <Ref Prop="IsPartialOrderDigraph"/> and will throw an error if
passed a digraph that is not a partial order digraph.

<Example><![CDATA[
gap> D1 := Digraph([[1, 3], [2, 3], [3]]);
<immutable digraph with 3 vertices, 5 edges>
<immutable digraph with 3 vertices, 5 edges>
gap> IsOrderIdeal(D, [1, 2, 3]);
gap> IsOrderIdeal(D1, [1, 2, 3]);
true
gap> D2 := DigraphDisjointUnion(D, D);
gap> D2 := DigraphDisjointUnion(D1, D1);
<immutable digraph with 6 vertices, 10 edges>
gap> IsOrderIdeal(D2, [1, 2, 3]);
true
Expand All @@ -2432,6 +2430,29 @@ false
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>

<#GAPDoc Label="IsOrderFilter">
<ManSection>
<Oper Name="IsOrderFilter" Arg="D, subset" Label="for a digraph and a list"/>
<Returns> <K>true</K> or <K>false</K>.</Returns>
<Description>
This function returns <K>true</K> if the specified subset is upwards
closed. A subset is upwards closed if it contains every vertex greater than the given vertices in the
order defined by <A>D</A>. The function can only be used on digraphs
satisfying <Ref Prop="IsPartialOrderDigraph"/> and will throw an error if
passed a digraph that is not a partial order digraph.
<Example><![CDATA[gap> D1 := DigraphByEdges(
> [[1, 2], [2, 3], [1, 3], [1, 1], [2, 2], [3, 3]]);
<immutable digraph with 3 vertices, 6 edges>
gap> IsOrderFilter(D1, [2, 3]);
false
gap> IsOrderFilter(D1, [1, 2]);
true]]>
</Example>
</Description>
</ManSection>
<#/GAPDoc>

<#GAPDoc Label="DIGRAPHS_FREE_HOMOS_DATA">
<Oper Name="DIGRAPHS_FREE_HOMOS_DATA"/>
Expand Down
2 changes: 2 additions & 0 deletions doc/z-chap5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
<#Include Label="IsPartialOrderDigraph">
<#Include Label="IsMeetSemilatticeDigraph">
<#Include Label="DigraphMeetTable">
<#Include Label="IsOrderIdeal">
<#Include Label="IsOrderFilter">
<#Include Label="IsUpperSemimodularDigraph">
<#Include Label="IsDistributiveLatticeDigraph">
<#Include Label="IsModularLatticeDigraph">
Expand Down
1 change: 1 addition & 0 deletions gap/oper.gd
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ DeclareOperation("DigraphShortestPathSpanningTree", [IsDigraph, IsPosInt]);
DeclareOperation("VerticesReachableFrom", [IsDigraph, IsPosInt]);
DeclareOperation("VerticesReachableFrom", [IsDigraph, IsList]);
DeclareOperation("IsOrderIdeal", [IsDigraph, IsList]);
DeclareOperation("IsOrderFilter", [IsDigraph, IsList]);
DeclareOperation("Dominators", [IsDigraph, IsPosInt]);
DeclareOperation("DominatorTree", [IsDigraph, IsPosInt]);
DeclareOperation("DigraphCycleBasis", [IsDigraph]);
Expand Down
8 changes: 6 additions & 2 deletions gap/oper.gi
Original file line number Diff line number Diff line change
Expand Up @@ -2312,6 +2312,10 @@ function(D, roots)

end);

InstallMethod(IsOrderFilter, "for a digraph and a list of vertices",
[IsDigraph, IsList],
{D, roots} -> IsOrderIdeal(DigraphReverse(D), roots));

InstallMethod(DominatorTree, "for a digraph and a vertex",
[IsDigraph, IsPosInt],
function(D, root)
Expand Down Expand Up @@ -2543,8 +2547,8 @@ function(G)
c := Length(unusedEdges);

# Warning for large matrix
# The warning is printed roughly when the result matrix will take up
# more than 8GB of RAM.
# The warning is printed roughly when the result matrix will
# take up more than 8GB of RAM.
if (10 ^ 11) / 2 < m * c then
Info(InfoWarning, 1, StringFormatted(
"The resulting matrix is going to be large of size {} \x {} ",
Expand Down
21 changes: 21 additions & 0 deletions tst/standard/oper.tst
Original file line number Diff line number Diff line change
Expand Up @@ -2843,6 +2843,27 @@ gap> D := CycleDigraph(5);;
gap> IsOrderIdeal(D, [1]);
Error, the 1st argument (a digraph) must be a partial order digraph

# IsOrderFilter
gap> D := DigraphByEdges([[1, 1], [1, 2], [1, 3], [2, 3], [3, 3], [2, 2], [2, 4], [4, 4], [1, 4]]);
<immutable digraph with 4 vertices, 9 edges>
gap> IsOrderFilter(D, [1, 2]);
true
gap> IsOrderFilter(D, [2, 3]);
false
gap> IsOrderFilter(D, [1, 4]);
false
gap> IsOrderFilter(D, [4]);
false
gap> IsOrderFilter(4);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `IsOrderFilter' on 1 arguments
gap> IsOrderFilter(D, 4);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `IsOrderFilter' on 2 arguments
gap> IsOrderFilter(D, [5]);
Error, an element of the 2nd argument (roots) is not a vertex of the 1st argum\
ent (a digraph)

# DigraphCycleBasis
gap> D := NullDigraph(0);
<immutable empty digraph with 0 vertices>
Expand Down
Loading