While an \(O(n^{\omega} + 2^{2g}n^2 + m)\) time deterministic algorithm was known for undirected graphs, the use of the underlying field \(\mathbb{Q}\) in the directed case (as opposed to \(\mathbb{Z}_2\) for the undirected case) presents extra challenges. It turns out that some of our new observations are useful for both variants of the problem, so we present an \(O(n^{\omega} + n^2 g^2 \log g + m)\) time deterministic algorithm for undirected graphs as well.