So, here's a way to do it with existing cypher functions. I don't promise it's super performant, but give it a shot. We're building our collection with reduce, using an accumulator tuple with a collection and the last node we looked at, so we can check that it's connected to the next node. This requires 2.0's case/when syntax--there may be a way to do it in 1.9 but it's probably even more complex.
START a=node:node_auto_index(name="Trinity")
MATCH a-[*]-b
WHERE a <> b
WITH distinct a,b
MATCH p = allshortestpaths(a-[*]-b)
RETURN extract(x in nodes(p): x.name?), // a concise representation of the path we're checking
head(
reduce(acc=[[], head(nodes(p))], x IN tail(nodes(p)): // pop the first node off, traverse the tail
CASE WHEN ALL (y IN tail(acc) WHERE y-->x) // a bit of a hack because tail(acc)-->x doesn't parse right, so I had to wrap it so I can have a bare identifier in the pattern predicate
THEN [head(acc) + 0, x] // add a 0 to our accumulator collection
ELSE [head(acc) + 1, x] // add a 1 to our accumulator collection
END )) AS in_line
http://console.neo4j.org/r/v0jx03
Output:
+---------------------------------------------------------------------------+
| extract(x in nodes(p): x.name?) | in_line |
+---------------------------------------------------------------------------+
| ["Trinity","Morpheus"] | [1] |
| ["Trinity","Morpheus","Cypher"] | [1,0] |
| ["Trinity","Morpheus","Cypher","Agent Smith"] | [1,0,0] |
| ["Trinity","Morpheus","Cypher","Agent Smith","The Architect"] | [1,0,0,0] |
| ["Trinity","Neo"] | [1] |
| ["Trinity","Neo",<null>] | [1,1] |
+---------------------------------------------------------------------------+
Note: Thanks @boggle for the brainstorming session.