The rand() function looks like it produces a random value of double type, thus the probability of repeating is extremely small. You can see with the following query what a sequence of 100 random values looks like.
unwind range(1,100) as indexes
return indexes, rand() as random
order by random
I thought you wanted 5 randomly selected paths between DOC and VOL nodes. It sounds like you also don't want any of the paths to have duplicate :Doc or :Vol nodes.
To help you better, can you explain your data? From your example, it looks like you have a one-to-many relationship between DOC nodes and VOL nodes, with each VOL node belongs to only one DOC node. Is this accurate? If this is true and you want 5 randomly selected paths between a DOC node and a VOL node, without repeating the DOC nodes, then you could try:
with n, rand() as r
order by r
with v, rand() as r
order by r
return n, v
The query first finds all the :Doc nodes, and randomly selects 5. It then performs a subquery for each of the 5 :Doc nodes separately to obtain all the :Vol nodes attached to that :Doc node. It then randomly selects one of the :Vol nodes attached to the :Doc node. Finally, it returns the ordered pair of :Doc and :Vol nodes. If I understand your data, you will get 5 randomly selected :Doc nodes, with one randomly selected :Vol node that is attached to the :Doc node; thus, giving you 5 randomly selected paths between :Doc and :Vol nodes, where no two :Doc nodes or :Vol nodes are alike.
If this is not what you are looking for, please describe your data so we can see if we can help.