-
Notifications
You must be signed in to change notification settings - Fork 46
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
Add RandomLattice method. #175
Add RandomLattice method. #175
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really good, some minor quibbles, then we'll be happy to merge.
2147941
to
3e694e3
Compare
3e694e3
to
a73be6f
Compare
I have implemented the requested changes. Could you review if everything is ok? Thanks :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much @reiniscirpons, a couple of further minor revisions are required, then I'll be happy for this to be merged.
UniteSet(fam, List(fam, x -> UnionBlist(x, rand_blist))); | ||
od; | ||
|
||
return Digraph(IsMutableDigraph, fam, IsSubsetBlist); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
|
||
while Length(fam) < n do | ||
rand_blist := List([1 .. n], x -> Random([true, false])); | ||
UniteSet(fam, List(fam, x -> UnionBlist(x, rand_blist))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea if this would make any difference but you could use Set
instead of List
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting suggestion, I tried it out, but in practice it is a slightly slower or the same with Set
, presumably since it needs to reorder the list, which adds time, and then UniteSet
does not take advantage of the second argument being a Set
.
This makes sense since UniteSet(set, list)
is only defined for a set and a list, so I do not think that having a Set
instead of a List
as the second argument will change the algorithm its using (which I think is to just add each element in the list to the set).
Therefore I will not change it to Set
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, that all makes sense.
Thanks @reiniscirpons, merged! |
This PR adds a method
RandomLattice
for constructing random lattices, given a positive integern
as input.It then incrementally calculates a union lattice of sets, terminating once the lattice has at least
n
vertices. It is guaranteed that the resulting lattice will have at leastn
and no more than2*n
vertices. The average time complexity seems to beO(n^2)
.Some results on the distribution of such lattices can be derived from
"The representation of posets and lattices by sets"
George Markowsky
Algebra Universalis, 11 (1980), 173-192