Local structure and electrical switching in chalcogenide glasses