Motivated by electricity markets we introduce in this paper a general network market model, in which agents are located on the nodes of a graph, a traded good can travel from one place to another through edges considering quadratic losses. An independent operator has to match locally production and demand at the lowest expense. As argued in our previous paper “Cost-minimizing regulations for a wholesale electricity market” this setting is relevant to describe some real electricity markets, pricing behavior and market power coming from the fact that generators can bid above their true value. In a general setting of many distributed generator agents connected by a transmission network, bidding piece-wise linear cost functions, we propose a pricing optimal mechanism model to reduce market power. Our main results are the expression of the optimal mechanism design, two algorithms for the allocation problem and market power estimations. To deduce these nice properties, we intensively use convex analysis and some monotone behaviors of the set-valued maps involved. Furthermore, these algorithms make it possible to numerically compute a Nash equilibrium for the procurement auction, which is important to compare the optimal mechanism and the standard auction setting. Finally, we also show some interesting examples. Joint work with Benjamin Heymann, Ecole Polytechnique, France.