src.preprocessing.compute_layout

Computes the x and y coordinates for the nodes in the graph, based on a story that each row is in.

Classes

ComputeLayout([spacing_within_story, transpose])

Compute the layout of the graph.

class src.preprocessing.compute_layout.ComputeLayout(spacing_within_story='uniform', transpose=False)[source]

Compute the layout of the graph.

The data is expected to have “adj_list”, “adj_weights” columns that contains the adjacency list of the graph. The “storyline” column contains the storyline index for each row. It will return the data with “x” and “y” columns that contains the layout for each row.

Parameters:
  • spacing_within_story (Literal['uniform', 'time-scaled']) – The spacing of the nodes. Either “uniform” or “time-scaled”.

  • transpose (bool) – Transpose the x and y coordinates.

spacing_within_story: Literal['uniform', 'time-scaled'] = 'uniform'
transpose: bool = False
custom_transform(data, **transform_args)[source]

Compute the layout of the graph.

Retrieves the storylines from the data and computes the layout of the nodes.

Parameters:
  • data (DataFrame) – The data to compute the layout for.

  • transform_args (Never) – [UNUSED] Additional keyword arguments.

Return type:

DataFrame

Returns:

The data with the layout.