gigl.src.common.graph_builder.abstract_graph_builder#
Attributes#
Classes#
Abstract base class for generic types. |
Module Contents#
- class gigl.src.common.graph_builder.abstract_graph_builder.GraphBuilder[source]#
Bases:
Generic
[TGraph
]Abstract base class for generic types.
A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:
class Mapping(Generic[KT, VT]): def __getitem__(self, key: KT) -> VT: ... # Etc.
This class can then be used as follows:
def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default
- add_edge(edge, feature_values=None, skip_if_exists=True)[source]#
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
- Parameters:
edge (Edge)
feature_values (Optional[torch.Tensor]) – The feature for the edge
skip_if_exists (bool)
- Returns:
returns self
- Return type:
- add_graph_data(graph_data)[source]#
Register pre-built graph data to be built into the new Tgraph data object
- Parameters:
graph_data (TGraph) – pre-built TGraph data
- Returns:
returns self
- Return type:
- add_node(node, feature_values=None)[source]#
Registers the given node to the TGraph data object that will be built.
- Parameters:
node (Node) – [description]
feature_values (Optional[torch.Tensor]) – [The feature for the node
- Returns:
returns self
- Return type:
- abstract build()[source]#
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:
The data object with all of the nodes/edges
- Return type:
TGraph