EDIT 2:
I printed the arrays, as requested by Boris Guéry:
Array
(
[0] => Array //Each of these contains node id's returned by a query
(
[0] => 12
[1] => 11
[2] => 10
[3] => 9
[4] => 8
[5] => 7
)
[1] => Array
(
[0] => 10
[1] => 9
[2] => 8
[3] => 7
)
[2] => Array
(
)
[3] => Array
(
[0] => 11
[1] => 10
[2] => 9
[3] => 8
[4] => 7
)
)
Array //This one uses the node ids from the previous array as keys, the values are the number of occurences.
(
[12] => 1
[11] => 2
[10] => 3
[9] => 3
[8] => 3
[7] => 3
)