The three Gallon Problem : Suppose you have 8L, 5L and a 3L bucket with you, The buckets have no measurement lines on them and you are asked to measure exactly 4L of water using the three buckets. How could you measure exactly 4L water using only those buckets?
The complete graph for the problem of 8L,5L and 3L gallon problem :
Here is a solution with graph theory implemented by python for this special case and also for generalized situation.