I have a network of vertices `Transaction`

connected undirectly to one another via other vertices. I would like to calculate the shortest path length from a Source `Transaction`

vertex to all other `Transaction`

vertices having the same attribute `id`

. This is the query:

```
CREATE QUERY tg_shortest_ss_no_wt (VERTEX source, SET<STRING> v_type, SET<STRING> e_type) RETURNS (ListAccum<INT>) {
MinAccum<INT> @min_dis;
OrAccum @or_visited;
ListAccum<INT> @@result;
##### Initialization #####
Source = {source};
Source = SELECT s
FROM Source:s
ACCUM s.@or_visited += true,
s.@min_dis = 0;
ResultSet = {};
##### Calculate distances #####
WHILE(Source.size()>0) DO
Source = SELECT t
FROM Source:s -(e_type:e)-> v_type:t
WHERE t.@or_visited == false AND t.id == s.id
ACCUM t.@min_dis += s.@min_dis + 1,
t.@or_visited += true
ORDER BY getvid(t);
ResultSet = ResultSet UNION Source;
END;
##### Show result only for Transaction nodes and modify shortest lengths #####
ResultSet = SELECT s
FROM ResultSet:s
WHERE s.type == "Transaction"
ACCUM @@result += s.@min_dis/2;
RETURN @@result;
}
```

The problem is that the query calculates the shortest path length from the Source `Transaction`

vertex to not only other `Transaction`

vertices but also all other vertices, which makes the query very slow. Does anyone know how to make the query not calculate the shortest path length to vertices which are not `Transaction`

? Thank you very much.