CS and math should be a solid basis here. To be honest I don't remember at all where I picked this stuff up - a lot of it comes from random disjoint fields like optimization theory, graph theory, etc. which impinge on econ all the time, although I couldn't tell you a definitive book on the subject(s)