Nanodiamonds intercalated with metals: structure and diamond-graphite phase transitions