How to use the atomic coordinates to determine the connectivity of all atoms.

Hi,

I got all the atomic coordinates (x,y,z) in COSMO-file, now I want to use those coordinates to determine the connectivity of all atoms.

For example, in CH4,    C connected by four H, and every H connected by one C.

Is there anyone knows about it? Thank u very much.