We use a tree-based structure to represent mechanical systems comprising interconnected rigid bodies. Using this representation, we derive a simple algorithm to numerically calculate forward kinematic maps, body velocities, and their derivatives. The algorithm is computationally efficient and scales to large systems very well by using recursion to take advantage of the tree structure. Moreover, this method is less prone to modeling errors because each element of the graph is simple. The tree representation provides a natural framework to simulate mechanical dynamics with numeric computations rather than large symbolically-derived equations. In particular, the representation allows one to simulate systems in generalized coordinates using Lagrangian dynamics without symbolically finding the equations of motion. This method also applies to the relatively new variational integrators which numerically integrate dynamics in a way that preserve momentum and other symmetries. We show how to implement both integration schemes for an arbitrary system of interconnected rigid bodies in a computationally efficient way while avoiding symbolic equations of motion. We end with an example simulating a marionette; a mechanically complex, high degree-of-freedom system.