refactor pairing task logic

not sure what dg.dfs_iterator(vertices[0]) is but if its an array:

dg.dfs_iterator(vertices[0]).map{ |v| path.append(v) }

for a nice ruby one-liner. (could also inject path into the map to be even cleaner)