Get the neighbors of node in graph. Parameters ---------- graph: the graph to query. n: node the node to get neighbors. report_type: the report type of report graph operation, types_pb2.SUCCS_BY_NODE: get the successors of node, ty
(graph, n, pred=False)
| 393 | |
| 394 | |
| 395 | def get_neighbors(graph, n, pred=False): |
| 396 | """Get the neighbors of node in graph. |
| 397 | |
| 398 | Parameters |
| 399 | ---------- |
| 400 | graph: |
| 401 | the graph to query. |
| 402 | n: node |
| 403 | the node to get neighbors. |
| 404 | report_type: |
| 405 | the report type of report graph operation, |
| 406 | types_pb2.SUCCS_BY_NODE: get the successors of node, |
| 407 | types_pb2.PREDS_BY_NODE: get the predecessors of node, |
| 408 | """ |
| 409 | if graph.graph_type == graph_def_pb2.ARROW_PROPERTY: |
| 410 | n = graph._convert_to_label_id_tuple(n) |
| 411 | report_t = types_pb2.PREDS_BY_NODE if pred else types_pb2.SUCCS_BY_NODE |
| 412 | op = dag_utils.report_graph( |
| 413 | graph, report_t, node=json.dumps(n).encode("utf-8", errors="ignore") |
| 414 | ) |
| 415 | archive = op.eval() |
| 416 | return msgpack.unpackb(archive.get_bytes(), use_list=False) |
| 417 | |
| 418 | |
| 419 | def get_neighbors_attr(graph, n, pred=False): |
no test coverage detected