Currently, I have been using Dgraph for a time, all is fine but I really want to find a way to apply those graph algorithms.

I know there is one algorithm(K shortest path) has been established. But how can I apply other algorithms？

The only way I know is to use pydgraph to connect dgraph, then write query to get json data, finally handle those results and apply functions(like pagerank) writen by myself to get output. Something just like this:

```
client = pydgraph.DgraphClient(client_stub)
def d_Pagerank(relation,beta):
query = """{{
bladerunner(func: has({})) {{
name
friend{{
name
}}
}}
}}""".format(relation)
res = client.txn(read_only=True).query(query)
res = json.loads(res.json)['bladerunner']
res = np.array([[i['name'],i['friend'][0]['name']] for i in res])
k1,k2,k3 = np.unique(res,return_inverse=True,return_index=True)
k3 = k3.reshape(res.shape)
weights = [1]*len(k1)
G = sparse.csr_matrix((weights, (k3[:,0], k3[:,1])), shape=(len(k1), len(k1)))
return pagerank(G, beta)
```

By this I can successfully get results:

```
%%time
d_Pagerank('friend',0.85)
```

```
CPU times: user 5.63 ms, sys: 1.94 ms, total: 7.57 ms
Wall time: 11 ms
Out[92]:
array([0.25, 0.25, 0.25, 0.25])
```

But, it will kill me if I have write each algorithm by myself (I need to consider memory and distributed problems)

Noticing there is already someone push an image including some algorithms how-about-doing-some-graph-compute-in-a-query .But I am afraid it is too old and may not stable.

Else build spark-dgraph-connector, I think this should be a decent way to apply agorithms from spark for dgraph. However, I am totally new for Spark and don’t know how to use such connector. Also, I have no one I can turn to…

Therefore, I really want to know is there anyone can help me out about how to implement those algorithms in Dgraph?