如何在 Grakn 中使用 Python Client 计算连通分量
How to compute connected-component using Python Client in Grakn
我想使用 Python 客户端获取集群(或连接的组件)。我可以通过以下方式使用 graql 来做到这一点:
compute cluster in [company, c2c], using connected-component, where contains=V86179944;
我也可以 运行 使用 Python 进行查询:
query = "compute cluster in [company, c2c], using connected-component, where contains=V86179944;"
with GraknClient(uri="localhost:48555") as client:
with client.session(keyspace=keyspace) as session:
with session.transaction().read() as transaction:
answer_iterator = transaction.query(query)
# What to do here??
但是,我不知道如何访问结果。根据 python client docs,有两种获取结果的方法:
- 遍历
- 使用
collect_concepts()
当我遍历时,我无法使用 .map()
我得到 AttributeError: 'ConceptSet' object has no attribute 'map'
当我尝试 collect_concepts
时,我得到 GraknError: Only use .collect_concepts on ConceptMaps returned by query()
我想使用 Python 客户端获取集群(或连接的组件)。我可以通过以下方式使用 graql 来做到这一点:
compute cluster in [company, c2c], using connected-component, where contains=V86179944;
我也可以 运行 使用 Python 进行查询:
query = "compute cluster in [company, c2c], using connected-component, where contains=V86179944;"
with GraknClient(uri="localhost:48555") as client:
with client.session(keyspace=keyspace) as session:
with session.transaction().read() as transaction:
answer_iterator = transaction.query(query)
# What to do here??
但是,我不知道如何访问结果。根据 python client docs,有两种获取结果的方法:
- 遍历
- 使用
collect_concepts()
当我遍历时,我无法使用 .map()
我得到 AttributeError: 'ConceptSet' object has no attribute 'map'
当我尝试 collect_concepts
时,我得到 GraknError: Only use .collect_concepts on ConceptMaps returned by query()