Operation object

class graphscope.framework.operation.Operation(session_id, op_type, inputs=None, output_types=None, config=None, large_attr=None, query_args=None)[source]

Represents a dag op that performs computation on tensors.

For example g2 = g1.add_vertices("path") create an Operation of type “ADD_LABELS” that takes operation of g1 as input, and produces a graph dag node g2 which contains this operation as output.

After the dag has been launched in a session, an Operation can be executed by :code`op.eval()` or passing it to session.run.

Operation.__init__(session_id, op_type[, …])

Creates an graphscope.framework.operation.Operation.



Unique key for each op_def_pb2.OpDef


Signature of its parents’ signatures and its own parameters.


Evaluate by sess.run.


BuiltIn operations


Wrapper for create an CREATE_APP Operation with configuration.

bind_app(graph, app_assets)

Wrapper for create an BIND_APP Operation with configuration.

run_app(app, *args, **kwargs)

Run bound app on the graph.

create_graph(session_id, graph_type[, inputs])

Create an CREATE_GRAPH op, add op to default dag.


Create a loader operation. :param vertex_or_edge_label_list: List of (graphscope.framework.graph_utils.VertexLabel) or (graphscope.framework.graph_utils.EdgeLabel).

add_labels_to_graph(graph, loader_op)

Add new labels to existed graph.


Create an op to transform a nx.Graph object to Graph.


Transform a Graph object to nx.Graph.

modify_edges(graph, modify_type, edges[, …])

Create modify edges operation for nx graph.

modify_vertices(graph, modify_type, vertices)

Create modify vertices operation for nx graph.

report_graph(graph, report_type[, node, …])

Create report operation for nx graph.

project_arrow_property_graph(graph, …)

project_to_simple(graph, v_prop, e_prop)

Project property graph to a simple graph.

copy_graph(graph[, copy_type])

Create copy operation for nx graph.


Create to_directed operation graph.


Create to_undirected operation for graph.

create_graph_view(graph, view_type)

Create view of nx graph. :param graph: A nx graph. :type graph: nx.Graph :param view_type: ‘reversed’: get a reverse view of graph. ‘directed’: get a directed view of graph ‘undirected’: get a undirected view of graph :type view_type: str.


Create clear graph operation for nx graph.


Create clear edges operation for nx graph.

create_subgraph(graph[, nodes, edges])

Create subgraph operation for nx graph.

create_unload_op(session_id, op_type, inputs)

Uility method to create a unload Operation based on op type and op.


Unload a loaded app.


Unload a graph.


context_to_numpy(context[, selector, …])

Retrieve results as a numpy ndarray.

context_to_dataframe(context[, selector, …])

Retrieve results as a pandas DataFrame.

to_vineyard_tensor(context[, selector, …])

Retrieve results as vineyard tensor.

to_vineyard_dataframe(context[, selector, …])

Retrieve results as vineyard dataframe.

to_data_sink(result, fd, **kwargs)

Dump result to fd by drivers in vineyard.

output(context, fd, selector, vertex_range, …)

Output result to fd, this will be handled by registered vineyard C++ adaptor.

get_context_data(results, node)

add_column(graph, results, selector)

Add a column to graph, produce a new graph.

graph_to_numpy(graph[, selector, vertex_range])

Retrieve graph raw data as a numpy ndarray.

graph_to_dataframe(graph[, selector, …])

Retrieve graph raw data as a pandas DataFrame.

gremlin_query(interactive_query, query[, …])

Execute a gremlin query.

gremlin_to_subgraph(interactive_query, …)

Create a subgraph from gremlin output.

fetch_gremlin_result(result_set[, fetch_type])

Fetch the gremlin query result.