MCPcopy Create free account
hub / github.com/alibaba/GraphScope / get_neighbors

Function get_neighbors

python/graphscope/nx/classes/cache.py:395–416  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

393
394
395def 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
419def get_neighbors_attr(graph, n, pred=False):

Callers 2

get_successorsMethod · 0.85
get_predecessorsMethod · 0.85

Calls 4

encodeMethod · 0.45
evalMethod · 0.45
get_bytesMethod · 0.45

Tested by

no test coverage detected