A gain graph (Γ, g, G) is a graph Γ = (V,E) together with a group G, the gain group, and a homomorphism g, the gain function, from the free group F (E) on the edge set E into G. We think of the edges of G as oriented in an arbitrary but fixed way, so that if e is an edge in one direction, then e−1 is the same edge in the opposite direction; thus g(e−1) = g(e)−1. A gain graph is balanced if for ...