Pair and Graph implementation.