tglite.TBatch

class tglite.TBatch(g: TGraph, range: Tuple[int, int])

Represents a batch of temporal edges to process. A thin wrapper with a TGraph reference and without actually materializing any arrays until they are needed.

__init__(g: TGraph, range: Tuple[int, int])

Internal constructor for creating a TBatch.

Parameters:
  • g (TGraph) – The TGraph.

  • range (Tuple[int, int]) – The range of edge indices: beginning and ending edge index.

Get graph data

g

Returns the TGraph.

neg_nodes

Get the negative nodes.

eids()

Returns edge ids of the batch.

edges()

Returns the edges in the batch as a two-column ndarray, where the first column represents the source

nodes([include_negs, reverse])

Returns a node index array: [src, des(, neg)] if reverse is False or [des, src(, src)] if reverse is True.

times([include_dsts, include_negs])

Returns timestamps corresponding to the nodes. It retrieves timestamps of the batch edges (as the timestamps for source nodes),

Get TBlock

block(ctx)

Creates the head TBlock of the batch, including negative nodes if set.

block_adj(ctx)

Creates the head TBlock with batch edges as neighbors (excluding negative nodes).

Split data

split_data(data)

Splits the data into multiple arrays, with each array containing a number of rows equal to the batch size.