BP algorithm written in C#