Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
scheinerman committed Aug 16, 2024
1 parent 2bec0dd commit d936f55
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,11 @@ are of the form `v < e` where `v` is a vertex that is an end point of the edge `

* `zeta_matrix(p)` returns the zeta matrix of the poset. This is a `0,1`-matrix whose
`i,j`-entry is `1` exactly when `p[i] ≤ p[j]`.
* `strict_zeta_matrix(p)` returns a `0,1`-matrix whose `i,j` entry is `1`
exactly when `p[i] < p[j]`.
* `mobius_matrix(p)` returns the inverse of `zeta(p)`.

In both cases, the output is a dense, integer matrix.
In all cases, the output is a dense, integer matrix.


## Operations
Expand Down
2 changes: 1 addition & 1 deletion docs/build/.documenter-siteinfo.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-08-11T10:27:38","documenter_version":"1.5.0"}}
{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-08-16T15:43:17","documenter_version":"1.5.0"}}
4 changes: 2 additions & 2 deletions docs/build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
{9, 8} directed simple Int64 graph

julia&gt; d == path_digraph(9)
true</code></pre><p>Given a graph <code>g</code>, calling <code>vertex_edge_incidence_poset(p)</code> creates a poset whose elements correspond to the vertices and edges of <code>g</code>. In this poset the only relations are of the form <code>v &lt; e</code> where <code>v</code> is a vertex that is an end point of the edge <code>e</code>.</p><h2 id="Matrices"><a class="docs-heading-anchor" href="#Matrices">Matrices</a><a id="Matrices-1"></a><a class="docs-heading-anchor-permalink" href="#Matrices" title="Permalink"></a></h2><ul><li><code>zeta_matrix(p)</code> returns the zeta matrix of the poset. This is a <code>0,1</code>-matrix whose <code>i,j</code>-entry is <code>1</code> exactly when <code>p[i] ≤ p[j]</code>. </li><li><code>mobius_matrix(p)</code> returns the inverse of <code>zeta(p)</code>. </li></ul><p>In both cases, the output is a dense, integer matrix. </p><h2 id="Operations"><a class="docs-heading-anchor" href="#Operations">Operations</a><a id="Operations-1"></a><a class="docs-heading-anchor-permalink" href="#Operations" title="Permalink"></a></h2><h3 id="Dual"><a class="docs-heading-anchor" href="#Dual">Dual</a><a id="Dual-1"></a><a class="docs-heading-anchor-permalink" href="#Dual" title="Permalink"></a></h3><p>The dual of poset <code>p</code> is created using <code>reverse(p)</code>. This returns a new poset with the same elements as <code>p</code> in which all relations are reversed (i.e., <code>v &lt; w</code> in <code>p</code> if and only if <code>w &lt; v</code> in <code>reverse(p)</code>). The dual (reverse) of <code>p</code> can also be created with <code>p&#39;</code>. </p><h3 id="Disjoint-union"><a class="docs-heading-anchor" href="#Disjoint-union">Disjoint union</a><a id="Disjoint-union-1"></a><a class="docs-heading-anchor-permalink" href="#Disjoint-union" title="Permalink"></a></h3><p>Given two posets <code>p</code> and <code>q</code>, the result of <code>p+q</code> is a new poset formed from the disjoint union of <code>p</code> and <code>q</code>. Note that <code>p+q</code> and <code>q+p</code> are isomorphic, but may be unequal because of the vertex numbering convention. </p><p>Alternatively <code>hcat(p,q)</code>.</p><h3 id="Stack"><a class="docs-heading-anchor" href="#Stack">Stack</a><a id="Stack-1"></a><a class="docs-heading-anchor-permalink" href="#Stack" title="Permalink"></a></h3><p>Given two posets <code>p</code> and <code>q</code>, the result of <code>p/q</code> is a new poset from a copy of <code>p</code> and a copy of <code>q</code> with all elements of <code>p</code> above all elements of <code>q</code>. </p><p>Alternatively, <code>vcat(p,q)</code> or <code>q\p</code>.</p><h3 id="Induced-subposet"><a class="docs-heading-anchor" href="#Induced-subposet">Induced subposet</a><a id="Induced-subposet-1"></a><a class="docs-heading-anchor-permalink" href="#Induced-subposet" title="Permalink"></a></h3><p>Given a poset <code>p</code> and a list of vertices <code>vlist</code>, use <code>induced_subposet(p)</code> to return a pair <code>(q,vmap)</code>. The poset <code>q</code> is the induced subposet and the vector <code>vmap</code> maps the new vertices to the old ones (the vertex <code>i</code> in the subposet corresponds to the vertex <code>vmap[i]</code> in <code>p</code>).</p><p>This is exactly analogous to <code>Graphs.induced_subgraph</code>. </p><h3 id="Intersection"><a class="docs-heading-anchor" href="#Intersection">Intersection</a><a id="Intersection-1"></a><a class="docs-heading-anchor-permalink" href="#Intersection" title="Permalink"></a></h3><p>Given two posets <code>p</code> and <code>q</code>, <code>intersect(p,q)</code> is a new poset in which <code>v &lt; w</code> if and only if <code>v &lt; w</code> in both <code>p</code> and <code>q</code>. The number of elements is the smaller of <code>nv(p)</code> and <code>nv(q)</code>. This may also be invoked as <code>p ∩ q</code>. </p><p>For example, the intersection of a chain with its reversal has no relations:</p><pre><code class="nohighlight hljs">julia&gt; p = chain(5)
true</code></pre><p>Given a graph <code>g</code>, calling <code>vertex_edge_incidence_poset(p)</code> creates a poset whose elements correspond to the vertices and edges of <code>g</code>. In this poset the only relations are of the form <code>v &lt; e</code> where <code>v</code> is a vertex that is an end point of the edge <code>e</code>.</p><h2 id="Matrices"><a class="docs-heading-anchor" href="#Matrices">Matrices</a><a id="Matrices-1"></a><a class="docs-heading-anchor-permalink" href="#Matrices" title="Permalink"></a></h2><ul><li><code>zeta_matrix(p)</code> returns the zeta matrix of the poset. This is a <code>0,1</code>-matrix whose <code>i,j</code>-entry is <code>1</code> exactly when <code>p[i] ≤ p[j]</code>. </li><li><code>strict_zeta_matrix(p)</code> returns a <code>0,1</code>-matrix whose <code>i,j</code> entry is <code>1</code> exactly when <code>p[i] &lt; p[j]</code>.</li><li><code>mobius_matrix(p)</code> returns the inverse of <code>zeta(p)</code>. </li></ul><p>In all cases, the output is a dense, integer matrix. </p><h2 id="Operations"><a class="docs-heading-anchor" href="#Operations">Operations</a><a id="Operations-1"></a><a class="docs-heading-anchor-permalink" href="#Operations" title="Permalink"></a></h2><h3 id="Dual"><a class="docs-heading-anchor" href="#Dual">Dual</a><a id="Dual-1"></a><a class="docs-heading-anchor-permalink" href="#Dual" title="Permalink"></a></h3><p>The dual of poset <code>p</code> is created using <code>reverse(p)</code>. This returns a new poset with the same elements as <code>p</code> in which all relations are reversed (i.e., <code>v &lt; w</code> in <code>p</code> if and only if <code>w &lt; v</code> in <code>reverse(p)</code>). The dual (reverse) of <code>p</code> can also be created with <code>p&#39;</code>. </p><h3 id="Disjoint-union"><a class="docs-heading-anchor" href="#Disjoint-union">Disjoint union</a><a id="Disjoint-union-1"></a><a class="docs-heading-anchor-permalink" href="#Disjoint-union" title="Permalink"></a></h3><p>Given two posets <code>p</code> and <code>q</code>, the result of <code>p+q</code> is a new poset formed from the disjoint union of <code>p</code> and <code>q</code>. Note that <code>p+q</code> and <code>q+p</code> are isomorphic, but may be unequal because of the vertex numbering convention. </p><p>Alternatively <code>hcat(p,q)</code>.</p><h3 id="Stack"><a class="docs-heading-anchor" href="#Stack">Stack</a><a id="Stack-1"></a><a class="docs-heading-anchor-permalink" href="#Stack" title="Permalink"></a></h3><p>Given two posets <code>p</code> and <code>q</code>, the result of <code>p/q</code> is a new poset from a copy of <code>p</code> and a copy of <code>q</code> with all elements of <code>p</code> above all elements of <code>q</code>. </p><p>Alternatively, <code>vcat(p,q)</code> or <code>q\p</code>.</p><h3 id="Induced-subposet"><a class="docs-heading-anchor" href="#Induced-subposet">Induced subposet</a><a id="Induced-subposet-1"></a><a class="docs-heading-anchor-permalink" href="#Induced-subposet" title="Permalink"></a></h3><p>Given a poset <code>p</code> and a list of vertices <code>vlist</code>, use <code>induced_subposet(p)</code> to return a pair <code>(q,vmap)</code>. The poset <code>q</code> is the induced subposet and the vector <code>vmap</code> maps the new vertices to the old ones (the vertex <code>i</code> in the subposet corresponds to the vertex <code>vmap[i]</code> in <code>p</code>).</p><p>This is exactly analogous to <code>Graphs.induced_subgraph</code>. </p><h3 id="Intersection"><a class="docs-heading-anchor" href="#Intersection">Intersection</a><a id="Intersection-1"></a><a class="docs-heading-anchor-permalink" href="#Intersection" title="Permalink"></a></h3><p>Given two posets <code>p</code> and <code>q</code>, <code>intersect(p,q)</code> is a new poset in which <code>v &lt; w</code> if and only if <code>v &lt; w</code> in both <code>p</code> and <code>q</code>. The number of elements is the smaller of <code>nv(p)</code> and <code>nv(q)</code>. This may also be invoked as <code>p ∩ q</code>. </p><p>For example, the intersection of a chain with its reversal has no relations:</p><pre><code class="nohighlight hljs">julia&gt; p = chain(5)
{5, 10} Int64 poset

julia&gt; p ∩ reverse(p)
Expand All @@ -207,4 +207,4 @@
julia&gt; trim!(p)

julia&gt; p
{4, 6} Int64 poset</code></pre><h2 id="Implementation"><a class="docs-heading-anchor" href="#Implementation">Implementation</a><a id="Implementation-1"></a><a class="docs-heading-anchor-permalink" href="#Implementation" title="Permalink"></a></h2><p>A <code>Poset</code> is a structure that contains a single data element: a <code>DiGraph</code>. 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 <span>$a \to b$</span> is an edge and <span>$b\to c$</span> is an edge, then <span>$a \to c$</span> is also an edge. The advantage to this structure is that checking if <span>$a \prec b$</span> in a poset is quick. There are two disadvantages.</p><p>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 <span>$n$</span> elements has <span>$\binom{n}{2} \sim n^2/2$</span> edges in the digraph that represents it, whereas there are only <span>$n-1$</span> edges in the cover digraph. However, this savings is an extreme example. A poset with <span>$n$</span> elements split into two antichains, with every element of the first antichain below every element of the second, has <span>$n^2/4$</span> edges in either representation. So in either case, the representing digraph may have up to order <span>$n^2$</span> edges. </p><p>Second, the computational cost of adding (or deleting) a relation is nontrivial. The <code>add_relation!</code> function first checks if the added relation would violate transitivity; this is speedy because we can add the relation <span>$a \prec b$</span> so long as we don&#39;t have <span>$b\prec a$</span> already in the poset. However, after the edge <span>$(a,b)$</span> is inserted into the digraph, we execute <code>transitiveclosure!</code> and that takes some work. Adding several relations to the poset, one at a time, can be slow. </p><p>This can be greatly accelerated by using <code>Posets.add_relations!</code> but (as discussed above) this function can cause severe problems if not used carefully.</p><h2 id="See-Also"><a class="docs-heading-anchor" href="#See-Also">See Also</a><a id="See-Also-1"></a><a class="docs-heading-anchor-permalink" href="#See-Also" title="Permalink"></a></h2><p>The <code>extras</code> folder includes additional code that may be useful in working with <code>Posets</code>. See the <code>README</code> in the <code>extras</code> directory. </p><p>Of note is <code>extras/converter.jl</code> that defines the function <code>poset_converter</code> that can be used to transform a <code>Poset</code> (defined in this module) to a <code>SimplePoset</code> (defined in the <a href="https://github.com/scheinerman/SimplePosets.jl">SimplePosets</a> module). </p></article><nav class="docs-footer"><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.5.0 on <span class="colophon-date" title="Sunday 11 August 2024 10:27">Sunday 11 August 2024</span>. Using Julia version 1.10.4.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
{4, 6} Int64 poset</code></pre><h2 id="Implementation"><a class="docs-heading-anchor" href="#Implementation">Implementation</a><a id="Implementation-1"></a><a class="docs-heading-anchor-permalink" href="#Implementation" title="Permalink"></a></h2><p>A <code>Poset</code> is a structure that contains a single data element: a <code>DiGraph</code>. 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 <span>$a \to b$</span> is an edge and <span>$b\to c$</span> is an edge, then <span>$a \to c$</span> is also an edge. The advantage to this structure is that checking if <span>$a \prec b$</span> in a poset is quick. There are two disadvantages.</p><p>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 <span>$n$</span> elements has <span>$\binom{n}{2} \sim n^2/2$</span> edges in the digraph that represents it, whereas there are only <span>$n-1$</span> edges in the cover digraph. However, this savings is an extreme example. A poset with <span>$n$</span> elements split into two antichains, with every element of the first antichain below every element of the second, has <span>$n^2/4$</span> edges in either representation. So in either case, the representing digraph may have up to order <span>$n^2$</span> edges. </p><p>Second, the computational cost of adding (or deleting) a relation is nontrivial. The <code>add_relation!</code> function first checks if the added relation would violate transitivity; this is speedy because we can add the relation <span>$a \prec b$</span> so long as we don&#39;t have <span>$b\prec a$</span> already in the poset. However, after the edge <span>$(a,b)$</span> is inserted into the digraph, we execute <code>transitiveclosure!</code> and that takes some work. Adding several relations to the poset, one at a time, can be slow. </p><p>This can be greatly accelerated by using <code>Posets.add_relations!</code> but (as discussed above) this function can cause severe problems if not used carefully.</p><h2 id="See-Also"><a class="docs-heading-anchor" href="#See-Also">See Also</a><a id="See-Also-1"></a><a class="docs-heading-anchor-permalink" href="#See-Also" title="Permalink"></a></h2><p>The <code>extras</code> folder includes additional code that may be useful in working with <code>Posets</code>. See the <code>README</code> in the <code>extras</code> directory. </p><p>Of note is <code>extras/converter.jl</code> that defines the function <code>poset_converter</code> that can be used to transform a <code>Poset</code> (defined in this module) to a <code>SimplePoset</code> (defined in the <a href="https://github.com/scheinerman/SimplePosets.jl">SimplePosets</a> module). </p></article><nav class="docs-footer"><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.5.0 on <span class="colophon-date" title="Friday 16 August 2024 15:43">Friday 16 August 2024</span>. Using Julia version 1.10.4.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
Binary file modified docs/build/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/build/search_index.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,11 @@ are of the form `v < e` where `v` is a vertex that is an end point of the edge `

* `zeta_matrix(p)` returns the zeta matrix of the poset. This is a `0,1`-matrix whose
`i,j`-entry is `1` exactly when `p[i] ≤ p[j]`.
* `strict_zeta_matrix(p)` returns a `0,1`-matrix whose `i,j` entry is `1`
exactly when `p[i] < p[j]`.
* `mobius_matrix(p)` returns the inverse of `zeta(p)`.

In both cases, the output is a dense, integer matrix.
In all cases, the output is a dense, integer matrix.


## Operations
Expand Down

0 comments on commit d936f55

Please sign in to comment.