From 5a7ed702a4f9bf5b75a8b1127b9746dc41ff4fc6 Mon Sep 17 00:00:00 2001 From: Ed Scheinerman Date: Tue, 27 Aug 2024 13:38:59 -0400 Subject: [PATCH] x --- docs/build/.documenter-siteinfo.json | 2 +- docs/build/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/build/.documenter-siteinfo.json b/docs/build/.documenter-siteinfo.json index 25f54e0..9df2e42 100644 --- a/docs/build/.documenter-siteinfo.json +++ b/docs/build/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-08-27T13:11:08","documenter_version":"1.5.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-08-27T13:29:57","documenter_version":"1.5.0"}} \ No newline at end of file diff --git a/docs/build/index.html b/docs/build/index.html index 1c87ba3..e174f0c 100644 --- a/docs/build/index.html +++ b/docs/build/index.html @@ -228,4 +228,4 @@ Element 7 in a {16, 65} Int64 poset julia> subset_decode(integer(ans)) -{2,3}

Implementation

A Poset is a structure that contains a single data element: a DiGraph. Users should not be accessing this directly, but it may be useful to understand how posets are implemented. The directed graph is acyclic (including loopless) and transitively closed. This means if $a \to b$ is an edge and $b\to c$ is an edge, then $a \to c$ is also an edge. The advantage to this structure is that checking if $a \prec b$ in a poset is quick. There are two disadvantages.

First, the graph may be larger than needed. If we only kept cover edges (the transitive reduction of the digraph) we might have many fewer edges. For example, a linear order with $n$ elements has $\binom{n}{2} \sim n^2/2$ edges in the digraph that represents it, whereas there are only $n-1$ edges in the cover digraph. However, this savings is an extreme example. A poset with $n$ elements split into two antichains, with every element of the first antichain below every element of the second, has $n^2/4$ edges in either representation. So in either case, the representing digraph may have up to order $n^2$ edges.

Second, the computational cost of adding (or deleting) a relation is nontrivial. The add_relation! function first checks if the added relation would violate transitivity; this is speedy because we can add the relation $a \prec b$ so long as we don't have $b\prec a$ already in the poset. However, after the edge $(a,b)$ is inserted into the digraph, we execute transitiveclosure! and that takes some work. Adding several relations to the poset, one at a time, can be slow.

This can be greatly accelerated by using Posets.add_relations! but (as discussed above) this function can cause severe problems if not used carefully.

See Also

The extras folder includes additional code that may be useful in working with Posets. See the README in the extras directory.

Of note is extras/converter.jl that defines the function poset_converter that can be used to transform a Poset (defined in this module) to a SimplePoset (defined in the SimplePosets module).

+{2,3}

Implementation

A Poset is a structure that contains a single data element: a DiGraph. Users should not be accessing this directly, but it may be useful to understand how posets are implemented. The directed graph is acyclic (including loopless) and transitively closed. This means if $a \to b$ is an edge and $b\to c$ is an edge, then $a \to c$ is also an edge. The advantage to this structure is that checking if $a \prec b$ in a poset is quick. There are two disadvantages.

First, the graph may be larger than needed. If we only kept cover edges (the transitive reduction of the digraph) we might have many fewer edges. For example, a linear order with $n$ elements has $\binom{n}{2} \sim n^2/2$ edges in the digraph that represents it, whereas there are only $n-1$ edges in the cover digraph. However, this savings is an extreme example. A poset with $n$ elements split into two antichains, with every element of the first antichain below every element of the second, has $n^2/4$ edges in either representation. So in either case, the representing digraph may have up to order $n^2$ edges.

Second, the computational cost of adding (or deleting) a relation is nontrivial. The add_relation! function first checks if the added relation would violate transitivity; this is speedy because we can add the relation $a \prec b$ so long as we don't have $b\prec a$ already in the poset. However, after the edge $(a,b)$ is inserted into the digraph, we execute transitiveclosure! and that takes some work. Adding several relations to the poset, one at a time, can be slow.

This can be greatly accelerated by using Posets.add_relations! but (as discussed above) this function can cause severe problems if not used carefully.

See Also

The extras folder includes additional code that may be useful in working with Posets. See the README in the extras directory.

Of note is extras/converter.jl that defines the function poset_converter that can be used to transform a Poset (defined in this module) to a SimplePoset (defined in the SimplePosets module).