Improve generic graph implementation.

This will serve as the basis for the feature graph, metadata graph, and
logical filesystem graph in the system.