gigl.src.common.graph_builder.PygGraphBuilder#

class gigl.src.common.graph_builder.pyg_graph_builder.PygGraphBuilder#

Bases: GraphBuilder[PygGraphData]

Methods

__init__

add_edge

Registers a given edge to the TGraph data object that will be built.

add_graph_data

Register pre-built graph data to be built into the new Tgraph data object

add_node

Registers the given node to the TGraph data object that will be built.

build

Builds the actual TGraph data object and returns it with all of the registered nodes and edges.

register_edge_types

Registers edge types

reset

Unregisters / resets all registered nodes and edges.

__init__() None#
classmethod __init_subclass__(*args, **kwargs)#

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__weakref__#

list of weak references to the object (if defined)

add_edge(edge: Edge, feature_values: Tensor | None = None, skip_if_exists: bool = True) GraphBuilder#

Registers a given edge to the TGraph data object that will be built. Both nodes for the edge must be registered before registering the edge

Args:

edge (Edge) feature_values (Optional[torch.Tensor]): The feature for the edge

Returns:

GraphBuilder: returns self

add_graph_data(graph_data: TGraph) GraphBuilder#

Register pre-built graph data to be built into the new Tgraph data object

Args:

graph_data (TGraph): pre-built TGraph data

Returns:

GraphBuilder: returns self

add_node(node: Node, feature_values: Tensor | None = None) GraphBuilder#

Registers the given node to the TGraph data object that will be built.

Args:

node (Node): [description] feature_values (Optional[torch.Tensor]): [The feature for the node

Returns:

GraphBuilder: returns self

build() PygGraphData#

Builds the actual TGraph data object and returns it with all of the registered nodes and edges. Will also reset i.e. unregister all existed nodes and edges such that GraphBuilder can be used again to build a new graph

Returns:

TGraph: The data object with all of the nodes/edges

register_edge_types(edge_types: List[EdgeType]) GraphBuilder#

Registers edge types

Args:

edge_types (List[EdgeType])

Returns:

GraphBuilder: returns self

reset() None#

Unregisters / resets all registered nodes and edges. “Reinitialized the class to a clean state”