strongly connectd components function