Re-added the optimization for symplectic graphs, added optimization for unitary graphs.