gigl.types.graph#

Attributes#

Classes#

FeaturePartitionData

Data and indexing info of a node/edge feature partition.

GraphPartitionData

Data and indexing info of a graph partition.

LoadedGraphTensors

PartitionOutput

Functions#

message_passing_to_negative_label(...)

Convert a message passing edge type to a negative label edge type.

message_passing_to_positive_label(...)

Convert a message passing edge type to a positive label edge type.

select_label_edge_types(message_passing_edge_type, ...)

Select label edge types for a given message passing edge type.

to_heterogeneous_edge(…)

Convert a value to a heterogeneous edge representation.

to_heterogeneous_node(…)

Convert a value to a heterogeneous node representation.

to_homogeneous(…)

Convert a value to a homogeneous representation.

Module Contents#

class gigl.types.graph.FeaturePartitionData[source]#

Data and indexing info of a node/edge feature partition.

feats: torch.Tensor[source]#
ids: torch.Tensor | None[source]#
class gigl.types.graph.GraphPartitionData[source]#

Data and indexing info of a graph partition.

edge_ids: torch.Tensor[source]#
edge_index: torch.Tensor[source]#
weights: torch.Tensor | None = None[source]#
class gigl.types.graph.LoadedGraphTensors[source]#
treat_labels_as_edges()[source]#

Convert positive and negative labels to edges. Converts this object in-place to a “heterogeneous” representation.

This function requires the following conditions and will throw if they are not met:
  1. The positive_label is not None

Return type:

None

edge_features: torch.Tensor | dict[gigl.src.common.types.graph_data.EdgeType, torch.Tensor] | None[source]#
edge_index: torch.Tensor | dict[gigl.src.common.types.graph_data.EdgeType, torch.Tensor][source]#
negative_label: torch.Tensor | dict[gigl.src.common.types.graph_data.EdgeType, torch.Tensor] | None[source]#
node_features: torch.Tensor | dict[gigl.src.common.types.graph_data.NodeType, torch.Tensor] | None[source]#
node_ids: torch.Tensor | dict[gigl.src.common.types.graph_data.NodeType, torch.Tensor][source]#
positive_label: torch.Tensor | dict[gigl.src.common.types.graph_data.EdgeType, torch.Tensor] | None[source]#
class gigl.types.graph.PartitionOutput[source]#
edge_partition_book: graphlearn_torch.partition.PartitionBook | dict[gigl.src.common.types.graph_data.EdgeType, graphlearn_torch.partition.PartitionBook][source]#
node_partition_book: graphlearn_torch.partition.PartitionBook | dict[gigl.src.common.types.graph_data.NodeType, graphlearn_torch.partition.PartitionBook][source]#
partitioned_edge_features: FeaturePartitionData | dict[gigl.src.common.types.graph_data.EdgeType, FeaturePartitionData] | None[source]#
partitioned_edge_index: GraphPartitionData | dict[gigl.src.common.types.graph_data.EdgeType, GraphPartitionData] | None[source]#
partitioned_negative_labels: torch.Tensor | dict[gigl.src.common.types.graph_data.EdgeType, torch.Tensor] | None[source]#
partitioned_node_features: FeaturePartitionData | dict[gigl.src.common.types.graph_data.NodeType, FeaturePartitionData] | None[source]#
partitioned_positive_labels: torch.Tensor | dict[gigl.src.common.types.graph_data.EdgeType, torch.Tensor] | None[source]#
gigl.types.graph.message_passing_to_negative_label(message_passing_edge_type)[source]#

Convert a message passing edge type to a negative label edge type.

Parameters:

message_passing_edge_type (EdgeType) – The message passing edge type.

Returns:

The negative label edge type.

Return type:

EdgeType

gigl.types.graph.message_passing_to_positive_label(message_passing_edge_type)[source]#

Convert a message passing edge type to a positive label edge type.

Parameters:

message_passing_edge_type (EdgeType) – The message passing edge type.

Returns:

The positive label edge type.

Return type:

EdgeType

gigl.types.graph.select_label_edge_types(message_passing_edge_type, edge_entities)[source]#

Select label edge types for a given message passing edge type.

Parameters:
  • message_passing_edge_type (EdgeType) – The message passing edge type.

  • edge_entities (abc.Iterable[EdgeType]) – The edge entities to select from.

Returns:

A tuple containing the positive label edge type and optionally the negative label edge type.

Return type:

tuple[EdgeType, Optional[EdgeType]]

gigl.types.graph.to_heterogeneous_edge(x: None) None[source]#
gigl.types.graph.to_heterogeneous_edge(x: _GraphEntity | dict[gigl.src.common.types.graph_data.EdgeType, _GraphEntity]) dict[gigl.src.common.types.graph_data.EdgeType, _GraphEntity]

Convert a value to a heterogeneous edge representation.

If the input is None, return None. If the input is a dictionary, return it as is. If the input is a single value, return it as a dictionary with the default homogeneous edge type as the key.

Parameters:

x (Optional[Union[_GraphEntity, dict[EdgeType, _GraphEntity]]]) – The input value to convert.

Returns:

The converted heterogeneous edge representation.

Return type:

Optional[dict[EdgeType, _GraphEntity]]

gigl.types.graph.to_heterogeneous_node(x: None) None[source]#
gigl.types.graph.to_heterogeneous_node(x: _GraphEntity | dict[gigl.src.common.types.graph_data.NodeType, _GraphEntity]) dict[gigl.src.common.types.graph_data.NodeType, _GraphEntity]

Convert a value to a heterogeneous node representation.

If the input is None, return None. If the input is a dictionary, return it as is. If the input is a single value, return it as a dictionary with the default homogeneous node type as the key.

Parameters:

x (Optional[Union[_GraphEntity, dict[NodeType, _GraphEntity]]]) – The input value to convert.

Returns:

The converted heterogeneous node representation.

Return type:

Optional[dict[NodeType, _GraphEntity]]

gigl.types.graph.to_homogeneous(x: None) None[source]#
gigl.types.graph.to_homogeneous(x: collections.abc.Mapping[gigl.src.common.types.graph_data.NodeType, _GraphEntity]) _GraphEntity
gigl.types.graph.to_homogeneous(x: collections.abc.Mapping[gigl.src.common.types.graph_data.EdgeType, _GraphEntity]) _GraphEntity
gigl.types.graph.to_homogeneous(x: _GraphEntity) _GraphEntity

Convert a value to a homogeneous representation.

If the input is None, return None. If the input is a dictionary, return the single value in the dictionary. If the input is a single value, return it as is.

Parameters:

x (Optional[Union[_T, dict[Union[NodeType, EdgeType], _T]]]) – The input value to convert.

Returns:

The converted homogeneous representation.

Return type:

Optional[_T]

gigl.types.graph.DEFAULT_HOMOGENEOUS_EDGE_TYPE[source]#
gigl.types.graph.DEFAULT_HOMOGENEOUS_NODE_TYPE[source]#
gigl.types.graph.logger[source]#