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
Function to check if a poset containt a subposet isomorphic to another poset #16892
Comments
comment:1
Seems that this function is easy:
(Thanks to Nathann Cohen for this.) Needs to test this, and then just add few lines of code + documentation to Sage. |
New commits:
|
Commit: |
comment:4
Nathann |
comment:5
My first comment is totally wrong, I am sorry. I thought you were defining the function twice, once in posets.py and another time in the categories files. What you are doing is fine. Though Hasse diagrams are graph objects, and so they already have the Nathann |
comment:6
But if I do
On point 2 you are right. |
comment:7
Yoooooooooooooo !
That's a bug. There is no reason why computing the transitive closure of a graph requires that graph to be mutable (indeed, the graph itself is not modified: its closure is returned as a completely new graph). You can fix it by going into Nathann |
comment:8
|
comment:9
Hello !!
I would fix it in the same ticket given that it's a very small change, but then that's up to you if you do not feel safe fixing this yourself. It is a fairly simple change, needed because we only recently added a support for immutable graphs (graphs that cannot be modified) and so a lot of code written before is not made to handle it. It is exactly the case here, where you have to say explicitly that the copy should NOT be immutable, even if the graph itself was immutable. If you prefer to leave others double-check it, then indeed you should open another ticket which would be a dependency of this one (only if you need that bug to be fixed in order to implement what you write here).
"Induced" here seems a little too vague to me. But you could complete it with the code you used before: "By subposet we mean tha set I really think that it would be best to implement both features at once (possibly with an optional 'induced' boolean parameter in the function you add). And it would also be nice to give the user a way to obtain the copy of P2 in P1, as they will probably want this as a certificate. Whatever you do, the beginning of the doc of each function should be a one-line description of what it does. Then you can describe better the behaviour of the function. Nathann |
Dependencies: 16909 |
comment:11
Can 'induced' be later added with default value to One more question: What is the meaning of having same documentation and examples copied to both posets.py and hasse_diagram.py? For example has_bottom() and actually most of functions? |
comment:12
Hello !
I just wrote a commit and added Travis and Simon in cc. The patch is very short, so it may not take very long before it is reviewed !
I believe that
Why exacty do you want to add a method to HasseDiagram, given that they are digraphs and that they already inherit the Nathann |
comment:13
As for default behaviour, I asked few mathematicians what they guess the function would do if they only know it's name. In any case, it must be documented. Now when I think more: "having subgraph" is quite different from "having subposet", and "having sublattice" is stille one more thing. About posets.py vs. hasse_diagram.py: Actually I don't know. Saying
shows that there are 14 functions that are just wrappers to underlying hasse_diagram -function. Should this be discussed on sage-devel -list? |
comment:14
Hello !
The current default behaviour is good, but it is what I would call "not induced". The "induced" version would be the one in which you do not have the call to
Yepyep, you can ask ! Nathann |
comment:15
OK, so we have same view on default behaviour. Good. And so it is possible to make this function first and expand it later. But I'll also check if I can make a function to get subposets. This seems to work:
|
comment:16
It does work "on the paper", but by doing this you first build the whole list of copies, then return it. And it could take a long time, in particular if the user is only looking for some specific copy. By replacing the [] with (), you turn it into a Python interator, and the list is not totally built first but only when the users wants to read more and more values. Example:
But
Nathann |
comment:17
Ah, it is that easy to convert this to iterator. Points to python! Now there is But anyways, I can make E: I think I'll do it in posets.py-hasse_diagram.py -style, because I'm not sure about rationale behind it. If unsure, do as others... |
comment:18
Yo !
Personally I'd vote for turning them all into iterators and having only one function of each kind.
Come oooooooon. If nobody knows why it is done like that, just do as you think best ! Don't follow others who followed others themselves. Nathann |
comment:19
Actually the function
Searching for a reason to this... What comes to iterators: They are of course needed when handling large data. But for quite simple tests it is easier to work with plain list, sets etc. |
comment:20
Hello !
Could it be because there are multiple ways to send D into N5 ?
True. But you can build a set from an iterator if you like, while if the function returns a lot of objects you are forced to store them all whatever you use case is. Nathann |
comment:21
There are 2 ways to insert D into N5. Or of course 4, if you think it somewhat unnaturally. In same way you got 2 hits with
But this doesn't sound right to me. |
comment:22
There is of course ways to remove duplikates from a list. However, I guess it is not possible (in reality) with iterators. Hence we must abandon |
Branch pushed to git repo; I updated commit sha1. New commits:
|
Changed dependencies from 16909 to #16909 |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:34
Hello ! A few other remarks:
"Return an iterator over the subposets isomorphic to other poset" -> to another poset ? Or 'to a given poset' ?
Thanks, Nathann |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:36
Hello ! This branch is good to go I guess, but it does not pass tests by itself. Could you merge this branch with the branch at #16909 ? Nathann |
comment:39
Now there is commit that has both patches merged. Should I or ncohen now close #16909 as merged? |
comment:40
Nononono: only the release manager should close the tickets, when he merges the commits into the next release. What you did was the right thing, nothing more is needed. Nathann |
Reviewer: Nathann Cohen |
comment:42
(name again) |
Author: Jori Mäntysalo |
Changed branch from u/jmantysalo/function_to_check_if_a_poset_containt_a_subposet_isomorphic_to_another_poset to |
It is, in principle, easy to check if poset A contains a subposet isomorphic to poset B:
In reality this is way too slow. Can this be made usefully fast at least in posets of size 5..10?
Depends on #16909
CC: @nathanncohen
Component: combinatorics
Author: Jori Mäntysalo
Branch/Commit:
346ef0e
Reviewer: Nathann Cohen
Issue created by migration from https://trac.sagemath.org/ticket/16892
The text was updated successfully, but these errors were encountered: