Skip to content

feat: expose mycielskian() and make_mycielski_graph() - #2404

Open
krlmlr with Copilot wants to merge 4 commits into
mainfrom
copilot/expose-mycielskian-graph-functions
Open

krlmlr with Copilot wants to merge 4 commits into
mainfrom
copilot/expose-mycielskian-graph-functions

Conversation

Copilot AI commented Oct 26, 2025 •

Copy link
Copy Markdown
Contributor

This PR was prepared with the assistance of GitHub Copilot,
and finalized with Claude Code.

  • By submitting this pull request, I assign the copyright of my contribution to The igraph development team.

Summary

Exposes igraph_mycielskian() and igraph_mycielski_graph()
from the C library to R users.

Functions added:

  • mycielskian(graph, k = 1, ...) —
    applies the Mycielski transformation k times to a graph
  • make_mycielski_graph(k, ...) —
    creates the Mycielski graph of order k
  • mycielski_graph(k, ...) —
    constructor spec for use with make_()

Implementation notes

  • The wrappers delegate to the Stimulus-generated mycielskian_impl()
    and mycielski_graph_impl(),
    with all arguments named and no .Call() in hand-written code.
  • mycielskian() validates its input via ensure_igraph()
    before delegating.
  • k sits before the ellipsis as a defining model parameter;
    the trailing ... is guarded with check_dots_empty()
    in all three functions.
  • Documentation follows the C library docs,
    including the special-case constructions
    for the null and singleton graphs,
    the extension to directed and non-simple graphs,
    and the convention for orders k <= 1.
    It uses math mode (\eqn{}) for all formulas,
    semantic line breaks,
    experimental badges,
    and a "Mycielski graph" concept for the pkgdown reference index.
  • The "Related documentation in the C library" section links to the
    C/igraph 0.10.17 documentation of both functions.

Testing

  • _impl() snapshot and structured tests exist in
    tests/testthat/test-aaa-auto.R.
  • Direct _impl() tests
    (full argument set, real counts, agreement with the wrappers)
    plus structured and error snapshot tests for the exported functions
    live in tests/testthat/test-make.R
    (constructor, including the make_(mycielski_graph(k)) form)
    and tests/testthat/test-operators.R (transformation).

Fixes #2089

Copilot AI changed the title [WIP] Expose igraph_mycielskian and igraph_mycielski_graph functions feat: expose mycielskian() and make_mycielski_graph() Oct 26, 2025
Copilot AI requested a review from krlmlr October 26, 2025 10:44
@krlmlr
krlmlr requested a review from szhorvat October 26, 2025 11:09
@krlmlr krlmlr removed their assignment Oct 26, 2025
@szhorvat

Copy link
Copy Markdown
Member

@copilot Make sure that al formulas and mathematical notation uses math mode, and not inline code, in the documentation.

@krlmlr

krlmlr commented Oct 26, 2025

Copy link
Copy Markdown
Contributor

@szhorvat: Thanks, I saw this too. This is best written down in AGENTS.md or in a separate file that's pointed to by this file. Would you like to take a stab, based on what you see in the PRs generated until now? We can then apply and ask to redo in a consistent way.

Copilot AI commented Oct 26, 2025

Copy link
Copy Markdown
Contributor Author

@copilot Make sure that al formulas and mathematical notation uses math mode, and not inline code, in the documentation.

Updated all mathematical notation to use \eqn{} math mode instead of inline code in commit 6ee824b. Variables (n, k, m, G), graph names (M_k, M(G)), and formulas are now properly formatted with LaTeX-style notation.

@krlmlr

krlmlr commented Oct 26, 2025

Copy link
Copy Markdown
Contributor

@copilot: Agent instructions are updated, adapt.

Copilot AI commented Oct 26, 2025

Copy link
Copy Markdown
Contributor Author

@copilot: Agent instructions are updated, adapt.

Applied AGENTS.md guidelines in commit 1f3cc01:

  • Added experimental badges to both functions
  • Added "Mycielski graph" concept for pkgdown reference index
  • Reformatted documentation with one sentence per line
  • Maintained proper math mode formatting with \eqn{}

Note: Removed @cdocs tags as the C documentation database doesn't yet include these new functions - they can be added later when the database is updated.

@szhorvat

Copy link
Copy Markdown
Member

Note: Removed @cdocs tags as the C documentation database doesn't yet include these new functions - they can be added later when the database is updated.

@maelle What does one need to do to update this database? The C documentation for these is online already.

@krlmlr We want to avoid .Call, and ideally use only _impl, right?

@krlmlr

krlmlr commented Nov 30, 2025

Copy link
Copy Markdown
Contributor

The cdocs need a bit of work. For this branch we rely on the cdocs for the last v0.x version, would the function also be documented there? When I search for "Mycielski", I don't find it, not in v0.x, not in v1.0.0 .

@krlmlr

krlmlr commented Nov 30, 2025

Copy link
Copy Markdown
Contributor

@copilot: Closely follow all agent instructions, amend as needed.

Copilot AI commented Nov 30, 2025

Copy link
Copy Markdown
Contributor Author

@copilot: Closely follow all agent instructions, amend as needed.

Applied all AGENTS.md guidelines in commit cee9bd9:

  • Refactored to use _impl functions instead of direct .Call()
  • Added ... with check_dots_empty() separating mandatory and optional arguments
  • Named all arguments in _impl function calls
  • Added explicit @description and @details sections in documentation
  • Updated tests to use named argument k =

@krlmlr

krlmlr commented Nov 30, 2025

Copy link
Copy Markdown
Contributor

@copilot: Do we need mycielski_graph() for symmetry with other constructors?

Copilot AI commented Nov 30, 2025

Copy link
Copy Markdown
Contributor Author

@copilot: Do we need mycielski_graph() for symmetry with other constructors?

Added mycielski_graph() constructor spec in commit 7e87476 for symmetry with other constructors like kautz_graph(), de_bruijn_graph(), etc. It can be used with make_(mycielski_graph(k)).

@szhorvat

Copy link
Copy Markdown
Member

For this branch we rely on the cdocs for the last v0.x version, would the function also be documented there?

Yes, but only in 0.10.17, which was released at the same time as 1.0.0.

Please don't use the Google Search box, there's an issue with that we could not yet fix. Use the index, and Command-F, https://igraph.org/c/html/latest/ix01.html

@krlmlr
krlmlr marked this pull request as ready for review July 26, 2026 15:04
Flattened onto the current main (post-#2779 rebase); content unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016M32izVHZPfxAqemAe4BrX
@krlmlr
krlmlr force-pushed the copilot/expose-mycielskian-graph-functions branch from d5698b3 to ec97b5d Compare July 26, 2026 16:43
@github-actions

Copy link
Copy Markdown
Contributor

This is how benchmark results would change (along with a 95% confidence interval in relative change) if ec97b5d is merged into main:

  • ✔️as_adjacency_matrix: 783ms -> 783ms [-1.07%, +1.01%]
  • ✔️as_biadjacency_matrix: 765ms -> 772ms [-0.24%, +2.12%]
  • ✔️as_data_frame_both: 1.54ms -> 1.57ms [-1.75%, +4.79%]
  • ✔️as_long_data_frame: 3.89ms -> 3.9ms [-0.88%, +1.46%]
  • ✔️es_attr_filter: 2.96ms -> 3.18ms [-8.9%, +23.88%]
  • ✔️graph_from_adjacency_matrix: 121ms -> 121ms [-0.88%, +0.87%]
  • ✔️graph_from_data_frame: 3.41ms -> 3.39ms [-2.61%, +1.16%]
  • ✔️vs_attr_filter: 1.63ms -> 1.64ms [-1.99%, +2.51%]
  • ✔️vs_by_name: 1.08ms -> 1.09ms [-1.14%, +3.93%]
    Further explanation regarding interpretation and methodology can be found in the documentation.

Resolve end-of-file test conflicts in tests/testthat/test-make.R and
tests/testthat/test-operators.R by keeping both sides: this branch's
mycielskian()/make_mycielski_graph() tests followed by main's
ellipsis-migration argument-coverage sections.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016M32izVHZPfxAqemAe4BrX
@github-actions

Copy link
Copy Markdown
Contributor

This is how benchmark results would change (along with a 95% confidence interval in relative change) if d4491a3 is merged into main:

  • ✔️as_adjacency_matrix: 792ms -> 793ms [-0.78%, +1.09%]
  • ✔️as_biadjacency_matrix: 764ms -> 766ms [-1.06%, +1.54%]
  • ✔️as_data_frame_both: 1.53ms -> 1.52ms [-2.05%, +1.57%]
  • ✔️as_long_data_frame: 4.03ms -> 3.97ms [-3.27%, +0.39%]
  • 🚀es_attr_filter: 2.69ms -> 2.66ms [-2.09%, -0.01%]
  • ✔️graph_from_adjacency_matrix: 131ms -> 132ms [-2.2%, +3.44%]
  • ✔️graph_from_data_frame: 3.43ms -> 3.5ms [-3.34%, +7.41%]
  • ✔️vs_attr_filter: 1.51ms -> 1.5ms [-1.64%, +1.03%]
  • ✔️vs_by_name: 970µs -> 969µs [-1.7%, +1.42%]
    Further explanation regarding interpretation and methodology can be found in the documentation.

claude added 2 commits July 28, 2026 06:51
Validate the graph argument in `mycielskian()` via `ensure_igraph()`
before delegating to the Stimulus-generated `mycielskian_impl()`.
Document the special-case constructions for the null and singleton
graphs,
the extension to directed and non-simple graphs,
and the convention for orders `k <= 1`,
matching the C library documentation.
Align `@return` wording with file conventions
and reflow the roxygen prose as semantic line breaks.
Add direct tests for `mycielski_graph_impl()` and `mycielskian_impl()`
that assert real counts
and agreement with the exported wrappers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016M32izVHZPfxAqemAe4BrX
@github-actions

Copy link
Copy Markdown
Contributor

This is how benchmark results would change (along with a 95% confidence interval in relative change) if a575b2c is merged into main:

  • ✔️as_adjacency_matrix: 703ms -> 704ms [-1.97%, +2.34%]
  • ✔️as_biadjacency_matrix: 684ms -> 680ms [-2.98%, +1.87%]
  • ✔️as_data_frame_both: 1.3ms -> 1.31ms [-1.62%, +4.13%]
  • ✔️as_long_data_frame: 3.17ms -> 3.16ms [-1.97%, +1.11%]
  • ✔️es_attr_filter: 2.29ms -> 2.27ms [-3.43%, +1.85%]
  • ✔️graph_from_adjacency_matrix: 139ms -> 138ms [-3.3%, +1.13%]
  • ✔️graph_from_data_frame: 2.86ms -> 2.86ms [-2.33%, +2.27%]
  • ✔️vs_attr_filter: 1.3ms -> 1.29ms [-3.65%, +2.53%]
  • ✔️vs_by_name: 837µs -> 847µs [-2.48%, +4.77%]
    Further explanation regarding interpretation and methodology can be found in the documentation.

This branch has not been deployed

No deployments
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.

Expose mycielskian and mycielski_graph

4 participants