如何在 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,有两种获取结果的方法:

当我遍历时,我无法使用 .map() 我得到 AttributeError: 'ConceptSet' object has no attribute 'map'

当我尝试 collect_concepts 时,我得到 GraknError: Only use .collect_concepts on ConceptMaps returned by query()

map()collect_concepts(在客户端 Python 的下一版本中将是 removed)是 ConceptMap 答案类型的方法。 compute cluster 查询返回的结果是 ConceptSet 答案类型。 ConceptSetset() 方法,returns 聚类计算后的概念 id 集合。

Here you'll find the query types and their corresponding answer type and here 您会在 ConceptSet.

上找到有关 set() 方法的文档