The only animal of which the complete neural circuitry is known at the submicroscopical level is the nematode Caenorhabditis elegans. This anatomical knowledge is complemented by functional insight from electrophysiological experiments in the related nematode Ascaris lumbricoides, which show that Ascaris motor neurons transmit signals electrotonically and not with unattenuated spikes. We developed a mathematical model for electrotonic neural networks and applied it to the motor nervous system of nematodes. This enabled us to reproduce experimental results in Ascaris quantitatively. In particular, our computed result of the velocity v approximately equal to 6 cm/s of neural excitations in the Ascaris interneurons supports the simple hypothesis that the so-called rapidly moving muscular wave is produced by a neural excitation traveling at the same speed in the interneuron as the muscular wave. In C. elegans, the computed velocity v approximately equal to 8-30 cm/s of signals in the interneurons is much larger than the observed velocity v approximately equal to 0.2 cm/s of the body wave. Therefore, the hypothesis that the muscular wave is produced by a synchronous neural excitation wave cannot hold for C. elegans. We argue that stretch receptor control is the most likely mechanism for the generation of body waves used in the locomotion of C. elegans. Extending the simulation to larger groups of neurons, we found that the neural system of C. elegans can operate purely electrotonically. We demonstrate that the same conclusion cannot be drawn for the nervous system of Ascaris, because in the long (l approximately equal to 30 cm) interneurons the electrotonic signals would be too strongly attenuated. This conclusion is not in contradiction with the experimental findings of electrotonic signal propagation in the motor neurons of Ascaris because the latter are shorter (l approximately equal to 5 cm) than the interneurons.