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

Kneser Graph Generator #2233

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

Conversation

valdaarhun
Copy link
Contributor

New feature: Generation of kneser graphs.

Resolves #1876.

So far, I have only implemented functions to calculate $\binom{n}{k}$ and generate k-size subsets. I have made both functions static and put them in kneser.c. Please let me know if I should integrate them into iterators.c instead.

I think it'll be best to finalize the design and implementation of the above functions before implementing the actual graph generator.

@ntamas
Copy link
Member

ntamas commented Oct 10, 2022

  • igraph_i_generate_subsets does not have a return type; it should be igraph_error_t and you should wrap the inner igraph_vector_list_... call in an IGRAPH_CHECK() to make sure that error codes are handled and propagated correctly. You should return IGRAPH_SUCCESS from the function when you wish to terminate the recursion.
  • Global variables should not be used; igraph_i_generate_subsets() should receive the vector list in which the subsets should be filled as a parameter.
  • The nCk variable is redundant; you can just return the corresponding expression directly.
  • genSubset is not defined; you probably meant igraph_i_generate_subsets(), right?

@valdaarhun
Copy link
Contributor Author

  • genSubset is not defined; you probably meant igraph_i_generate_subsets(), right?

Hi. You're right, my bad. I forgot to change the name while refactoring.

@codecov
Copy link

codecov bot commented Oct 11, 2022

Codecov Report

Merging #2233 (98162c0) into master (0c735a3) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2233   +/-   ##
=======================================
  Coverage   83.54%   83.54%           
=======================================
  Files         376      376           
  Lines       61586    61586           
=======================================
  Hits        51450    51450           
  Misses      10136    10136           

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0c735a3...98162c0. Read the comment docs.

@szhorvat
Copy link
Member

Just a note that it's strongly preferred to use non-recursive implementations. Recursive functions are prone to stack overflow. This has happened in the past.

@valdaarhun
Copy link
Contributor Author

valdaarhun commented Oct 24, 2022

Hi. I thought I would just give an update here. I have made igraph_i_generate_subsets iterative. I am still working on making igraph_i_number_of_subsets iterative.

Edit: Both functions are now iterative.

src/constructors/kneser.c Outdated Show resolved Hide resolved
src/constructors/kneser.c Outdated Show resolved Hide resolved
1. Fix function name in function body
2. Make igraph_error_t the return type of igraph_i_generate_subsets
3. Use IGRAPH_CHECK and IGRAPH_SUCCESS
4. Remove global variable
5. Style check and cleanup
    Use 'igraph_vector_resize()' and remove 'igraph_vector_init()'
@stale
Copy link

stale bot commented Mar 25, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Issues that have been inactive for a long time; will be closed in the absence of further activity label Mar 25, 2023
@stale stale bot removed the stale Issues that have been inactive for a long time; will be closed in the absence of further activity label Mar 25, 2023
@GroteGnoom
Copy link
Member

What's the status of this PR? @valdaarhun are you waiting for us before you continue?

@valdaarhun
Copy link
Contributor Author

Hi. Yes, I was waiting for feedback. I apologize for not sending a reminder, I got caught up with other work. I would like to resume working on this now.

igraph_integer_t subsets, igraph_vector_int_list_t *vertices) {

igraph_vector_int_t *temp = igraph_vector_list_get_ptr(vertices, 0);
IGRAPH_CHECK(igraph_vector_resize(temp, k));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since temp is an igraph_vector_int_t, you need to use the functions that take an igraph_vector_int_t. For instance, igraph_vector_int_resize() instead of igraph_vector_resize(), igraph_vector_int_update() instead of igraph_vector_update() and so on. I haven't checked the correctness of the algorithm yet, this just simply struck my eye.

I haven't checked the correctness of this function, this just simply struck my eye.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I must have missed this. I'll fix it.

@GroteGnoom
Copy link
Member

GroteGnoom commented Apr 5, 2023

Hi. Yes, I was waiting for feedback. I apologize for not sending a reminder, I got caught up with other work. I would like to resume working on this now.

No apologies necessary 🙂
As Tamás noticed, your types are not completely correct.

If you add your file to src/CMakeLists.txt you can use CMake to build your code and see the warnings.
(You can also maybe set up your editor so you can see these warnings while coding.)

If you add the actual generator function (or maybe for now just something that tests your subset generator) you can also add some tests in /tests/unit/ and add it in tests/CMakeLists, so your code gets run. That's one basic way of getting some feedback on your code :)

If you have any further questions (like about using CMake) don't hesitate to ask.

@valdaarhun
Copy link
Contributor Author

If you add your file to src/CMakeLists.txt you can use CMake to build your code and see the warnings. (You can also maybe set up your editor so you can see these warnings while coding.)

If you add the actual generator function (or maybe for now just something that tests your subset generator) you can also add some tests in /tests/unit/ and add it in tests/CMakeLists, so your code gets run. That's one basic way of getting some feedback on your code :)

Oh, that's nice. I'll definitely do this.

If you have any further questions (like about using CMake) don't hesitate to ask.

Sure thing. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generator for Kneser graphs and related graphs
4 participants