     (set/difference candidates
                     rejects)))
 
+(defn arrows-in-bounding-box [db {:keys [start-x end-x start-y end-y]}]
+  (let [x0 (min start-x end-x)
+        x1 (max start-x end-x)
+        y0 (min start-y end-y)
+        y1 (max start-y end-y)]
+    (reduce (fn [acc d]
+              (let [origin (d/entity db (:e d))
+                    dest (d/entity db (:v d))
+                    origin-center (layers/center origin)
+                    dest-center (layers/center dest)
+                    [ox oy] (layers/layer-intercept origin dest-center)
+                    [dx dy] (layers/layer-intercept dest origin-center)]
+                (if (or
+                     ;; has endpoint
+                     (and (< x0 ox x1)
+                          (< y0 oy y1))
+                     ;; has endpoint
+                     (and (< x0 dx x1)
+                          (< y0 dy y1))
+
+                     (and
+                      (> (max ox dx) x0)
+                      (< (min ox dx) x1)
+                      (> (max oy dy) y0)
+                      (< (min oy dy) y1)
+                      (not= 4 (Math/abs (reduce + (map (partial det [ox oy] [dx dy])
+                                                       [[x0 y0] [x0 y1] [x1 y0] [x1 y1]]))))))
+                  (conj acc {:origin-id (:e d) :dest-id (:v d)})
+                  acc)))
+            #{} (d/datoms db :aevt :layer/points-to))))
+
 (defn draw-in-progress-drawing [state x y {:keys [force-even? delta]}]
   (let [[rx ry] (cameras/screen->point (:camera state) x y)
         [snap-x snap-y] (cameras/snap-to-grid (:camera state) rx ry)

    (assoc-in [:drawing :layers 0 :layer/text] value)
    (assoc-in [:drawing :layers 0 :bbox] bbox)))

(defn eids-in-bounding-box [db {:keys [start-x end-x start-y end-y] :as box}]
  (let [x0 (min start-x end-x)
        x1 (max start-x end-x)

                                above-y0-end-e)

                     (set/union below-y1-start-e
                                below-y1-end-e))]
    (set (filter (fn [eid]
                   ;; TODO: optimize by looking up start-x, end-x, etc. from the index ranges
                   ;;       we've already created
