You are looking for the connected components of the undirected graph induced by your adjacency list.
G = sparse(A(:,1),A(:,2),1,max(A(:,2)),max(A(:,2)));
[num labels] = graphconncomp( G+G' ); % symmetric for undirected graph
Resulting labels
1 1 1 1 1 1 2 1 2 2 2 2 2
As you can see, 1-6 and 8 are labeled '1'
while 9 to 12 and 7 are labeled '2'
.
See graphconncomp
for more information.