Graph Learning
- class graphscope.learning.graph.Graph(*args: Any, **kwargs: Any)[source]
- E(edge_type, feed=None, reverse=False)[source]
Entry of Gremlin-like query. Start from edge.
- Parameters
edge_type (string) – The type of edge which is the entry of query.
feed (None| (np.ndarray, np.ndarray) | types.GeneratorType | Edges) – None: Default. Sample edges with the following .shuffle and .batch API. (np.ndarray, np.ndarray): src_ids, dst_ids. Get edges of the given (src_ids, dst_ids) and given edge_type. src_ids and dst_ids must be the same shape, dtype is int. types.Generator: A generator of (numpy.ndarray, numpy.ndarray). Get edges of generated (src_ids, dst_ids) and given edge_type. Edges: An Edges object.
- Returns
A ‘Query’ object.
Example:
>>> import numpy as np >>> g.E("buy").shuffle().batch(64) >>> g.E("buy", feed=(np.array([1, 2, 3]), np.array([4, 5, 6])) >>> def gen(): >>> while True: >>> yield (np.array([1, 2, 3]), np.array([4, 5, 6])) >>> gen = gen() >>> g.E("buy", feed=gen)
- V(t, feed=None)[source]
Entry of Gremlin-like query. Start from node.
Args: t (string): The type of node which is the entry of query or the type
of edge when node is from edge source or dst.
- feed (None| numpy.ndarray | types.GeneratorType | Nodes): When feed
is not None, the type should be a node type, which means query the attributes of the specified node ids. None: Default. Sample nodes with the following .shuffle and .batch API. numpy.ndarray: Any shape of ids. Get nodes of the given ids and node_type. types.Generator: A generator of numpy.ndarray. Get nodes of generated ids and given node_type. Nodes: A Nodes object.
Return: A ‘Query’ object.
Example:
>>> import numpy as np >>> g.V("user").shuffle().batch(64) >>> g.V("user", feed=np.array([1, 2, 3])) >>> def gen(): >>> while True: >>> yield np.array([1, 2, 3]) >>> gen = gen() >>> g.V("user", feed=gen)