How daffidwilde/matching works
matching is a Python library for constructing and solving four preference-based allocation games: stable marriage, hospital-resident, student allocation, and stable roommates. A user creates a game from player instances or preference dictionaries, calls its solver, and receives a dictionary-like matching; game classes also expose validity and stability checks. The graph separates game APIs, algorithm implementations, player models, and shared framework code. Edges follow the shown calls or documented workflow; some unsampled game internals are represented only where the README or source index supports the connection.
Main entry points: hospital.py Hospital · util.py Pair operations · stable_marriage.py Stable marriage · hospital_resident.py Hospital resident
Components 18
Game APIs
- Stable marriage
src/matching/games/stable_marriage.py - Hospital resident
src/matching/games/hospital_resident.py - Student allocation
src/matching/games/student_allocation.py - Stable roommates
src/matching/games/stable_roommates.py
Solving algorithms
- Marriage solver
src/matching/algorithms/stable_marriage.py - Hospital solver
src/matching/algorithms/hospital_resident.py - Allocation solver
src/matching/algorithms/student_allocation.py - Roommates solver
src/matching/algorithms/stable_roommates.py - Pair operations
src/matching/algorithms/util.py
Player models
- Player
src/matching/players/player.py - Hospital
src/matching/players/hospital.py - Project
src/matching/players/project.py - Supervisor
src/matching/players/supervisor.py
Shared framework
- Base player
src/matching/base.py - Game validation
src/matching/base.py - Solver warnings
src/matching/exceptions.py - Matching results
src/matching/matchings.py
Other components
- Library user
Connections 22
- Library user → Stable marriage: creates and solves
README.md - Library user → Hospital resident: creates and solves
README.md - Library user → Student allocation: creates and solves
README.md - Library user → Stable roommates: creates and solves
README.md - Stable marriage → Marriage solver: calls solver
src/matching/games/stable_marriage.py - Hospital resident → Hospital solver: calls solver
src/matching/games/hospital_resident.py - Student allocation → Allocation solver: calls solver
src/matching/games/student_allocation.py - Stable roommates → Roommates solver: calls solver
src/matching/games/stable_roommates.py - Marriage solver → Pair operations: imports helpers
src/matching/algorithms/stable_marriage.py - Hospital solver → Pair operations: uses pair helpers
src/matching/algorithms/hospital_resident.py - Allocation solver → Pair operations: uses pair helpers
src/matching/algorithms/student_allocation.py - Roommates solver → Pair operations: uses pair helper
src/matching/algorithms/stable_roommates.py - Hospital solver → Hospital: queries capacities
src/matching/algorithms/hospital_resident.py - Allocation solver → Hospital: queries capacity
src/matching/algorithms/student_allocation.py - Roommates solver → Player: proposes to players
src/matching/algorithms/stable_roommates.py - Hospital → Base player: inherits behavior
src/matching/players/hospital.py - Project → Hospital: inherits capacity model
src/matching/players/hospital.py - Supervisor → Hospital: inherits capacity model
src/matching/players/hospital.py - Stable marriage → Matching results: returns matching
README.md - Hospital resident → Matching results: wraps result
src/matching/games/hospital_resident.py - Student allocation → Matching results: wraps result
src/matching/games/student_allocation.py - Game validation → Solver warnings: raises warnings
src/matching/base.py