cycle canceling algorithm and refactoring of edges and vertices (add balance and cost / capacity)