We define a new algebraic invariant of a graph G called the Ceresa-Zharkov class and show that it is trivial if and only if G is of hyperelliptic type, equivalently, G does not have as a minor the complete graph on 4 vertices or the loop of 3 loops. After choosing edge-lengths, this class specializes to an algebraic invariant of a tropical curve with underlying graph G that is closely related to the Ceresa cycle for an algebraic curve defined over C((t)).