Draft
refactor: extract common graph construction patterns into graph.rs#220
Conversation
Add four new utility functions to cspuz_rs/src/graph.rs: - graph_8_neighbors: 8-neighbor connectivity graph for an h*w grid - graph_8_neighbors_with_outer_vertex: same + outer vertex connected to border cells - active_edges_acyclic: dual-graph acyclicity constraint for BoolGridEdges - graph_slash_connectivity / graph_slash_connectivity_with_outer_vertex: sub-cell connectivity graph for slash/backslash puzzles Update puzzle files to use these new helpers: - bramble.rs, cocktail.rs, tetrochain_common.rs -> graph_8_neighbors - nurimaze.rs, city_space.rs -> graph_8_neighbors_with_outer_vertex - mintonette.rs, move_common.rs -> active_edges_acyclic - gokigen.rs -> graph_slash_connectivity_with_outer_vertex - slashpack.rs -> graph_slash_connectivity Agent-Logs-Url: https://github.com/semiexp/cspuz_core/sessions/767797f1-b6e9-4190-9c51-8b5099df4a97 Co-authored-by: semiexp <7336994+semiexp@users.noreply.github.com>
Agent-Logs-Url: https://github.com/semiexp/cspuz_core/sessions/767797f1-b6e9-4190-9c51-8b5099df4a97 Co-authored-by: semiexp <7336994+semiexp@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
semiexp
April 13, 2026 00:21
View session
Contributor
|
litherslink has the no acyclic constraint as well |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Several puzzle files under
cspuz_rs_puzzles/src/puzzles/were constructing identical or near-identicalGraphstructures inline. This PR factors out the recurring patterns into reusable functions incspuz_rs/src/graph.rs.New functions
graph_8_neighbors(shape)— h×w graph with 8-neighbor (4-directional + diagonal) connectivity.Used by:
bramble.rs,cocktail.rs,tetrochain_common.rsgraph_8_neighbors_with_outer_vertex(shape)— same as above, plus a single outer vertex (h*w) connected to all border cells.Used by:
nurimaze.rs,city_space.rsactive_edges_acyclic(solver, edges: &BoolGridEdges)— adds a no-cycle constraint on a set of grid edges via the planar dual graph. An identical ~40-line block was copy-pasted verbatim inmintonette.rsandmove_common.rs.graph_slash_connectivity(shape)/graph_slash_connectivity_with_outer_vertex(shape)— sub-cell connectivity graph for slash/backslash puzzles, splitting each cell into 4 parity-indexed quadrants.Used by:
slashpack.rs/gokigen.rsExample: before → after