Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Class solving stable marriage problem

branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

README.textile

Shadchan

This gem provides a class for solving the Stable Marriage problem and Stable Roommates problem.

Installation
gem install shadchan

Usage

require 'shadchan'
# stable marriage example
shadchan = Shadchan::Shadchan.new [0, 2, 1], [2, 0, 1], [0, 2, 1], [1, 0, 2], [0, 2, 1], [0, 1, 2]
shadchan.match #=> [[0, 2], [1, 0], [2, 1]]
shadchan.match_men #=> [1, 2, 0]
shadchan.match_women #=> [2, 0, 1]

# stable roommates example
roomie = Shadchan::Roomie.new [2,3,1,5,4],[5,4,3,0,2],[1,3,4,0,5],[4,1,2,5,0],[2,0,1,3,5],[4,0,2,3,1]
roomie.match #=> [5,4,3,1,2,0]
Something went wrong with that request. Please try again.