An invariant theory approach to graph enumeration