-
-
Notifications
You must be signed in to change notification settings - Fork 465
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
Implementation of algorithm for exact counting graph homomorphisms #38062
base: develop
Are you sure you want to change the base?
Conversation
Documentation preview for this PR (built with commit 3231ec8; changes) is ready! 🎉 |
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 PR requires some work before. It must be properly documented, doctests are needed, etc. Here is a first list of needed changes.
I don't think we need this helper_functions.py
file. I fact, I'm in favor of using a single file called homomorphisms.py
and gathering all methods related to graph homomorphisms.
|
||
def extract_bag_vertex(mapping, index, graph_size): | ||
r""" | ||
Extract the bag vertex at `index` from `mapping` |
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.
The method don't extract
but returns an index
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 belive this returns that vertex at some index
|
||
def add_vertex_into_mapping(new_vertex, mapping, index, graph_size): | ||
r""" | ||
Insert `new_vertex` at `index` into `mapping` |
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.
The method don't insert
but returns the index where to do so.
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.
Yes, but I could not think of a better name for this. Do you have any name suggestions?
Thank you for all the reviews! Of course, many tests and much documentation are needed.
I also consider the possibility of having only one file, but wouldn't it make the main file I think the name |
We already have files with 20.000+ lines. |
…isms functionality
@dcoudert Thank you again for the code reviews! I think I have changed some codes based on your review. Do you think we also need examples/tests for the small helper functions at the end of the file? |
Tests are needed in all methods, even the small helper functions. |
In the past few months, we have been working towards a SageMath library for exact counting graph homomorphisms, based on the proof of Prop. 1.6 from "Homomorphisms Are a Good Basis for Counting Small Subgraphs" by Radu Curticapean, Holger Dell, and Dániel Marx: The algorithm is deterministic and runs in time$\exp(O(k)) + poly(k) \cdot n^{tw(H) + 1}$ for counting the number of homomorphisms from graph $H$ to graph $G$ , where $k = |V(H)|$ , $n = |V(G)|$ , and $tw(H)$ is the treewidth of $H$ .
The library is recently released on GitHub: https://github.com/guojing0/count-graph-homs
This commit is mainly for the sake of CI. More documentations and tests will follow.
📝 Checklist
⌛ Dependencies