Basic graph algorithms.