Abstract We describe an algorithm that identifies a subnetwork of brain regions involved in producing a task-specific behavior, here visuomotor behavior, from an anatomically defined primate brain connectome. The algorithm first finds the brain regions connected to an output region (here, primary motor cortex, M1) by one connection. It then identifies all regions, termed layer 2 regions, connected to these layer 1 regions by one connection.