Edge Documentation

retrieve_edge

查询边。通过边id查询边。

函数声明

def retrieve_edge(self, edge_id: str) -> Edge

参数说明

Parameter

Optional

Type

DESC

edge_id

Y

str

边id,不能为空。

响应参数

Parameter

Type

DESC

Edge

查询的边信息。

异常

Type

DESC

ParamException

参数格式不正确,当边id为空或格式不正确时将抛出异常。

DatabaseException

数据库内部异常。

示例

from graphdbapi.types.graph import Edge
# 获取边id为'00000000000000000001000000000002'的边
edge = graph.retrieve_edge('00000000000000000001000000000002')

# 打印边信息
print(edge)

retrieve_edges_by_type

查询边类型下所有边。迭代获取某个类型的所有边信息。

函数声明

def retrieve_edges_by_type(self, type: str) -> Iterator[Edge]

参数说明

Parameter

Optional

Type

DESC

type

Y

str

边类型,不能为空。

响应参数

Parameter

Type

DESC

Iterator[Edge]

边信息迭代器。

异常

Type

DESC

ParamException

参数格式不正确,当类型为空时将抛出异常。

DatabaseException

数据库内部异常。

示例

from graphdbapi.types.graph import Edge
# 获取person_to_person类型下的所有边
for edge in graph.retrieve_edges_by_type("person_to_person"):
    print(edge)

retrieve_all_edges

查询所有边。迭代获取所有类型的所有边。

函数声明

def retrieve_all_edges(self) -> Iterator[Edge]

响应参数

Parameter

Type

DESC

Iterator[Edge]

边信息迭代器。

异常

Type

DESC

DatabaseException

数据库内部异常。

示例

from graphdbapi.types.graph import Edge
for edge in graph.retrieve_all_edges():
    print(edge)

get_edge_count

查询边个数。查询当前类型边总数。

函数声明

def get_edge_count(self, type: str) -> int

参数说明

Parameter

Optional

Type

DESC

type

Y

str

点类型,不能为空。

响应参数

Parameter

Type

DESC

int

边个数

异常

Type

DESC

ParamException

参数格式不正确,当类型为空时将抛出异常。

TypeNotFoundException

边类型在图中不存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

# 查看person_to_person的边总数
print(graph.get_edge_count("person_to_person"))

get_all_edge_count

查询边个数。查询图中边总数。

函数声明

def get_all_edge_count(self) -> int

响应参数

Parameter

Type

DESC

int

边个数

异常

Type

DESC

DatabaseException

数据库内部异常。

示例

# 查看图中边总数
print(graph.get_all_edge_count())

insert_edge_by_vertex_id

新增边。通过起始点id和终止点id新增一条边,属性为可选项。

函数声明

def insert_edge_by_vertex_id(self, from_id: int, to_id: int, type: str, property: Union[Dict[str, Any], None]) -> Edge

参数说明

Parameter

Optional

Type

DESC

from_id

Y

int

起始点id,不能小于0。

to_id

Y

int

终止点id,不能小于0。

type

Y

str

边类型,不能为空。

property

N

Dict[str, Any]

边属性。填None或{}时,表示新增的边没有属性值。

响应参数

Parameter

Type

DESC

Edge

新增后的边信息。

异常

Type

DESC

ParamException

参数格式不正确,当起始点id、终止点id小于0、type为空或property输入的属性类型不支持时将抛出异常。

TypeNotFoundException

边类型在图中不存在时将抛出异常。

TypeErrorException

起始点和终止点的类型不是作为边类型的起始类型和终止类型时将抛出异常。

VertexNotFoundException

起始点或终止点在图中不存在时将抛出异常。

PropertyNotFoundException

属性名在边类型中没有定义时将抛出异常。

ValueFormatException

属性值类型错误时将抛出异常。

DatabaseException

数据库内部异常。

示例

from graphdbapi.types.graph import Edge
# 添加一条由(id:0)指向(id:100)的person_to_person边
edge = graph.insert_edge_by_vertex_id(0,100,"person_to_person",None)
print(result)

update_edge

更新边。通过边id更新边。

函数声明

from graphdbapi.types.graph import Edge
def update_edge(self, edge_id: str, property: Dict[str, Any], is_merge: bool) -> Edge

参数说明

Parameter

Optional

Type

DESC

edge_id

Y

str

边id,不能为空。

property

Y

Dict[str, Any]

边属性。

is_merge

Y

bool

为true时集合属性追加,为fasle属性覆盖

响应参数

Parameter

Type

DESC

Edge

更新后的边信息。

异常

Type

DESC

ParamException

参数格式不正确,当边id为空或格式不正确、property输入的属性类型不支持时将抛出异常。

EdgeNotFoundException

边在图中不存在时将抛出异常。

PropertyNotFoundException

属性名在边类型中没有定义时将抛出异常。

ValueFormatException

属性值类型错误时将抛出异常。

DatabaseException

数据库内部异常。

示例

from graphdbapi.types.graph import Edge
#修改边000000000290008A000E000005FCA85C的timestamp属性
edge = graph.update_edge("000000000290008A000E000005FCA85C", {"timestamp": int(time.time())}, True)
print(edge)

delete_edge

删除边。通过边id删除边。

函数声明

def delete_edge(self, edge_id: str) -> None

参数说明

Parameter

Optional

Type

DESC

edge_id

Y

str

边id,不能为空。

异常

Type

DESC

ParamException

参数格式不正确,当边id格式不正确时将抛出异常。

EdgeNotFoundException

边在图中不存在时将抛出异常。

DatabaseException

数据库内部异常

示例

# 删除边000000000290008A000E000005FCA85C
graph.delete_edge("000000000290008A000E000005FCA85C")

delete_edges

批量删除边。通过边id删除边。如果不存在或删除失败,则会返回异常结果集。 结果按传入顺序构成集合,集合中包含成功信息和错误信息。通过{ResponseItem#is_error()}方法判断操作是否失败。

函数声明

def delete_edges(self, items: List[str]) -> List[str]

参数说明

Parameter

Optional

Type

DESC

items

Y

List[str]

边id集合,不能为空。

响应参数

Parameter

Type

DESC

List[str]

批量操作结果集。边删除成功时返回None,边删除失败时返回错误信息。

异常

Type

DESC

ParamException

参数格式不正确。当参数集合为空,以及集合中存在None、边id格式不正确时将抛出异常。

DatabaseException

数据库内部异常。

示例

items = [
    "00000000000000000001000000000008",
    "00000000000000000001000000000008",
    "00000000000000000001000000000009",
]
#
res = graph.delete_edges(items)
# 打印结果信息
print(res)

search_edges_by_index

通过索引,查找边数据, 返回边id迭代器,所查询的边属性必须存在索引

函数声明

def search_edges_by_index(self, type_name: str, prop_name: str, data: Any, skip: int, limit: int) -> Iterator[str]

参数说明

Parameter

Optional

Type

DESC

type_name

Y

str

类型名

prop_name

Y

str

属性名

data

Y

Any

所查找的值

skip

Y

int

跳过条目

limit

Y

int

限制返回数量

响应参数

Parameter

Type

DESC

Iterator[int]

边id迭代器

异常

Type

DESC

ParamException

参数格式不正确时将抛出异常。

DatabaseException

数据库内部异常。

示例

# 查询20个timestamp为1635852783的follow边,并返回边id的迭代器
print(list(graph.search_edges_by_index("follow", "timestamp", 1635852783, 0, 20)))

insert_batch_edge_by_vertex_pk

批量新增边,点不存在创建点。通过起止点类型和pk、边类型来新增边,属性可选。

边信息中的create_from、create_to在此方法中不生效。

函数声明

def insert_batch_edge_by_vertex_pk(self, items: List[EdgeInfoByVertexPk], create_vertex_if_absent=False) -> None

参数说明

Parameter

Optional

Type

DESC

items

Y

List[EdgeInfoByVertexPk]

参数集合,不能为空。

create_vertex_if_absent

N

bool

是否创建起止点[default: False]

示例

import time

from graphdbapi.v1.graph import EdgeInfoByVertexPk

infos = [
    EdgeInfoByVertexPk.init_edge_info_by_vertex_pk(str(time.time_ns() + 1000), "test", str(time.time_ns() + 2000), "test", "e", None),
    EdgeInfoByVertexPk.init_edge_info_by_vertex_pk(str(time.time_ns() + 3000), "test", str(time.time_ns() + 4000), "test", "e", None),
]

graph.insert_batch_edge_by_vertex_pk(infos, False)

for info in infos:
    print(graph.retrieve_vertex_by_pk(info.get_from_pk(), info.get_from_type()))
    print(graph.retrieve_vertex_by_pk(info.get_to_pk(), info.get_to_type()))
    cypher = 'match (:test {id: "%s"})-[r]-(:test {id: "%s"}) return r' % (info.get_from_pk(), info.get_to_pk())
    edges = graph.execute_cypher(cypher)
    for _ in edges:
        print(_)

insert_edges_by_vertex_pk

批量新增边。通过起始点pk和终止点pk来新增边。

找不到起始点和终止点时会通过create_from和create_to来决定是否新增无属性的起始点和终止点。

该方法与{Graph#insert_edges_by_vertex_id(List)} (List)} 不同的是,该方法list中每项是通过pk进行新增。

如果想通过点id新增边,请调用{Graph#insert_edges_by_vertex_id(List)}

结果按传入顺序构成集合,集合中包含新增后的边信息和错误信息。通过{ResponseItem#is_error()}方法判断操作是否失败。

函数声明

def insert_edges_by_vertex_pk(self, items: List[EdgeInfoByVertexPk]) -> List[ResponseItem]

参数说明

Parameter

Optional

Type

DESC

items

Y

List[EdgeInfoByVertexPk]

参数集合,不能为空。

响应参数

Parameter

Type

DESC

List[ResponseItem]

批量操作结果集。包含新增后的边信息和错误信息。

异常

Type

DESC

ParamException

参数格式不正确。当参数集合为空,以及集合中存在None,fromPk、fromType、toPk、toType或type值为空,property输入的属性类型不支持时将抛出异常。

DatabaseException

数据库内部异常。

示例

from graphdbapi.v1.graph import EdgeInfoByVertexPk,ResponseItem
# 初始化待添加的边信息
infos = [
    EdgeInfoByVertexPk.init_edge_info_by_vertex_pk("1000", "person", "1001", "person", "person_to_person", None),
    EdgeInfoByVertexPk.init_edge_info_by_vertex_pk("1000", "person", "1001", "person", "person_to_person", None),
    EdgeInfoByVertexPk.init_edge_info_by_vertex_pk_with_create("1006", "person", True, "1008", "person", True,"person_to_person", None),
]
res = graph.insert_edges_by_vertex_pk(infos)
print(res)

retrieve_edges

批量查询边。通过边id查询边。如果不存在,则会返回异常。

结果按传入顺序构成集合,集合中包含查询的边信息和错误信息。通过{ResponseItem#is_error()}方法判断操作是否失败。

函数声明

def retrieve_edges(self, items: List[str]) -> List[ResponseItem]

参数说明

Parameter

Optional

Type

DESC

items

Y

List[str]

边id集合,不能为空。

响应参数

Parameter

Type

DESC

List[ResponseItem]

批量操作结果集。包含查询的边信息和错误信息。

异常

Type

DESC

ParamException

参数格式不正确。当参数集合为空,以及集合中存在None、边id格式不正确时将抛出异常。

DatabaseException

数据库内部异常。

示例

from graphdbapi.v1.graph import ResponseItem
# 待获取的边id列表
items = [
    "00000000000000000001000000000008",
    "00000000000000000001000000000008",
    "00000000000000000001000000000009",
]

for res in graph.retrieve_edges(items):
    print(res)

insert_edge_by_vertex_pk

新增边。通过起始点pk和终止点pk新增边。

找不到起始点和终止点时会通过createFrom和createTo决定是否新增无属性的起始点和终止点。

函数声明

def insert_edge_by_vertex_pk(
        self, from_pk: str, from_type: str, create_from: bool,
        to_pk: str, to_type: str, create_to: bool,
        type: str, property: Union[Dict[str, Any], None]
    ) -> Edge

参数说明

Parameter

Optional

Type

DESC

from_pk

Y

str

起始点pk,不能为空。

from_type

Y

str

起始点类型,不能为空。

create_from

Y

bool

填True时,如果点不存在,则添加没有属性的起始点,填False,如果点不存在,则抛异常

to_pk

Y

str

终止点pk,不能为空。

to_type

Y

str

终止点类型,不能为空。

create_to

Y

str

填True时,如果点不存在,则添加没有属性的终止点。填False,如果点不存在,则抛异常

type

Y

str

边类型,不能为空。

property

Y

Union[Dict[str, Any], None]

边属性。填None或{}时,表示添加的边没有属性值。

响应参数

Parameter

Type

DESC

Edge

新增后的边信息。

异常

Type

DESC

ParamException

参数格式不正确,当fromPk、fromType、toPk、toType或type值为空、property输入的属性类型不支持时将抛出异常。

TypeNotFoundException

边类型不存在时抛出异常。

TypeErrorException

起始点和终止点的类型不是作为边类型的起始类型和终止类型时抛出异常。

VertexNotFoundException

当createFrom或createTo为False时起始点或终止点在图中不存在时将抛出异常。

PropertyNotFoundException

属性名在边类型中没有定义时抛出异常。

ValueFormatException

属性值类型错误时抛出异常。

DatabaseException

数据库内部异常。

示例

from graphdbapi.types.graph import Edge
# 添加点(person:1006)到点(person:1008) person_to_person类型的无属性边,无起止点不存在则创建
edge = graph.insert_edge_by_vertex_pk("1006", "person", True, "1008", "person", True,"person_to_person", None)
print(edge)

insert_edges_by_vertex_id

批量新增边。通过起始点id和终止点id新增边。

该方法与{Graph#insert_edges_by_vertex_pk(List)} 不同的是,该方法list中每项是通过点id进行新增。

如果想通过pk新增边,请调用{Graph#insert_edges_by_vertex_pk(List)}

结果按传入顺序构成集合,集合中包含新增后的边信息和错误信息。通过{ResponseItem#is_error()}方法判断操作是否失败。

函数声明

def insert_edges_by_vertex_id(self, items: List[EdgeInfoByVertexId]) -> List[ResponseItem]

参数说明

Parameter

Optional

Type

DESC

items

Y

List[EdgeInfoByVertexId]

参数集合,不能为空。

响应参数

Parameter

Type

DESC

List[ResponseItem]

批量操作结果集。包含新增后的边信息和错误信息。

异常

Type

DESC

ParamException

参数格式不正确。当参数集合为空,以及集合中存在None、EdgeInfoById中起始点id或终止点id小于0、type为空或property输入的属性类型不支持时将抛出异常。

DatabaseException

数据库内部异常。

示例

from graphdbapi.v1.graph import EdgeInfoByVertexPk,EdgeInfoByVertexId, ResponseItem
infos = [
    EdgeInfoByVertexId.init_edge_info_by_vertex_id(0,0, "person_to_person", None),
    EdgeInfoByVertexId.init_edge_info_by_vertex_id(0,100, "person_to_person", None),
    EdgeInfoByVertexId.init_edge_info_by_vertex_id(0,105, "person_to_person", None),
]

res = graph.insert_edges_by_vertex_id(infos)
print(res)

update_edges

批量更新边。通过边id更新边。

结果按传入顺序构成集合,集合中包含更新后的边信息和错误信息。通过{ResponseItem#is_error()}方法判断操作是否失败。

函数声明

def update_edges(self, items: List[EdgeInfo]) -> List[ResponseItem]

参数说明

Parameter

Optional

Type

DESC

items

Y

List[EdgeInfo]

参数列表,不能为空。

响应参数

Parameter

Type

DESC

List[ResponseItem]

批量操作结果集。包含更新后的边信息和错误信息。

异常

Type

DESC

ParamException

参数格式不正确。当参数集合为空,以及集合中存在None、边id格式不正确、property输入的属性类型不支持时将抛出异常。

DatabaseException

数据库内部异常。

示例

from graphdbapi.v1.graph import EdgeInfoByVertexPk,EdgeInfoByVertexId, EdgeInfo, ResponseItem
infos = [
    EdgeInfo.init_edge_info("00000000000000000001000000000008", {"timestamp": 1618369905}),
    EdgeInfo.init_edge_info("00000000000000000001000000000009", {"timestamp": 1618369905}),
    EdgeInfo.init_edge_info("00000000000000000001000000000010", {"timestamp": 1618369905}),
    EdgeInfo.init_edge_info("00000000000000000001000000000011", {"timestamp": 1618369905}),
]

res = graph.update_edges(infos)
print(res)

update_edges_by_vertex_pk

批量更新边。通过起始点pk和终止点pk新增或修改边。

找不到起始点和终止点时会通过create_from和create_to决定是否新增无属性的起始点和终止点。

如果起始点到终止点不存在边,则新增一条边。如果存在一条或多条边,则都会比较属性值。

结果按传入顺序构成集合,集合中包含新增或更新后的边信息和错误信息。通过{ResponseItem#is_error()}方法判断操作是否失败。

函数声明

def update_edges_by_vertex_pk(self, items: List[EdgeInfoByVertexPk]) -> List[ResponseItem]

参数说明

Parameter

Optional

Type

DESC

items

Y

List[EdgeInfoByVertexPk]

参数集合,不能为空。

响应参数

Parameter

Type

DESC

List[ResponseItem]

批量操作结果集。包含更新后的边信息和错误信息。

异常

Type

DESC

ParamException

参数格式不正确。当参数集合为空,以及集合中存在None,frompk、fromtype、topk、totype或type值为空,property输入的属性类型不支持时将抛出异常。

DatabaseException

数据库内部异常。

示例

from graphdbapi.v1.graph import EdgeInfoByVertexPk,EdgeInfoByVertexId, EdgeInfo, ResponseItem
# 边信息封装
infos = [
    EdgeInfoByVertexPk.init_edge_info_by_vertex_pk("1000", "person", "1001", "person", "person_to_person", None),
    EdgeInfoByVertexPk.init_edge_info_by_vertex_pk("1000", "person", "1001", "person", "person_to_person", None),
    EdgeInfoByVertexPk.init_edge_info_by_vertex_pk_with_create("1006", "person", True, "1008", "person", True,"person_to_person", None),
]

res = graph.update_edges_by_vertex_pk(infos)
print(res)

update_edge_by_vertex_id

更新边。通过起始点id和终止点id来修改边。

如果存在一条或多条边,则都会比较属性值。

函数声明

def update_edge_by_vertex_id(self, from_id: int, to_id: int, type: str, property: Union[Dict[str, Any]], is_merge:bool)  -> Iterator[Edge]

参数说明

Parameter

Optional

Type

DESC

from_id

Y

int

起始点id,不能小于0。

to_id

Y

int

终止点id,不能小于0。

type

Y

str

边类型,不能为空。

property

Y

Dict[str,Any]

边属性。不能为空。

is_merge

Y

bool

为true时集合属性追加,为fasle属性覆盖

响应参数

Parameter

Type

DESC

Iterator[Edge]

边详细信息迭代器

异常

Type

DESC

ParamException

参数格式不正确,当fromId、toId小于0或type值为空时将抛出异常。

TypeNotFoundException

边类型在图中不存在时将抛出异常。

TypeErrorException

起始点和终止点的类型不是作为边类型的起始类型和终止类型、property输入的属性类型不支持时将抛出异常。

VertexNotFoundException

起始点或终止点在图中不存在时将抛出异常。

PropertyNotFoundException

属性名在边类型中没有定义时将抛出异常。

ValueFormatException

属性值类型错误时将抛出异常。

DatabaseException

数据库内部异常。

示例

from graphdbapi.types.graph import Edge
for edge in graph.update_edge_by_vertex_id(0,0,"person_to_person", {"timestamp": int(time.time())}, True):
    print(edge)

update_edges_by_vertex_id

更新边。通过起始点id和终止点id修改边。

如果存在一条或多条边,则都会比较属性值。

结果按传入顺序构成集合,集合中包含更新后的边信息和错误信息。通过{ResponseItem#is_error()}方法判断操作是否失败。

函数声明

def update_edges_by_vertex_id(self, items: List[EdgeInfoByVertexId]) -> List[ResponseItem]

参数说明

Parameter

Optional

Type

DESC

items

Y

List[EdgeInfoByVertexId]

参数集合,不能为空。

响应参数

Parameter

Type

DESC

List[ResponseItem]

批量操作结果集。包含更新后的边信息和错误信息。

异常

Type

DESC

ParamException

参数格式不正确,当fromId、toId小于0或type值为空、property输入的属性类型不支持时时将抛出异常。

DatabaseException

数据库内部异常。

示例

from graphdbapi.types.graph import Edge
from graphdbapi.v1.graph import EdgeInfoByVertexPk,EdgeInfoByVertexId, EdgeInfo, ResponseItem
infos = [
    EdgeInfoByVertexId.init_edge_info_by_vertex_id(0,0, "person_to_person", None),
    EdgeInfoByVertexId.init_edge_info_by_vertex_id(0,100, "person_to_person", None),
    EdgeInfoByVertexId.init_edge_info_by_vertex_id(0,105, "person_to_person", None),
]

for res in graph.update_edges_by_vertex_id(infos):
    print(res)

retrieve_edge_by_vertex_id

查询邻居。通过起始点id查询。

函数声明

def retrieve_edge_by_vertex_id(
        self, id: int, edge_type_filter: Union[Set[str], None], direction: Direction, limit_edge: int,
        vertex_condition: Union[VisitCondition, None], edge_condition: Union[VisitCondition, None], get_loop: bool
    ) -> Iterator[Edge]

参数说明

Parameter

Optional

Type

DESC

id

Y

int

点id,不能小于0。

edge_type_filter

N

Union[Set[str], None]

边类型的过滤条件。只会返回满足参数中边类型的边。填None不参与计算。建议类型过滤使用这个字段,而不是edge_condition

direction

Y

Direction

查询方向,不能为None。

limit_edge

Y

int

边个数限制,小于0表示不进行限制。

vertex_condition

N

VisitCondition

点条件,填None不参与计算

edge_condition

N

VisitCondition

边条件,填None不参与计算

get_loop

Y

bool

True计算自环,False不计算自环

响应参数

Parameter

Type

DESC

Iterator[Edge]

边信息迭代器。

异常

Type

DESC

ParamException

参数格式不正确,当点id小于0、查询方向为None时将抛出异常。

TypeNotFoundException

边类型在图中不存在时将抛出异常。

PropertyNotFoundException

点/边条件过滤对应的属性类型在指定点/边类型中不存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

from graphdbapi.types.graph import Edge
from graphdbapi.v1.graph import EdgeInfoByVertexPk,EdgeInfoByVertexId, EdgeInfo, ResponseItem
from graphdbapi.v1.enum import Direction, QueryMethod
from graphdbapi.v1.graph.query.condition import *
for edge in graph.retrieve_edge_by_vertex_id(0, None, Direction.BOTH, -1, None, None, True):
    print(edge)

retrieve_edge_by_src_dst_vertex_id

查询邻居。通过起始点id和终止点id查询。

函数声明

def retrieve_edge_by_src_dst_vertex_id(
        self, src_id: int, dst_id: int, edge_type_filter: Union[Set[str], None], dirextion: Direction,
        edge_condition: Union[VisitCondition, None]
    ) -> Iterator[Edge]

参数说明

Parameter

Optional

Type

DESC

src_id

Y

int

起始点id,不能小于0。

dst_id

Y

int

终止点id,不能小于0。

edge_type_filter

N

Union[Set[str], None]

边类型的过滤条件。只会返回满足参数中边类型的边。填None不参与计算。建议类型过滤使用这个字段,而不是edge_condition

direction

Y

Direction

查询方向,不能为None。

limit_edge

Y

int

边个数限制,小于0表示不进行限制。

vertex_condition

N

VisitCondition

点条件,填None不参与计算

edge_condition

N

VisitCondition

边条件,填None不参与计算

响应参数

Parameter

Type

DESC

Iterator[Edge]

边信息迭代器。

异常

Type

DESC

ParamException

参数格式不正确,当起始点或终止点id小于0、查询方向为None时将抛出异常。

VertexNotFoundException

起始点或终止点在图中不存在时将抛出异常。

TypeNotFoundException

边类型在图中不存在时将抛出异常。

PropertyNotFoundException

边条件过滤对应的属性类型在指定边类型中不存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

from graphdbapi.types.graph import Edge
from graphdbapi.v1.graph import EdgeInfoByVertexPk,EdgeInfoByVertexId, EdgeInfo, ResponseItem
from graphdbapi.v1.enum import Direction, QueryMethod
from graphdbapi.v1.graph.query.condition import *
for edge in graph.retrieve_edge_by_src_dst_vertex_id(0, 0, None, Direction.BOTH, -1, None, None):
    print(edge)

retrieve_edge_by_vertex_pk

查询邻居。通过起始点pk和type查询。

函数声明

def retrieve_edge_by_vertex_pk(
        self, pk: str, type: str, edge_type_filter: Union[Set[str], None], direction: Direction, limit_edge: int,
        vertex_condition: Union[VisitCondition, None], edge_condition: Union[VisitCondition, None], get_loop: bool
    ) -> Iterator[Edge]

参数说明

Parameter

Optional

Type

DESC

pk

Y

str

起始点pk,不能为空。

type

Y

str

点类型,不能为空。

edge_type_filter

N

Union[Set[str], None]

边类型的过滤条件。只会返回满足参数中边类型的边。填None不参与计算。建议类型过滤使用这个字段,而不是edge_condition

direction

Y

Direction

查询方向,不能为None。

limit_edge

Y

int

边个数限制,小于0表示不进行限制。

vertex_condition

N

VisitCondition

点条件,填None不参与计算

edge_condition

N

VisitCondition

边条件,填None不参与计算

get_loop

Y

bool

True计算自环,False不计算自环

响应参数

Parameter

Type

DESC

Iterator[Edge]

边信息迭代器。

异常

Type

DESC

ParamException

参数格式不正确,当点pk和type为空、查询方向为None时将抛出异常。

VertexNotFoundException

起始点在图中不存在时将抛出异常。

TypeNotFoundException

边类型在图中不存在时将抛出异常。

PropertyNotFoundException

点/边条件过滤对应的属性类型在指定点/边类型中不存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

from graphdbapi.types.graph import Edge
from graphdbapi.v1.graph import EdgeInfoByVertexPk,EdgeInfoByVertexId, EdgeInfo, ResponseItem
from graphdbapi.v1.enum import Direction, QueryMethod
from graphdbapi.v1.graph.query.condition import *
for edge in graph.retrieve_edge_by_vertex_pk("1001", "person", None, Direction.BOTH, -1, None, None, True):
    print(edge)

update_edge_by_vertex_pk

更新边。通过起始点pk和终止点pk来修改边。

函数声明

def update_edge_by_vertex_pk(
        self, from_pk: str, from_type: str, to_pk: str, to_type: str,
        type: str, property: Union[Dict[str, Any]]
    ) -> Iterator[Edge]

参数说明

Parameter

Optional

Type

DESC

from_pk

Y

str

起始点pk,不能为空。

from_type

Y

str

起始点类型,不能为空。

to_pk

Y

str

终止点pk,不能为空。

to_type

Y

str

起始点类型,不能为空。

type

Y

str

边类型,不能为空。

property

Y

Dict[str, Any]

边属性。

响应参数

Parameter

Type

DESC

Iterator[Edge]

更新后的边信息迭代器。

异常

Type

DESC

ParamException

参数格式不正确,当from_pk、from_type、to_pk、to_type或type值为空、property输入的属性类型不支持时将抛出异常。

TypeNotFoundException

边类型不存在时抛出异常。

TypeErrorException

起始点和终止点的类型不是作为边类型的起始类型和终止类型时抛出异常。

VertexNotFoundException

当create_from或create_to为False时起始点或终止点在图中不存在时将抛出异常。

PropertyNotFoundException

属性名在边类型中没有定义时抛出异常。

ValueFormatException

属性值类型错误时抛出异常。

DatabaseException

数据库内部异常。

示例

edge = graph.update_edge_by_vertex_pk("1006", "person", "1008", "person", "person_to_person", {"timestamp": int(time.time())})
print(edge)

retrieve_or_insert_edge_by_vertex_id

查询或新增边。通过起始点、终止点id和边类型查询或新增边。

若两点之间此边类型的边存在,则查询并返回两点之间此类型所有边的迭代器。若不存在,则新增一条边并返回。

函数声明

def retrieve_or_insert_edge_by_vertex_id(self, from_id: int, to_id: int, type: str, property: Union[Dict[str, Any], None]) -> Iterator[Edge]

参数说明

Parameter

Optional

Type

DESC

from_id

Y

int

起始点id,不能小于0。

to_id

Y

int

终止点id,不能小于0。

type

Y

str

边类型,不能为空。

property

N

dict

边属性。填None或{}时,新增的边没有属性值。

响应参数

Parameter

Type

DESC

Iterator[Edge]

查询或新增后的边信息迭代器。

异常

Type

DESC

ParamException

参数格式不正确,当type为空、起始点id或终止点id小于0时将抛出异常。

VertexNotFoundException

起始点或终止点在图中不存在时将抛出异常。

TypeNotFoundException

边类型在图中不存在时将抛出异常。

PropertyNotFoundException

属性名在边类型中没有定义时将抛出异常。

ValueFormatException

属性值类型错误时将抛出异常。

DatabaseException

数据库内部异常。

示例

# 添加点(id:56281)到点(id:7393322)空属性的person_to_person类型的边
iterator = graph.retrieve_or_insert_edge_by_vertex_id(56281, 7393322, 'person_to_person', None)
# 打印边
for edge in iterator:
    print(edge)

retrieve_or_insert_edge_by_vertex_pk

查询或新增边。通过起始点pk和终止点pk查询或新增边。

若两点之间此边类型的边存在,则查询并返回两点之间此类型所有边的迭代器。若不存在,则新增一条边并返回。

函数声明

def retrieve_or_insert_edge_by_vertex_pk(
        self, from_pk: str, from_type: str, create_from: bool,
        to_pk: str, to_type: str, create_to: bool,
        type: str, property: Union[Dict[str, Any], None]
    ) -> Iterator[Edge]

参数说明

Parameter

Optional

Type

DESC

from_pk

Y

str

起始点pk,不能为空。

from_type

Y

str

起始点类型,不能为空。

create_from

Y

bool

填True时,如果点不存在,则添加没有属性的起始点,填False,如果点不存在,则抛异常

to_pk

Y

str

终止点pk,不能为空。

to_type

Y

str

终止点类型,不能为空。

create_to

Y

bool

填True时,如果点不存在,则添加没有属性的终止点,填False,如果点不存在,则抛异常

type

Y

str

边类型,不能为空。

property

N

Dict[str,Any]

边属性。填None或{}时,表示添加的边没有属性值。

响应参数

Parameter

Type

DESC

Iterator[Edge]

查询或新增后的边信息迭代器。

异常

Type

DESC

ParamException

参数格式不正确,当type为空、起始点或终止点类型为空、property输入的属性类型不支持时将抛出异常。

VertexNotFoundException

起始点或终止点在图中不存在时将抛出异常。

TypeErrorException

起始点和终止点的类型不是作为边类型的起始类型和终止类型时将抛出异常。

TypeNotFoundException

边类型在图中不存在时将抛出异常。

PropertyNotFoundException

属性名在边类型中没有定义时将抛出异常。

ValueFormatException

属性值类型错误时将抛出异常。

DatabaseException

数据库内部异常。

示例

# 添加点(person:1006)到点(person:1008) person_to_person类型的无属性边,无起止点不存在则创建
# 或查找点(person:1006)到点(person:1008) 之间的person_to_person类型边
iterator = graph.retrieve_or_insert_edge_by_vertex_pk("1006", "person", True, "1008", "person", True,"person_to_person", None)
for edge in iterator:
    print(edge)

retrieve_or_insert_edges_by_vertex_id

批量查询或新增边。通过起始点id和终止点id查询或新增边。若存在,仅查询并返回所有边信息,属性值不做修改。若不存在,则新增一条边并返回边信息。

结果按传入顺序构成集合,集合中包含查询或新增后的边信息和错误信息。通过{ResponseItem#is_error()}方法判断操作是否失败。

函数声明

def retrieve_or_insert_edges_by_vertex_id(self, items: List[EdgeInfoByVertexId]) -> List[ResponseItem]

参数说明

Parameter

Optional

Type

DESC

items

Y

List[EdgeInfoByVertexId]

参数集合,不能为空。

响应参数

Parameter

Type

DESC

List[ResponseItem]

批量操作结果集。包含查询或新增后的边信息和错误信息。

异常

Type

DESC

ParamException

参数格式不正确。当参数集合为空、以及集合中存在None、type为空、起始点id或终止点id小于0、property输入的属性类型不支持时将抛出异常。

DatabaseException

数据库内部异常。

示例

# 边信息列表
infos = [
    EdgeInfoByVertexId.init_edge_info_by_vertex_id(0,0, "person_to_person", None),
    EdgeInfoByVertexId.init_edge_info_by_vertex_id(0,100, "person_to_person", None),
    EdgeInfoByVertexId.init_edge_info_by_vertex_id(0,105, "person_to_person", None),
]
result = graph.retrieve_or_insert_edges_by_vertex_id(infos)
print(result)

retrieve_or_insert_edges_by_vertex_pk

批量查询或新增边。通过起始点pk和终止点pk查询或新增边。若存在,仅查询并返回所有边信息,属性值不做修改。若不存在,则新增一条边并返回边信息。

结果按传入顺序构成集合,集合中包含查询或新增后的边信息和错误信息。通过{ResponseItem#is_error()}方法判断操作是否失败。

函数声明

def retrieve_or_insert_edges_by_vertex_pk(self, items: List[EdgeInfoByVertexPk]) -> List[ResponseItem]

参数说明

Parameter

Optional

Type

DESC

items

Y

List[EdgeInfoByVertexPk]

参数集合,不能为空。

响应参数

Parameter

Type

DESC

List[ResponseItem]

批量操作结果集。包含查询或新增后的边信息和错误信息。

异常

Type

DESC

ParamException

参数格式不正确。当参数集合为空,以及集合中存在None、type为空、起始点或终止点类型为空、起始点pk和终止点pk为空、property输入的属性类型不支持时将抛出异常。

DatabaseException

数据库内部异常。

示例

# 边信息封装
infos = [
    EdgeInfoByVertexPk.init_edge_info_by_vertex_pk("1000", "person", "1001", "person", "person_to_person", None),
    EdgeInfoByVertexPk.init_edge_info_by_vertex_pk("1000", "person", "1001", "person", "person_to_person", None),
    EdgeInfoByVertexPk.init_edge_info_by_vertex_pk_with_create("1006", "person", True, "1008", "person", True,"person_to_person", None),
]

res = graph.retrieve_or_insert_edges_by_vertex_pk(infos)
print(res)

upsert_edge_by_vertex_pk

新增或更新边。通过起始点pk和终止点pk来新增或修改边。

找不到起始点和终止点时会通过create_from和create_to来决定是否新增无属性的起始点和终止点。

如果起始点到终止点不存在边,则新增一条边。如果存在一条或多条边,则都会比较属性值。

函数声明

def upsert_edge_by_vertex_pk(
        self, from_pk: str, from_type: str, create_from: bool,
        to_pk: str, to_type: str, create_to: bool,
        type: str, property: Union[Dict[str, Any]]
    ) -> Iterator[Edge]

参数说明

Parameter

Optional

Type

DESC

from_pk

Y

str

起始点pk,不能为空。

from_type

Y

str

起始点类型,不能为空。

create_from

Y

bool

填True时,如果点不存在,则添加没有属性的起始点,填False,如果点不存在,则抛异常

to_pk

Y

str

终止点pk,不能为空。

to_type

Y

str

起始点类型,不能为空。

create_to

Y

bool

填True时,如果点不存在,则添加没有属性的终止点。填False,如果点不存在,则抛异常

type

Y

str

边类型,不能为空。

property

Y

Dict[str, Any]

边属性。

响应参数

Parameter

Type

DESC

Iterator[Edge]

新增或更新后的边信息迭代器。

异常

Type

DESC

ParamException

参数格式不正确,当frompk、fromtype、topk、totype或type值为空、property输入的属性类型不支持时将抛出异常。

TypeNotFoundException

边类型不存在时抛出异常。

TypeErrorException

起始点和终止点的类型不是作为边类型的起始类型和终止类型时抛出异常。

VertexNotFoundException

当createfrom或createto为False时起始点或终止点在图中不存在时将抛出异常。

PropertyNotFoundException

属性名在边类型中没有定义时抛出异常。

ValueFormatException

属性值类型错误时抛出异常。

DatabaseException

数据库内部异常。

示例

edge = graph.upsert_edge_by_vertex_pk("1006", "person", True, "1008", "person", True,"person_to_person", {"timestamp": int(time.time())})
print(edge)

upsert_edges_by_vertex_pk

批量新增或更新边。通过起始点pk和终止点pk新增或修改边。

找不到起始点和终止点时会通过create_from和create_to决定是否新增无属性的起始点和终止点。

如果起始点到终止点不存在边,则新增一条边。如果存在一条或多条边,则都会比较属性值。

结果按传入顺序构成集合,集合中包含新增或更新后的边信息和错误信息。通过{ResponseItem#is_error()}方法判断操作是否失败。

函数声明

def upsert_edges_by_vertex_pk(self, items: List[EdgeInfoByVertexPk]) -> List[ResponseItem]

参数说明

Parameter

Optional

Type

DESC

items

Y

List[EdgeInfoByVertexPk]

参数集合,不能为空。

响应参数

Parameter

Type

DESC

List[ResponseItem]

批量操作结果集。包含新增或更新后的边信息和错误信息。

异常

Type

DESC

ParamException

参数格式不正确。当参数集合为空,以及集合中存在None,frompk、fromtype、topk、totype或type值为空,property输入的属性类型不支持时将抛出异常。

DatabaseException

数据库内部异常。

示例

# 边信息封装
infos = [
    EdgeInfoByVertexPk.init_edge_info_by_vertex_pk("1000", "person", "1001", "person", "person_to_person", None),
    EdgeInfoByVertexPk.init_edge_info_by_vertex_pk("1000", "person", "1001", "person", "person_to_person", None),
    EdgeInfoByVertexPk.init_edge_info_by_vertex_pk_with_create("1006", "person", True, "1008", "person", True,"person_to_person", None),
]

res = graph.upsert_edges_by_vertex_pk(infos)
print(res)

upsert_edge_by_vertex_id

新增或更新边。通过起始点id和终止点id来新增或修改边。

如果起始点到终止点不存在边,则新增一条边。如果存在一条或多条边,则都会比较属性值。

函数声明

def upsert_edge_by_vertex_id(self, from_id: int, to_id: int, type: str, property: Union[Dict[str, Any]])  -> Iterator[Edge]

参数说明

Parameter

Optional

Type

DESC

from_id

Y

int

起始点id,不能小于0。

to_id

Y

int

终止点id,不能小于0。

type

Y

str

边类型,不能为空。

property

Y

Dict[str,Any]

边属性。不能为空。

响应参数

Parameter

Type

DESC

Iterator[Edge]

边详细信息迭代器

异常

Type

DESC

ParamException

参数格式不正确,当fromId、toId小于0或type值为空时将抛出异常。

TypeNotFoundException

边类型在图中不存在时将抛出异常。

TypeErrorException

起始点和终止点的类型不是作为边类型的起始类型和终止类型、property输入的属性类型不支持时将抛出异常。

VertexNotFoundException

起始点或终止点在图中不存在时将抛出异常。

PropertyNotFoundException

属性名在边类型中没有定义时将抛出异常。

ValueFormatException

属性值类型错误时将抛出异常。

DatabaseException

数据库内部异常。

示例

for edge in graph.upsert_edge_by_vertex_id(0,0,"person_to_person", {"timestamp": int(time.time())}):
    print(edge)

upsert_edges_by_vertex_id

批量新增或更新边。通过起始点id和终止点id新增或修改边。

如果起始点到终止点不存在边,则新增一条边。如果存在一条或多条边,则都会比较属性值。

结果按传入顺序构成集合,集合中包含新增或更新后的边信息和错误信息。通过:ref:ResponseItem is_error()方法判断操作是否失败。

函数声明

def upsert_edges_by_vertex_id(self, items: List[EdgeInfoByVertexId]) -> List[ResponseItem]

参数说明

Parameter

Optional

Type

DESC

items

Y

List[EdgeInfoByVertexId]

参数集合,不能为空。

响应参数

Parameter

Type

DESC

List[ResponseItem]

批量操作结果集。包含新增或更新后的边信息和错误信息。

异常

Type

DESC

ParamException

参数格式不正确,当fromId、toId小于0或type值为空、property输入的属性类型不支持时时将抛出异常。

DatabaseException

数据库内部异常。

示例

infos = [
    EdgeInfoByVertexId.init_edge_info_by_vertex_id(0,0, "person_to_person", None),
    EdgeInfoByVertexId.init_edge_info_by_vertex_id(0,100, "person_to_person", None),
    EdgeInfoByVertexId.init_edge_info_by_vertex_id(0,105, "person_to_person", None),
]

for res in graph.upsert_edges_by_vertex_id(infos):
    print(res)

delete_edge_by_vertex_pk

删除边。通过起始点pk和终止点pk,删除两点之间的边。

函数声明

def delete_edge_by_vertex_pk(self, from_pk: str, from_type: str, to_pk: str, to_type: str, edge_types: Union[Set[str], None]) -> None

参数说明

Parameter

Optional

Type

DESC

from_pk

Y

str

起始点pk,不能为空。

from_type

Y

str

起始点类型,不能为空。

to_pk

Y

str

终止点pk,不能为空。

to_type

Y

str

终止点类型,不能为空。

edge_types

Y

Union[Set[str], None])

需要删除的边类型,为None或空集合时所有类型全删。

异常

Type

DESC

ParamException

参数格式不正确

DatabaseException

数据库内部异常。

示例

delete_edge_by_vertex_pk("1", "person", "1", "person", None)

retrieve_edge_by_vertex_pks

查询邻居。通过起始点pk和type查询

函数声明

def retrieve_edge_by_vertex_pks(
            self, pk: str, type:str, another_pk: str, another_type: str, edge_type_filter: Union[Set[str], None],
            direction: Direction, limit_edge: int, edge_condition: Union[VisitCondition, None]) -> Iterator[Edge]

参数说明

Parameter

Optional

Type

DESC

pk

Y

str

点pk,不能为空。

type

Y

str

点类型,不能为空。

another_pk

Y

str

点pk,不能为空。

another_type

Y

str

点类型,不能为空。

edge_type_filter

Y

Union[Set[str], None]

边类型的过滤条件 。只会返回满足参数中边类型的边。填None不参与计算。建议类型过滤使用这个字段,而不是edge_condition

direction

Y

Direction

查询方向,不能为None。

limit_edge

Y

int

边个数限制,小于0表示不进行限制。

edge_condition

Y

Union[VisitCondition, None]

边条件,填None不参与计算

响应参数

Parameter

Type

DESC

Iterator[Edge]

边迭代器

异常

Type

DESC

ParamException

参数格式不正确

DatabaseException

数据库内部异常。

示例

for _ in retrieve_edge_by_vertex_pks("1", "person", "1", "person", None, Direction.OUT, -1, None):
    print(_)

delete_edge_by_vertex_id_with_edge_type

删除边。通过起始点id和终止点id,删除两点之间的边

函数声明

def delete_edge_by_vertex_id_with_edge_type(self, from_id: int, to_id: int, edge_types: Union[Set[str], None]) -> None

参数说明

Parameter

Optional

Type

DESC

from_id

Y

int

起始点id,不能为空。

to_id

Y

int

终止点id,不能为空。

edge_types

Y

Union[Set[str], None])

需要删除的边类型,为None或空集合时所有类型全删。

异常

Type

DESC

ParamException

参数格式不正确

DatabaseException

数据库内部异常。

示例

delete_edge_by_vertex_id_with_edge_type(1099511627776, 1099511627976, None)

search_edge_property

通过类型、属性查询点。

函数声明

def search_edge_property(self, edge_type: str, predicates: List[SearchPredicate], orders: List[SearchOrder],
                               skip: int, limit: int) -> Iterator[Edge]:

参数说明

Parameter

Optional

Type

DESC

edge_type

Y

str

边类型名,不能为空。

predicates

Y

List[SearchPredicate]

查询谓词,每个谓词包括:属性名、查询值

orders

Y

List[SearchOrder]

属性排序

skip

Y

int

跳过

limit

Y

int

限制返回数量

响应参数

Parameter

Type

DESC

Iterator[Edge]

结果边迭代器。

异常

Type

DESC

ParamException

参数格式不正确。

DatabaseException

数据库内部异常。

示例

from graphdbapi.v1 import SearchPredicate, SearchOrder
from graphdbapi.v1.enum import OrderBy, SearchType

# 查询图中最新500个关注uid(1234)的边
for _ in graph.search_edge_property(
        "关注", [SearchPredicate.init_by_value(SearchType.EQUAL, "uid", "1234")],
        [SearchOrder("timestamp", OrderBy.DESC)], -1, 500):
    print(_)

delete_edge_by_vertex_pk_with_condition

删除边。通过起始点pk和终止点pk,删除两点之间的边。

函数声明

def delete_edge_by_vertex_pk_with_condition(
            self, from_pk: str, from_type: str, to_pk: str, to_type: str,
            edge_condition: Union[VisitCondition, None],
            edge_types: Union[Set[str], None]) -> None:

参数说明

Parameter

Optional

Type

DESC

from_pk

Y

str

起始点pk,不能为空。

from_type

Y

str

起始点类型,不能为空。

to_pk

Y

str

终止点pk,不能为空。

to_type

Y

str

终止点类型,不能为空。

edge_condition

Y

Union[VisitCondition, None]

边条件过滤,为None不参与计算。

edge_types

Y

Union[Set[str], None]

需要删除的边类型,为None或空集合时所有类型全删。推荐使用此参数过滤边类型

异常

Type

DESC

ParamException

参数格式不正确。

VertexNotFoundException

起始点在图中不存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

from graphdbapi.v1.graph.query.condition import VisitConditionByProperty
from graphdbapi.v1.graph.query.condition import PropertyFilter
from graphdbapi.v1.graph.query.condition import PropertyFilterInfo
from graphdbapi.v1.enum import QueryMethod

p = PropertyFilter.init_Property_filter()
p.add_filter_by_property_filter_info(PropertyFilterInfo.init_property_filter_info("金额", QueryMethod.MoreOrEqual, 500))
v = VisitConditionByProperty.init_visit_condition_by_property({"交易": p}, False)
graph.delete_edge_by_vertex_pk_with_condition("张三", "person", "李四", "person", v, {"交易"})

delete_edge_by_vertex_id_with_condition

删除边。通过起始点id和终止点id,删除两点之间的边

函数声明

def delete_edge_by_vertex_id_with_condition(
            self, from_id: int, to_id: int,
            edge_condition: Union[VisitCondition, None],
            edge_types: Union[Set[str], None]) -> None

参数说明

Parameter

Optional

Type

DESC

from_id

Y

int

起始点id,不能小于0。

to_id

Y

int

终止点id,不能小于0。

edge_condition

Y

Union[VisitCondition, None]

边条件过滤,为None不参与计算。

edge_types

Y

Union[Set[str], None]

需要删除的边类型,为None或空集合时所有类型全删。推荐使用此参数过滤边类型

异常

Type

DESC

ParamException

参数格式不正确。

VertexNotFoundException

起始点在图中不存在时将抛出异常。

DatabaseException

数据库内部异常。

示例

from graphdbapi.v1.graph.query.condition import VisitConditionByProperty
from graphdbapi.v1.graph.query.condition import PropertyFilter
from graphdbapi.v1.graph.query.condition import PropertyFilterInfo
from graphdbapi.v1.enum import QueryMethod

p = PropertyFilter.init_Property_filter()
p.add_filter_by_property_filter_info(PropertyFilterInfo.init_property_filter_info("金额", QueryMethod.MoreOrEqual, 500))
v = VisitConditionByProperty.init_visit_condition_by_property({"交易": p}, False)
graph.delete_edge_by_vertex_id_with_condition(1002563611, 1002563612, v, {"交易"})

update_edge_by_vertex_pk_with_condition

更新边。通过起始点pk和终止点pk来修改边。

函数声明

def update_edge_by_vertex_pk_with_condition(
            self, from_pk: str, from_type: str, to_pk: str, to_type: str, type: str,
            edge_condition: Union[VisitCondition, None],
            property: Union[Dict[str, Any]], is_merge: bool
    ) -> Iterator[Edge]

参数说明

Parameter

Optional

Type

DESC

from_pk

Y

str

起始点pk,不能为空。

from_type

Y

str

起始点类型,不能为空。

to_pk

Y

str

终止点pk,不能为空。

to_type

Y

str

终止点类型,不能为空。

type

Y

str

边类型,不能为空。

edge_condition

Y

Union[VisitCondition, None]

边条件过滤,为None不参与计算。

property

Y

Dict[str, Any]

边属性

is_merge

Y

bool

为True时集合属性追加,为False属性覆盖

响应参数

Parameter

Type

DESC

Iterator[Edge]

结果边迭代器。

异常

Type

DESC

ParamException

参数格式不正确。

TypeNotFoundException

边类型不存在时抛出异常

TypeErrorException

起始点和终止点的类型不是作为边类型的起始类型和终止类型时抛出异常。

VertexNotFoundException

起始点在图中不存在时将抛出异常。

PropertyNotFoundException

属性名在边类型中没有定义时抛出异常。

ValueFormatException

属性值类型错误时抛出异常。

DatabaseException

数据库内部异常。

示例

from graphdbapi.v1.graph.query.condition import VisitConditionByProperty
from graphdbapi.v1.graph.query.condition import PropertyFilter
from graphdbapi.v1.graph.query.condition import PropertyFilterInfo
from graphdbapi.v1.enum import QueryMethod

p = PropertyFilter.init_Property_filter()
p.add_filter_by_property_filter_info(PropertyFilterInfo.init_property_filter_info("金额", QueryMethod.MoreOrEqual, 500))
v = VisitConditionByProperty.init_visit_condition_by_property({"交易": p}, False)
graph.update_edge_by_vertex_pk_with_condition("张三", "person", "李四", "person", "交易",v, {"金额": 500}, False)

update_edge_by_vertex_id_with_condition

更新边。通过起始点pk和终止点pk来修改边。

函数声明

def update_edge_by_vertex_id_with_condition(
            self, from_id: int, to_id: int, type: str,
            edge_condition: Union[VisitCondition, None],
            property: Union[Dict[str, Any]], is_merge: bool
    ) -> Iterator[Edge]

参数说明

Parameter

Optional

Type

DESC

from_id

Y

int

起始点id,大于0。

to_id

Y

int

终止点id,大于0。

type

Y

str

边类型,不能为空。

edge_condition

Y

Union[VisitCondition, None]

边条件过滤,为None不参与计算。

property

Y

Dict[str, Any]

边属性

is_merge

Y

bool

为True时集合属性追加,为False属性覆盖

响应参数

Parameter

Type

DESC

Iterator[Edge]

结果边迭代器。

异常

Type

DESC

ParamException

参数格式不正确。

TypeNotFoundException

边类型不存在时抛出异常

TypeErrorException

起始点和终止点的类型不是作为边类型的起始类型和终止类型时抛出异常。

VertexNotFoundException

起始点在图中不存在时将抛出异常。

PropertyNotFoundException

属性名在边类型中没有定义时抛出异常。

ValueFormatException

属性值类型错误时抛出异常。

DatabaseException

数据库内部异常。

示例

from graphdbapi.v1.graph.query.condition import VisitConditionByProperty
from graphdbapi.v1.graph.query.condition import PropertyFilter
from graphdbapi.v1.graph.query.condition import PropertyFilterInfo
from graphdbapi.v1.enum import QueryMethod

p = PropertyFilter.init_Property_filter()
p.add_filter_by_property_filter_info(PropertyFilterInfo.init_property_filter_info("金额", QueryMethod.MoreOrEqual, 500))
v = VisitConditionByProperty.init_visit_condition_by_property({"交易": p}, False)
graph.update_edge_by_vertex_id_with_condition(1002563611, 1002563612, "交易",v, {"金额": 500}, False)