Yarn dyeing is rather an art than a science. There are too many variables to give you exact formulas. There are some books and web sites that do just that and, if you need that kind of information, there is lots of it online and in books.
The number one question I get asked when I show some of the yarn that I have tinted with food coloring is "Will it stay or will it just wash out?” And my answer is yes, it's permanent, however I don't have the years of experience in this to tell you exactly how permanent. Ask me in a couple of years I will be able to tell you from personal experience. I have asked others who showed me their food dyed wool garment and the answer was "it has not washed out yet".
If the water is clear when you are rinsing the yarn, the color has set and will not wash out. It may fade, but there is no class of dyes that are 100% fade proof. Given enough time, number of washings and how you wash it, ie. soap used and exposure to UV light, color fades no matter what kind of dye or method of dyeing is used. Here are some pictures from the class, some of us got more on our hands than on the wool. Not to worry it washes off your hands not immediately but after doing a load of dishes and take a shower and I was almost all clean.