For each squarefree monomial ideal $I$, we associate a simple graph $G_I$ by using the first syzygies of $I$. The nodes of $G_I$ adre the generators of $I$, and two vertices $u_i$ and $u_j$ are adjacent if there exist variables $x$ and $y$ such that $xu_i=yu_j$. In the cases that $G_I$ is cycle or a tree, we show that $I$ has a linear resolution if and only if it has linear quotients and if and only if it is variable decomposable. In addition, with the same assumption on $G_I$, we characterize all squarefree monomial ideals with a linear resolution.