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

Equality checking for ActionDigraph #89

Open
MTWhyte opened this issue Dec 2, 2022 · 1 comment
Open

Equality checking for ActionDigraph #89

MTWhyte opened this issue Dec 2, 2022 · 1 comment
Labels
documentation Improvements or additions to documentation duplicate This issue or pull request already exists

Comments

@MTWhyte
Copy link
Contributor

MTWhyte commented Dec 2, 2022

On my current fpsemi-examples branch, where I import the re

from libsemigroups_pybind11 import Sims1, congruence_kind, presentation
from libsemigroups_pybind11.fpsemigroup import make, full_transformation_monoid

p = make(full_transformation_monoid(4))
p.alphabet(5)
presentation.replace_word(p, [], [4])
presentation.add_identity_rules(p, 4)

C = Sims1(congruence_kind.right)
C.short_rules(p)

k = C.number_of_congruences(2)
it = C.iterator(2)
graphs = []
for i in range(k):
    graphs.append(next(it))

I find that graphs[0] == graphs[1] is True. This suggests that equality checking for action digraphs possibly hadn't been implemented. I wondered if ActionDigraphs which give equal strings as output from their repr are 'equal' under ==, but the following illustrates this isn't true:

In [48]: ad1 = ActionDigraph(2)
In [49]: ad2 = ActionDigraph(2)
In [50]: ad1.add_to_out_degree(2)
In [51]: ad2.add_to_out_degree(2)
In [52]: ad1.add_edge(0, 0, 0)
In [53]: ad1.add_edge(0, 1, 1)
In [54]: ad1.add_edge(1, 0, 0)
In [55]: ad1.add_edge(1, 1, 1)
In [56]: ad2.add_edge(0, 0, 1)
In [57]: ad2.add_edge(0, 1, 0)
In [58]: ad2.add_edge(1, 0, 1)
In [59]: ad2.add_edge(1, 1, 0)
In [60]: ad1
Out[60]: <action digraph with 2 nodes, 4 edges, 2 out-degree>
In [61]: ad2
Out[61]: <action digraph with 2 nodes, 4 edges, 2 out-degree>
In [62]: ad1 == ad2
Out[62]: False

There is possibly something unexpected going on here, or something just as of yet unimplemented, but I'm not sure exactly what.

@james-d-mitchell
Copy link
Member

Thanks @MTWhyte. The digraphs ad1 and ad2 in your second code block aren't equal, so why do you think the answer is wrong? Their __repr__ being equal doesn't mean anything, there are plenty of non-equal (and non-isomorphic) graphs (even action/word graphs) with the same numbers of nodes and edges.

The first issue your having is the same as #70, the iterator points at a reference to a single graph, so when the iterator is incremented, the value of graphs[0] is the same as that for graphs[1]. I'm not sure that this is exactly a bug, maybe more of an issue with the documentation.

If you do:

[ActionDigraph(x) for x in C.iterator(2)]

In your example, you copy x (which is changed in-place when calling next) using the copy constructor of ActionDigraph. There are good reasons to not do this copying by default (performance!). So I think this becomes an issue in the documentation rather than in the code itself.

@james-d-mitchell james-d-mitchell added the duplicate This issue or pull request already exists label Dec 2, 2022
@james-d-mitchell james-d-mitchell added the documentation Improvements or additions to documentation label Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants