Skip to content

Commit

Permalink
re-org
Browse files Browse the repository at this point in the history
  • Loading branch information
scheinerman committed Aug 6, 2024
1 parent 605aa7c commit da878c5
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 33 deletions.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,11 @@ as do elements `n+1` through `2n`. The only relations are of the form `j < k` wh
and `k = n+i` where `1 ≤ i ≤ n` and `i ≠ j`. This is a smallest-size poset of dimension `n`.
* `chevron()` creates a poset with `6` elements that has dimension equal to `3`. It is
different from `standard_example(3)`.
* `semiorder(xs)` creates a semiorder. Here `xs` is a list of `n` real numbers. The result is a poset with `n` elements in which `i<j` when `x[i] ≤ x[j] - 1`. More generally, use `semiorder(xs,t)` in which case `i<j` when `x[i] ≤ x[j] - t`. Setting `t=0` gives a total order (if the values in `xs` are distinct). If `t` is negative, errors may be thrown.
* `random_linear_order(n)`: Create a linear order in which the numbers `1` through `n` appear in
random order.
* `random_poset(n,d=2)`: Create a random `d`-dimensional poset by intersecting `d` random linear orders,
each with `n` elements.



## Graphs
Expand Down
19 changes: 10 additions & 9 deletions extras/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@ is a factor of the `b`-divisor.
* `subsets_poset(n)`: Create a poset (isomorphic to) the $2^d$ subsets of a `d`-element set
ordered by inclusion.

## `random_posets.jl`

Functions provided:
* `random_linear_order(n)`: Create a linear order in which the numbers `1` through `n` appear in
random order.

* `random_poset(n,d=2)`: Create a random `d`-dimensional poset by intersecting `d` random linear orders,
each with `n` elements.

## `pplot.jl`

Function provided:
* `pplot(p)`: draw a picture of (the cover digraph of) `p`. An edge `v → w` means
`v < w` and `w` covers `v`. Use `pplot(p, nodelable=1:nv(p))` to have the nodes labeled.
`v < w` and `w` covers `v`. Use `pplot(p, nodelable=1:nv(p))` to have the nodes labeled.


## `interval_orders.jl`

* `semiorder(xs)` creates a semiorder. Here `xs` is a list of `n` real numbers.
The result is a poset with `n` elements in which `i<j` when `x[i] ≤ x[j] - 1`.
More generally, use `semiorder(xs,t)` in which case `i<j` when `x[i] ≤ x[j] - t`.
Setting `t=0` gives a total order (if the values in `xs` are distinct).
If `t` is negative, errors may be thrown.
2 changes: 2 additions & 0 deletions extras/divisors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ function subsets_poset(d::Integer)
n = prod(primes(d)) # product of first d primes
return divisor_poset(n)
end

nothing
22 changes: 22 additions & 0 deletions extras/interval-orders.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Posets, Graphs, ClosedIntervals

"""
semiorder(values::Vector{T}, thresh=1) where {T<:Real}
Create a semi-order from a list of numbers. In this poset we have `a<b`
exactly when `values[a] ≤ values[b] - thresh`.
"""
function semiorder(values::Vector{T}, thresh=1) where {T<:Real}
n = length(values)
g = DiGraph(n)
for a in 1:n
for b in 1:n
if values[a] <= values[b] - thresh
add_edge!(g, a, b)
end
end
end
return Poset(g)
end

nothing
2 changes: 2 additions & 0 deletions extras/pplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ function pplot(p::Poset; args...)
g = cover_digraph(p)
return gplot(g; args...)
end

nothing
5 changes: 5 additions & 0 deletions src/Posets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ module Posets

using Graphs
using LinearAlgebra
using Random

using ChooseOptimizer
using JuMP
using HiGHS
Expand Down Expand Up @@ -63,6 +65,8 @@ export Poset,
mobius_matrix,
nr,
nv,
random_linear_order,
random_poset,
realizer,
relations,
rem_vertex!,
Expand Down Expand Up @@ -146,5 +150,6 @@ include("connection.jl")
include("height-width.jl")
include("realizer.jl")
include("iso.jl")
include("random-posets.jl")

end # module Posets
4 changes: 0 additions & 4 deletions extras/random_posets.jl → src/random-posets.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
using Posets
using Graphs
using Random

"""
random_linear_order(n::Integer)
Expand Down
19 changes: 0 additions & 19 deletions src/standard.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,3 @@ function chevron()

return p
end

"""
semiorder(values::Vector{T}, thresh=1) where {T<:Real}
Create a semi-order from a list of numbers. In this poset we have `a<b`
exactly when `values[a] ≤ values[b] - thresh`.
"""
function semiorder(values::Vector{T}, thresh=1) where {T<:Real}
n = length(values)
g = DiGraph(n)
for a in 1:n
for b in 1:n
if values[a] <= values[b] - thresh
add_edge!(g, a, b)
end
end
end
return Poset(g)
end

0 comments on commit da878c5

Please sign in to comment.