Skip to content

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

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.51%. Comparing base (e4fd298) to head (b443766).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2233   +/-   ##
=======================================
  Coverage   75.51%   75.51%           
=======================================
  Files         406      406           
  Lines       75313    75313           
  Branches    15049    15049           
=======================================
  Hits        56870    56870           
  Misses      18443    18443           

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 e4fd298...b443766. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@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.

@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 stale Issues that have been inactive for a long time; will be closed in the absence of further activity and removed stale Issues that have been inactive for a long time; will be closed in the absence of further activity labels 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.

@stale
Copy link

stale bot commented Apr 26, 2025

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 Apr 26, 2025
@szhorvat szhorvat added todo Triaged for implementation in some unspecified future version and removed stale Issues that have been inactive for a long time; will be closed in the absence of further activity labels Apr 27, 2025
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()'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

todo Triaged for implementation in some unspecified future version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generator for Kneser graphs and related graphs

4 participants