$x^{2} d y+\left(x y+y^{2}\right) d x=0 ; y=1$ when $x=1$
$x^{2} d y+\left(x y+y^{2}\right) d x=0$
$\Rightarrow x^{2} d y=-\left(x y+y^{2}\right) d x$
$\Rightarrow \frac{d y}{d x}=\frac{-\left(x y+y^{2}\right)}{x^{2}}$ ...(1)
Let $F(x, y)=\frac{-\left(x y+y^{2}\right)}{x^{2}}$.
$\therefore F(\lambda x, \lambda y)=\frac{\left[\lambda x \cdot \lambda y+(\lambda y)^{2}\right]}{(\lambda x)^{2}}=\frac{-\left(x y+y^{2}\right)}{x^{2}}=\lambda^{0} \cdot F(x, y)$
Therefore, the given differential equation is a homogeneous equation.
To solve it, we make the substitution as:
y = vx
$\Rightarrow \frac{d}{d x}(y)=\frac{d}{d x}(v x)$
$\Rightarrow \frac{d y}{d x}=v+x \frac{d v}{d x}$
Substituting the values of $y$ and $\frac{d y}{d x}$ in equation $(1)$, we get:
$v+x \frac{d v}{d x}=\frac{-\left[x \cdot v x+(v x)^{2}\right]}{x^{2}}=-v-v^{2}$
$\Rightarrow x \frac{d v}{d x}=-v^{2}-2 v=-v(v+2)$
$\Rightarrow \frac{d v}{v(v+2)}=-\frac{d x}{x}$
$\Rightarrow \frac{1}{2}\left[\frac{(v+2)-v}{v(v+2)}\right] d v=-\frac{d x}{x}$
$\Rightarrow \frac{1}{2}\left[\frac{1}{v}-\frac{1}{v+2}\right] d v=-\frac{d x}{x}$
Integrating both sides, we get:
$\frac{1}{2}[\log v-\log (v+2)]=-\log x+\log \mathrm{C}$
$\Rightarrow \frac{1}{2} \log \left(\frac{v}{v+2}\right)=\log \frac{\mathrm{C}}{x}$
$\Rightarrow \frac{v}{v+2}=\left(\frac{\mathrm{C}}{x}\right)^{2}$
$\Rightarrow \frac{\frac{y}{x}}{\frac{y}{x}+2}=\left(\frac{\mathrm{C}}{x}\right)^{2}$
$\Rightarrow \frac{y}{y+2 x}=\frac{\mathrm{C}^{2}}{x^{2}}$
$\Rightarrow \frac{x^{2} y}{y+2 x}=\mathrm{C}^{2}$ ...(2)
Now, y = 1 at x = 1.
$\Rightarrow \frac{1}{1+2}=\mathrm{C}^{2}$
$\Rightarrow \mathrm{C}^{2}=\frac{1}{3}$
Substituting $\mathrm{C}^{2}=\frac{1}{3}$ in equation (2), we get:
$\frac{x^{2} y}{y+2 x}=\frac{1}{3}$
$\Rightarrow y+2 x=3 x^{2} y$
This is the required solution of the given differential equation.