Skip to content

[Feat] Constraint-aware neighbour selection to enforce min/max node degree during graph construction #120

@Shivampal157

Description

@Shivampal157

When creating graphs from coordinates, we currently rely on distance-based neighbor selection (radius/kNN variants), but there is no direct mechanism to enforce degree constraints during edge selection itself. In practice this can produce local hubs or under-connected nodes depending on coordinate density.

I propose adding a constraint-aware neighbour selection step that enforces configurable degree bounds while preserving locality.

Proposed API

  • min_out_degree (default: None)
  • max_out_degree (default: None)
  • min_in_degree (default: None)
  • max_in_degree (default: None)
  • repair_strategy ("knn_fallback" / "radius_expand")

Expected behavior

  1. Build candidate neighbors using existing distance logic.
  2. Apply degree-constrained edge selection (local + deterministic).
  3. Run a repair pass for nodes violating minimum degree.
  4. Keep graph directed and preserve required edge attributes (len, vdiff).

Why this is useful

  • Prevents unstable degree extremes in irregular/sparse coordinate regions.
  • Makes graph quality more controllable at construction time (not only post-hoc diagnostics).
  • Helps downstream message passing behave more consistently across domains with varying point density.

Acceptance criteria

  • Degree constraints can be enabled/disabled via function arguments.
  • Constraint pass works for both sparse and dense coordinate distributions.
  • Graph remains valid for existing save/export workflows.
  • Tests added for:
    • uniform grid
    • jittered irregular coordinates
    • clustered sparse coordinates
  • Reproducible output with fixed seed (where randomness is used).

Notes

This is intentionally scoped to construction-time edge selection, not visualization or additional diagnostics.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions