graphs¶
A module containing different graph representations in GraphNeT.
- class graphnet.models.graphs.graphs.KNNGraph(*args, **kwargs)[source]¶
Bases:
GraphDefinition
A Graph representation where Edges are drawn to nearest neighbours.
Construct k-nn graph representation.
- Parameters:
detector (
Detector
) – Detector that represents your data.node_definition (
Optional
[NodeDefinition
], default:None
) – Definition of nodes in the graph.input_feature_names (
Optional
[List
[str
]], default:None
) – Name of input feature columns.dtype (
Optional
[dtype
], default:torch.float32
) – data type for node features.perturbation_dict (
Optional
[Dict
[str
,float
]], default:None
) – Dictionary mapping a feature name to a standard deviation according to which the values for this feature should be randomly perturbed. Defaults to None.seed (
Union
[int
,Generator
,None
], default:None
) – seed or Generator used to randomly sample perturbations. Defaults to None.nb_nearest_neighbours (
int
, default:8
) – Number of edges for each node. Defaults to 8.columns (
List
[int
], default:[0, 1, 2]
) – node feature columns used for distance calculation. Defaults to [0, 1, 2].distance_as_edge_feature (
bool
, default:False
) – Add edge distances as an edge feature. Defaults to False.args (Any)
kwargs (Any)
- Return type:
object
- class graphnet.models.graphs.graphs.EdgelessGraph(*args, **kwargs)[source]¶
Bases:
GraphDefinition
A Data representation without edge assignment.
I.e the resulting representation is created without an EdgeDefinition.
Construct isolated nodes graph representation.
- Parameters:
detector (
Detector
) – Detector that represents your data.node_definition (
Optional
[NodeDefinition
], default:None
) – Definition of nodes in the graph.input_feature_names (
Optional
[List
[str
]], default:None
) – Name of input feature columns.dtype (
Optional
[dtype
], default:torch.float32
) – data type for node features.perturbation_dict (
Optional
[Dict
[str
,float
]], default:None
) – Dictionary mapping a feature name to a standard deviation according to which the values for this feature should be randomly perturbed. Defaults to None.seed (
Union
[int
,Generator
,None
], default:None
) – seed or Generator used to randomly sample perturbations. Defaults to None.args (Any)
kwargs (Any)
- Return type:
object
- class graphnet.models.graphs.graphs.KNNGraphRRWP(*args, **kwargs)[source]¶
Bases:
GraphDefinition
KNN Graph with relative random walk probabilities (RRWP).
Identical to KNNGraph, but with five extra fields containing absolute and relative positional encoding using RRWP.
abs_pe = graph[“rrwp”] # RRWP absolute positional encoding values rrwp_val = graph[“rrwp_val”] # Non-zero values of the RRWP tensor rrwp_index = graph[“rrwp_index] # Corresponding row, col indices degree = graph[“deg”] # Degree of each node (num. of incoming edges)
Construct k-nn graph representation.
- Parameters:
detector (
Detector
) – Detector that represents your data.node_definition (
Optional
[NodeDefinition
], default:None
) – Definition of nodes in the graph.edge_definition (
Optional
[EdgeDefinition
], default:None
) – Definition of edges in the graph.input_feature_names (
Optional
[List
[str
]], default:None
) – Name of input feature columns.dtype (
Optional
[dtype
], default:torch.float32
) – data type for node features.perturbation_dict (
Optional
[Dict
[str
,float
]], default:None
) – Dictionary mapping a feature name to a standard deviation according to which the values for this feature should be randomly perturbed. Defaults to None.seed (
Union
[int
,Generator
,None
], default:None
) – seed or Generator used to randomly sample perturbations. Defaults to None.nb_nearest_neighbours (
int
, default:8
) – Number of edges for each node. Defaults to 8.columns (
List
[int
], default:[0, 1, 2]
) – node feature columns used for distance calculation. Defaults to [0, 1, 2].walk_length (
int
, default:8
) – number of steps for the random walk. Defaults to 8.args (Any)
kwargs (Any)
- Return type:
object
- class graphnet.models.graphs.graphs.KNNGraphRWSE(*args, **kwargs)[source]¶
Bases:
GraphDefinition
KNN Graph with random walk structural encoding (RWSE).
Identical to KNNGraph but with an additional field containing the values obtained from RWSE. The encoding can be accessed via
rwse = graph[“rwse”] # random walk structural encoding
Construct k-nn graph representation.
- Parameters:
detector (
Detector
) – Detector that represents your data.node_definition (
Optional
[NodeDefinition
], default:None
) – Definition of nodes in the graph.edge_definition (
Optional
[EdgeDefinition
], default:None
) – Definition of edges in the graph.input_feature_names (
Optional
[List
[str
]], default:None
) – Name of input feature columns.dtype (
Optional
[dtype
], default:torch.float32
) – data type for node features.perturbation_dict (
Optional
[Dict
[str
,float
]], default:None
) – Dictionary mapping a feature name to a standard deviation according to which the values for this feature should be randomly perturbed. Defaults to None.seed (
Union
[int
,Generator
,None
], default:None
) – seed or Generator used to randomly sample perturbations. Defaults to None.nb_nearest_neighbours (
int
, default:8
) – Number of edges for each node. Defaults to 8.columns (
List
[int
], default:[0, 1, 2]
) – node feature columns used for distance calculation. Defaults to [0, 1, 2].walk_length (
int
, default:8
) – number of steps for the random walk. Defaults to 8.args (Any)
kwargs (Any)
- Return type:
object