How to create a graph connecting predecessors and successors in time from a timeseries table in PostgreSQL 10?
SELECT t1.id
     , t2.id
FROM sensor_time_series t1
INNER JOIN sensor_time_series t2 ON  t1.sensor_id = t2.sensor_id 
                                 AND t1."time" &lt; t2."time"
LEFT JOIN sensor_time_series t3 ON  t1.sensor_id = t3.sensor_id 
                                AND t1."time" &lt; t3."time" 
                                AND t3."time" &lt; t2."time"
WHERE t3.id IS NULL;


or (thanks to Lennart for the idea)

SELECT t1.id
     , t2.id
FROM ( SELECT id
            , sensor_id
            , lead("time") over(partition by sensor_id order by time) AS leading
       FROM sensor_time_series ) t1
INNER JOIN sensor_time_series t2 ON  t1.sensor_id = t2.sensor_id 
                                 AND t1.id != t2.id
WHERE t2."time" = t1.leading;


In the last query the join/where conditions can be freely moved between those sections for the best visibility.

fiddle