circulation matrix generation