Don't bother using a UDF to do this: simply do it with client side code. Between doing batch reads, and list operations in database ( for pushing edges onto lists efficientlys ), and doing the edge traversal in your app server, you'll end up with a very efficient system.
If everything you can do fits into a single server's ram, simply use a local data structure (edges, vertexes). Don't bother with a database.
If you need multiple servers' worth of storage, portions of the graph will be on different servers anyway. So making a network request is fine - and networks are faster than you think, if you use batches.
Do make sure you use batch reads. This means you can get the next set of edges with a single network round trip. If you want to build highly scalable ( instead of single-server-limited ) graph traversal, this is as good as it gets.