Find "external" incoming edges

I’m trying to create a query that will find all “external incoming edges” in a subgraph. With “subgraph” I mean all vertices that will be traversed when initiating traversal at a specified “RootNode” using something like:

SELECT FROM (TRAVERSE out() FROM (SELECT FROM V WHERE name=“RootNode”))

In the example image below the “subgraph” is the black vertices ( and edges ) and the edges I would like to find with a query is the green edges.

Graph

Is it possible to use a single query to find the green incoming edges where only the “RootNode” is specified as a parameter?

/PorkLip

Hi,
I tried you case with a schema like this:

and both these querys work
select expand(in()) from Test where name = "RootNode"

SELECT FROM (TRAVERSE in() FROM (SELECT FROM V WHERE name="RootNode"))

Hope it helps.

Regards,
Michela

That query will find the incoming edges on the root node, but I want to find all incoming edges on the complete “subgraph” (RootNode, Node2, Node3, Node4, Node5 in your example) that originates from nodes that not are part of the “subgraph”. I can traverse and a find the nodes of the complete subgraph using
SELECT FROM (TRAVERSE out() FROM (SELECT FROM V WHERE name=“RootNode”))
but now I need to find all incoming edges to all the “subgraph” nodes that not is a part of the “subgraph”
/PorkLip

This query seems find the “external” vertices that has edges in to the “subgraph” but it builds the “subgraph” twice. Maybe it possible to use “LET” in the query to build the subgraph once?

SELECT FROM (TRAVERSE in() FROM (
  SELECT FROM (TRAVERSE out() FROM (
    SELECT FROM V WHERE name='RootNode'))
  )
)
WHERE @rid NOT IN (
  SELECT @rid FROM (TRAVERSE out() FROM (
    SELECT FROM V WHERE name='RootNode'
  ))
)

/PorkLip