completed clustering coefficient function