A general and efficient representation of ancestral recombination graphs