A procedure to determine optimal partition of weighted hypergraphs through a network flow analogy