There are several variations on this theme, Trainyard being the outstanding example, but you could do a lot worse than Paper train HD, so download it while you can for free from here.
From the publisher: “Woozzle is puzzle-logic game for iOS devices. Lot of hours of fun, from easy levels to brain-teasing mazes with special features and amazingly balanced gameplay. All gift-wrapped in beautiful graphics. Meet Woozzle, a new world of crazy marbles. Discover and learn key principles of the game to pass each level.”