Can Write LPA with PIE or Pregel with GAE in GraphScope?
- Dominant language
- C++
- Stars
- 3.6k
- Forks
- 468
- Avg merge
- 29m
- Merged PRs (30d)
- 1
Description
**Is your feature request related to a problem? Please describe.**
#2601
With this doc https://graphscope.io/docs/analytics_engine.html#
Can write algo in [PIE、Pregel、Java]
Can distributed LPA be realized through the above framework?
This is chat-gpt answer
IN Pregel
```
from graphscope.analytical.udf.decorators import pregel
from graphscope.framework.app import AppAssets
@pregel(vd_type='int', md_type='double')
class LPA_Pregel(AppAssets):
@staticmethod
def Init(v, context):
v.set_value(v.id())
@staticmethod
def Compute(messages, v, context):
labels = {}
max_label_count = 0
for message in messages:
if message not in labels:
labels[message] = 0
labels[message] += 1
max_label_count = max(max_label_count, labels[message])
if v.value() not in labels:
labels[v.value()] = 0
labels[v.value()] += 1
max_label_count = max(max_label_count, labels[v.value()])
for label, count in labels.items():
if count == max_label_count:
v.set_value(label)
break
for edge in v.outgoing_edges():
v.send(edge.vertex(), v.value())
@staticmethod
def Combine(messages):
label_count = {}
for label in messages:
if label not in label_count:
label_count[label] = 0
label_count[label] += 1
max_label = None
max_count = 0
for label, count in label_count.items():
if count > max_count:
max_count = count
max_label = label
return max_label
```
but there is some mistake when running LPA_Pregel
```
# load my algorithm
my_app = LPA_Pregel()
ret = my_app(graph)
```
log
```
Error compiling Cython file:
------------------------------------------------------------
...
max_count = count
max_label = label
return max_label
cdef public void Init(Vertex[int32_t, double] &v, Context[int32_t, double] &context):
v.set_value(v.id())
^
------------------------------------------------------------
LPA_Pregel_1682080147.pyx:46:20: Cannot assign type 'string' to 'const int32_t'
Error compiling Cython file:
------------------------------------------------------------
...
max_label_count = max(max_label_count, labels[v.value()])
for label, count in labels.items():
if count == max_label_count:
v.set_value(label)
break
for edge in v.outgoing_edges():
^
------------------------------------------------------------
LPA_Pregel_1682080147.pyx:64:32: Call with wrong number of arguments (expected 1, got 0)
Error compiling Cython file:
------------------------------------------------------------
...
max_label_count = max(max_label_count, labels[v.value()])
for label, count in labels.items():
if count == max_label_count:
v.set_value(label)
break
for edge in v.outgoing_edges():
^
------------------------------------------------------------
LPA_Pregel_1682080147.pyx:64:16: Cannot convert Python object to 'Neighbor[int32_t,double]'
```
Contributor guide
Assessment
This issue has not been assessed yet.