You are viewing a single comment's thread.

view the rest of the comments →

0
2

[–] CaptainParanoia 0 points 2 points (+2|-0) ago  (edited ago)

You can model it as a directed graph, your edges are compatible donations (donor -> patient) and family relations (patient -> family member). People who donate and don't want anything in return have incoming edges from all patients.

Then you can pick a patient A and use Dijkstra's algorithm to find the shortest path A -> A. That should give you a chain of trades.