5.3.4. xgt.GraphFrame

class xgt.GraphFrame(conn: Connection, name: str, container_id: int)

A GraphFrame object represents a grouping of vertex and edge frames that make a logical graph. A GraphFrame should not be instantiated directly by the user. Instead it is created by the method Connection.create_graph_frame().

Methods that return this object: Connection.get_frame(), Connection.get_frames() and Connection.create_graph_frame().

Parameters:
  • conn (Connection) – An open connection to an xGT server.

  • name (str) – Fully qualified name of the graph, including the namespace.

  • container_id (int) – The ID of the graph’s container on the server.

Examples

>>> import xgt
>>> conn = xgt.Connection()
>>> g = conn.create_graph_frame('MyGraph', { 'v0' : 'Vertex0',
>>>                                          'v1' : 'other__Vertex0',
>>>                                          'e'  : 'Edge' })
>>> print(g.name)

Experimental: The API of this class may change in future releases.

Methods

add_frames(graph_members)

Add frames to the graph.

remove_frames(graph_members)

Remove frames from the graph.

Attributes

connection

The connection used when constructing the frame.

graph_members

The frames belonging to this graph.

name

Name of the graph frame.

add_frames(graph_members: dict[str, str | VertexFrame | EdgeFrame] | set[str | VertexFrame | EdgeFrame]) None

Add frames to the graph. The new frames are given as either a dictionary mapping aliases to frames or a set of frames. The frames can be any of names, aliases, VertexFrames, and EdgeFrames. If a frame is given without an alias, it is given an alias of its fully qualified name.

Parameters:

graph_members (dictionary[str | VertexFrame | EdgeFrame] | set[str | VertexFrame | EdgeFrame]) – Dictionary mapping aliases to frames or a set of frames to add to the graph.

Raises:
  • XgtNameError – If a frame specified in the dictionary or set does not exist in the system.

  • XgtTypeError – If the graph members are not a dictionary mapping strings to strings, VertexFrames, or EdgeFrames or a set of strings, VertexFrames, or EdgeFrames or if the request specifies a frame which is not a vertex or edge frame.

property connection: Connection

The connection used when constructing the frame.

property graph_members: dict[str, str]

The frames belonging to this graph. Given as a dictionary mapping aliases to frame names.

property name: str

Name of the graph frame.

remove_frames(graph_members: set[str | VertexFrame | EdgeFrame]) None

Remove frames from the graph. The frames are given as a set containing any of names, aliases, VertexFrames, and EdgeFrames.

Parameters:

graph_members (set[str | VertexFrame | EdgeFrame]) – Set of frames to be removed from the graph.

Raises:

XgtTypeError – If the graph members are not a set of strings, VertexFrames, or EdgeFrames.