How to find relationship between two nodes?

In addition to Minhaj’s suggestion. You could also do this with Recurse Query. The only problem is that you need to hard type all possible edges (in shortest you have also to do this) to accomplish that. e.g:

{
	M as var(func: type(Person)) @filter(eq(name, 'Martin Sheen')
	O as var(func: type(Person)) @filter(eq(name, 'Oliver Stone')

	q(func: uid(O) @recurse(depth: 50, loop: true) {
		friend @filter(uid(M))
		~friend @filter(uid(M))
		follows @filter(uid(M))
		~follows @filter(uid(M))
	}
}

My idea would be to reduce this to:

{
	M as var(func: type(Person)) @filter(eq(name, 'Martin Sheen')
	O as var(func: type(Person)) @filter(eq(name, 'Oliver Stone')

	q(func: uid(O) @recurse(depth: 50, loop: true) {
		expand(User) @filter(uid(M))
	}
}

It would expand and apply the same filter to all edges. Today expand only supports Type filter.

I have created an issue for this