MultiOrderModel
MultiOrderModel
¶
MultiOrderModel based on torch_geometric.Data.
Source code in src/pathpyG/core/MultiOrderModel.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
|
__str__
¶
Return a string representation of the higher-order graph.
aggregate_edge_index
staticmethod
¶
Aggregate the possibly duplicated edges in the (higher-order) edge index and return a graph object containing the (higher-order) edge index without duplicates and the node sequences. The edge weights of duplicated edges are summed up.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge_index |
torch.Tensor
|
The edge index of a (higher-order) graph where each source and destination node corresponds to a node which is an edge in the (k-1)-th order graph. |
required |
node_sequence |
torch.Tensor
|
The node sequences of first order nodes that each node in the edge index corresponds to. |
required |
edge_weight |
torch.Tensor | None
|
The edge weights corresponding to the edge index. |
None
|
Source code in src/pathpyG/core/MultiOrderModel.py
aggregate_edge_weight
staticmethod
¶
Aggregate edge weights of a (k-1)-th order graph for a kth-order graph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ho_index |
torch.Tensor
|
The higher-order edge index of the higher-order graph. |
required |
edge_weight |
torch.Tensor
|
The edge weights of the (k-1)th order graph. |
required |
aggr |
str
|
The aggregation method to use. One of "src", "dst", "max", "mul". |
'src'
|
Source code in src/pathpyG/core/MultiOrderModel.py
from_PathData
staticmethod
¶
Creates multiple higher-order De Bruijn graphs modelling paths in PathData.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path_data |
pathpyG.core.path_data.PathData
|
|
required |
max_order |
int
|
The maximum order of the MultiOrderModel that should be computed |
1
|
mode |
str
|
The process that we assume. Can be "diffusion" or "propagation". |
'propagation'
|
cached |
bool
|
Whether to save the aggregated higher-order graphs smaller than max order in the MultiOrderModel. |
True
|
Source code in src/pathpyG/core/MultiOrderModel.py
from_temporal_graph
staticmethod
¶
Creates multiple higher-order De Bruijn graph models for paths in a temporal graph.
Source code in src/pathpyG/core/MultiOrderModel.py
iterate_lift_order
staticmethod
¶
Lift order by one and save the result in the layers dictionary of the object. This is a helper function that should not be called directly. Only use for edge_indices after the special cases have been handled e.g. in the from_temporal_graph (filtering non-time-respecting paths of order 2) or from_PathData (reindexing with dataloader) functions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge_index |
torch.Tensor
|
The edge index of the (k-1)-th order graph. |
required |
node_sequence |
torch.Tensor
|
The node sequences of the (k-1)-th order graph. |
required |
edge_weight |
torch.Tensor | None
|
The edge weights of the (k-1)-th order graph. |
None
|
k |
The order of the graph that should be computed. |
required | |
aggr |
str
|
The aggregation method to use. One of "src", "dst", "max", "mul". |
'src'
|
save |
bool
|
Whether to compute the aggregated graph and later save it in the layers dictionary. |
True
|
Source code in src/pathpyG/core/MultiOrderModel.py
lift_order_edge_index
staticmethod
¶
Do a line graph transformation on the edge index to lift the order of the graph by one. Assumes that the edge index is sorted.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge_index |
torch.Tensor
|
A sorted edge index tensor of shape (2, num_edges). |
required |
num_nodes |
int
|
The number of nodes in the graph. |
required |
Source code in src/pathpyG/core/MultiOrderModel.py
lift_order_edge_index_weighted
staticmethod
¶
Do a line graph transformation on the edge index to lift the order of the graph by one. Additionally, aggregate the edge weights of the (k-1)-th order graph to the (k)-th order graph. Assumes that the edge index is sorted.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge_index |
torch.Tensor
|
A sorted edge index tensor of shape (2, num_edges). |
required |
edge_weight |
torch.Tensor
|
The edge weights of the (k-1)th order graph. |
required |
num_nodes |
int
|
The number of nodes in the graph. |
required |
aggr |
str
|
The aggregation method to use. One of "src", "dst", "max", "mul". |
'src'
|
Source code in src/pathpyG/core/MultiOrderModel.py
to_dbgnn_data
¶
Convert the MultiOrderModel to a De Bruijn graph for the given maximum order.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_order |
int
|
The maximum order of the De Bruijn graph to be computed. |
2
|
mapping |
str
|
The mapping to use for the bipartite edge index. One of "last", "first", or "both". |
'last'
|