# DAG - why is the path open?

I have this DAG

As I understand it, the paths D <- Ed -> St -> P -> Su and D <- A -> P -> Su are both closed because the contain the collider P. If I condition on P, both these paths will be open.

But that doesn't seem to be the case according to dagitty:

library(dagitty)

d = dagitty('dag {
A -> D
A -> P
D -> Em
D -> Su
Ed -> D
Ed -> St
Em -> Su
P -> Su
Se -> D
Se -> Su
St -> P
St -> Su
}')

p = paths(d, from = 'D', to = 'Su')
p$$path[p$$open]

[1] "D -> Em -> Su"            "D -> Su"                  "D <- A -> P -> Su"
[4] "D <- Ed -> St -> P -> Su" "D <- Ed -> St -> Su"      "D <- Se -> Su"


Also if I condition on P, it doesn't open the two paths mentioned at the start, but does open the path D <- A -> P <- St -> Su.

Have I misunderstood the backdoor criterion? Does it have something to do with P being immediately next to the outcome Su?

$$P$$ would only be a collider if you were examining a path such as $$A\to P\leftarrow St.$$ That is, whether a node is a collider or not is actually dependent on the path you take through that node.
So both the paths $$D\leftarrow Ed\to St\to P\to Su$$ and $$D\leftarrow A\to P\to Su$$ have no colliders in them. You can think of it this way: suppose you took the subgraph of your graph consisting only of the nodes $$\{A, Ed, St, P, Su\}.$$ Would the first path you mentioned have a collider in it? Answer: no.
If you are considering $$D$$ as your cause, and $$Su$$ as your effect, you have a LOT of backdoor paths from $$D$$ to $$Su$$ that are unblocked. But if you were to condition on, say, the set $$\{Se, St, P\},$$ you would block them all.
In this case, P isn't a collider in neither of the two paths you've picked. In fact, it's a mediator in both. The only back-door path in which P is a collider is D <- A -> P <- St -> Su. As you say, this back-door path is automatically closed because it has a collider.