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

Add RandomLattice method. #175

Merged
merged 3 commits into from
Jul 25, 2019

Conversation

reiniscirpons
Copy link
Collaborator

@reiniscirpons reiniscirpons commented Feb 27, 2019

This PR adds a method RandomLattice for constructing random lattices, given a positive integer n 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 least n and no more than 2*n vertices. The average time complexity seems to be O(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

@james-d-mitchell james-d-mitchell added the new-feature A label for new features. label Mar 4, 2019
Copy link
Member

@james-d-mitchell james-d-mitchell left a 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.

doc/digraph.xml Outdated Show resolved Hide resolved
gap/digraph.gi Outdated Show resolved Hide resolved
tst/standard/digraph.tst Show resolved Hide resolved
@james-d-mitchell james-d-mitchell added this to the 1.0.0 milestone Mar 28, 2019
@reiniscirpons reiniscirpons force-pushed the RandomLattice branch 2 times, most recently from 2147941 to 3e694e3 Compare April 24, 2019 14:58
@reiniscirpons
Copy link
Collaborator Author

reiniscirpons commented Jul 21, 2019

I have implemented the requested changes. Could you review if everything is ok? Thanks :)

Copy link
Member

@james-d-mitchell james-d-mitchell left a 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.

doc/digraph.xml Outdated Show resolved Hide resolved
UniteSet(fam, List(fam, x -> UnionBlist(x, rand_blist)));
od;

return Digraph(IsMutableDigraph, fam, IsSubsetBlist);
Copy link
Member

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)));
Copy link
Member

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.

Copy link
Collaborator Author

@reiniscirpons reiniscirpons Jul 22, 2019

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.

Copy link
Member

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.

gap/digraph.gi Outdated Show resolved Hide resolved
@james-d-mitchell james-d-mitchell added the merge-in-to-master A label for PRs that should be merged into the master branch label Jul 22, 2019
@james-d-mitchell james-d-mitchell merged commit 62b5b5a into digraphs:master Jul 25, 2019
@james-d-mitchell
Copy link
Member

Thanks @reiniscirpons, merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-in-to-master A label for PRs that should be merged into the master branch new-feature A label for new features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants