Its a complex algorithm in the background, but as a high level, it takes into consideration In/Out Anchors, Src/Dst IPs and Call IDs and tries to match call legs from different vendors. Matching between the vendors is vastly different, vendor to vendor.
If my reply answered your question please click on the 'Accept as Solution' button to help others find the answer.
Thanks,
Shoaib