Code simulating Adaptation and Learning in Diffusion Networks