A criterion for algebraicity of analytic set germs