Use unique_ptr to store graph nodes.