Hi TG Team,

Suppose I have a graph of two vertex types - Car and Accident. The relationship is Car - (INVOLVED_IN) -> Accident. Accident vertex has a datetime attribute called “time”. Now for the accidents originated from each car, I want to compare the accident time between any two accidents. If the time difference is bigger smaller than a threshold, I want to store the car vertex and the corresponding accident pairs into a mapaccum.

What is the most efficient way to do this? My attempt is to first create a mapaccum storing Car vertex as key and a setaccum of corresponding accidents as value. Then I write a nested for loop to loop through each claim set twice, and determine whether the time difference is greater than the threshold. But the problem is that when using IF or CASE WHEN, there must be only one operation after the the THEN statement, which means that I need to add both accidents from a pair to a set or something in just one line, and I can’t figure out how.

I was also considering creating undirected edges between accidents to do the comparison, but since I have too many accidents in my graph, it will lead to way too many undirected edges. I’ m not sure if this is a good way.

Any help? Thanks !