essentialGraph function

Construct the essential graph