The path is representing for users' browse history.
I'm considering which design structure should I take.
For example,
the red path means the user has browsed
[page A]-> [page B]-> [page B]-> [page C]-> [page B]-> [page A]
the blue path means the user has browsed
[page C]-> [page D]-> [page A]
If I want to select whose browse path is page C earlier than page A ,
The answer should be blue path
How could I design the query in cypher query ,
Which design is suitable for my case?
Thank you.
design 1 (each path share the same nodes)

design 2 (each path should has its own nodes.)

UPDATE
I tried to apply your query in my model,
I want to know if the node 5231 is before than node 7222
But it couldn't get any output.
MATCH p=(x)-[*0..]->(y {code: '5231'})
WHERE NOT ()-->(x)
RETURN p
ORDER BY LENGTH(p)
LIMIT 1;


Creating disjoint subgraphs for each path is wasteful, and probably would not make it any easier to solve your use case.
Here is a query (that works with a unified graph) that finds the path (or one of them, if there is a tie) in which
Cappears the earliest.This particular query ends the paths it finds at the
Cnode, and does not bother to included any subsequent nodes (there could be many branches, and it is not clear which branch you would want to follow).