gigl.src.common.graph_builder.gbml_graph_protocol#
Classes#
Base class for protocol classes. |
Module Contents#
- class gigl.src.common.graph_builder.gbml_graph_protocol.GbmlGraphDataProtocol[source]#
Bases:
Protocol
Base class for protocol classes.
Protocol classes are defined as:
class Proto(Protocol): def meth(self) -> int: ...
Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing), for example:
class C: def meth(self) -> int: return 0 def func(x: Proto) -> int: return x.meth() func(C()) # Passes static type check
See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:
class GenProto(Protocol[T]): def meth(self) -> T: ...
- static are_disjoint(a, b)[source]#
Returns True if the two GbmlGraphDataProtocol objects do not share any edges. :param a: :param b: :return:
- Parameters:
- Return type:
bool
- static are_same_graph(a, b)[source]#
- Parameters:
- Returns:
Returns True if both a and b objects that implement GbmlGraphDataProtocol represent the same graph in the global space. i.e. both have same nodes + related features, and edges + related features. i.e. a form of loose equality.
For example for a: PygGraphData and b: PygGraphData, may both have same 3 nodes and 3 edges with the same features. But, because they are built in a specific way i.e order of edges and nodes, they may not be strictly equal: a != b. But really, the two represent the same “graph” in different ways. This function fills that gap.
- Return type:
bool
- get_global_edge_features_dict()[source]#
Computes and fetches a dictionary mapping the global edge to its relevant edge features
- Returns:
FrozenDict[Edge, torch.Tensor]
- Return type:
gigl.common.collections.frozen_dict.FrozenDict[gigl.src.common.types.graph_data.Edge, torch.Tensor]
- get_global_node_features_dict()[source]#
Computes and fetches a dictionary mapping the global node to its relevant node features
- Returns:
FrozenDict[Node, torch.Tensor]
- Return type:
gigl.common.collections.frozen_dict.FrozenDict[gigl.src.common.types.graph_data.Node, torch.Tensor]
- property edge_types_to_be_registered: List[gigl.src.common.types.graph_data.EdgeType][source]#
Maintains a list of EdgeTypes associated with this graph data.
Used in conjunction with GraphBuilder, to preserve EdgeTypes when combining multiple GbmlGraphDataProtocol objects together.
- Returns:
List[EdgeType]
- Return type:
- property global_node_to_subgraph_node_mapping: gigl.common.collections.frozen_dict.FrozenDict[gigl.src.common.types.graph_data.Node, gigl.src.common.types.graph_data.Node][source]#
Maintains Mapping from original Node to Mapped Node that is used in the underlying graph data format
During creation of GBML Data representations using graph libraries such as DGL and Pytorch geometric, there may be occasions where nodes will need to be remapped to contiguous node ids 0, 1, 2 …. either as a requirement from the graph library or to maintain simpler logic for formulating and working with these graphs data formats.
- Returns:
Dict[Node, Node]
- Return type:
gigl.common.collections.frozen_dict.FrozenDict[gigl.src.common.types.graph_data.Node, gigl.src.common.types.graph_data.Node]
- property subgraph_node_to_global_node_mapping: gigl.common.collections.frozen_dict.FrozenDict[gigl.src.common.types.graph_data.Node, gigl.src.common.types.graph_data.Node][source]#
Inverse mapping of global_node_to_subgraph_node_mapping
- Return type: