graphrecords.builder.GraphRecordBuilder#

class GraphRecordBuilder[source]#

Bases: object

A builder class for constructing GraphRecord instances.

Allows for adding nodes, edges, and groups incrementally, and optionally specifying a schema.

__init__()[source]#

Initializes a new GraphRecordBuilder instance.

Methods

__init__()

Initializes a new GraphRecordBuilder instance.

add_edges(edges, *[, group, bypass_plugins])

Adds edges to the builder.

add_group(group, *[, nodes, bypass_plugins])

Adds a group to the builder with an optional list of nodes.

add_nodes(nodes, *[, group, bypass_plugins])

Adds nodes to the builder.

add_plugin(name, plugin)

Adds a plugin to the builder.

build()

Constructs a GraphRecord instance from the builder's configuration.

with_plugins(plugins)

Specifies plugins for the GraphRecord.

with_schema(schema, *[, bypass_plugins])

Specifies a schema for the GraphRecord.

add_edges(edges, *, group=None, bypass_plugins=False)[source]#

Adds edges to the builder.

Parameters:
  • edges (EdgeInput) – Edges to add.

  • group (Optional[Group], optional) – Group to associate with the edges.

  • bypass_plugins (bool) – If True, plugin hooks are not called. Defaults to False.

Return type:

GraphRecordBuilder

Returns:

GraphRecordBuilder – The current instance of the builder.

add_group(group, *, nodes=None, bypass_plugins=False)[source]#

Adds a group to the builder with an optional list of nodes.

Parameters:
  • group (Group) – The name of the group to add.

  • nodes (List[NodeIndex], optional) – Node indices to add to the group.

  • bypass_plugins (bool) – If True, plugin hooks are not called. Defaults to False.

Return type:

GraphRecordBuilder

Returns:

GraphRecordBuilder – The current instance of the builder.

add_nodes(nodes, *, group=None, bypass_plugins=False)[source]#

Adds nodes to the builder.

Parameters:
  • nodes (NodeInput) – Nodes to add.

  • group (Optional[Group], optional) – Group to associate with the nodes.

  • bypass_plugins (bool) – If True, plugin hooks are not called. Defaults to False.

Return type:

GraphRecordBuilder

Returns:

GraphRecordBuilder – The current instance of the builder.

add_plugin(name, plugin)[source]#

Adds a plugin to the builder.

Parameters:
  • name (PluginName) – The name of the plugin.

  • plugin (Plugin) – The plugin instance to add.

Return type:

GraphRecordBuilder

Returns:

GraphRecordBuilder – The current instance of the builder.

build()[source]#

Constructs a GraphRecord instance from the builder’s configuration.

Return type:

GraphRecord

Returns:

GraphRecord – The constructed GraphRecord instance.

with_plugins(plugins)[source]#

Specifies plugins for the GraphRecord.

Parameters:

plugins (Dict[PluginName, Plugin]) – A dictionary mapping plugin names to plugin instances.

Return type:

GraphRecordBuilder

Returns:

GraphRecordBuilder – The current instance of the builder.

with_schema(schema, *, bypass_plugins=False)[source]#

Specifies a schema for the GraphRecord.

Parameters:
  • schema (Schema) – The schema to apply.

  • bypass_plugins (bool) – If True, plugin hooks are not called. Defaults to False.

Return type:

GraphRecordBuilder

Returns:

GraphRecordBuilder – The current instance of the builder.