graphistry.layout.gib package#

Submodules#

graphistry.layout.gib.gib module#

graphistry.layout.gib.gib.group_in_a_box_layout(self, partition_alg=None, partition_params=None, layout_alg=None, layout_params=None, x=0, y=0, w=None, h=None, encode_colors=True, colors=None, partition_key=None, engine='auto')#

Perform a group-in-a-box layout on a graph, supporting both CPU and GPU execution modes.

This layout algorithm organizes nodes into rectangular bounding boxes based on a partitioning algorithm. It supports various layout algorithms within each partition and optional color encoding based on the partition.

Supports passing in a custom per-partition layout algorithm handler.

Parameters:
  • partition_alg (Optional[str]) – (optional) The algorithm to use for partitioning the graph nodes. Examples include ‘community’ or ‘louvain’.

  • partition_params (Optional[Dict[str, Any]]) – (optional) Parameters for the partition algorithm, passed as a dictionary.

  • layout_alg (Optional[Union[str, Callable[[Plottable], Plottable]]]) –

    (optional) The layout algorithm to arrange nodes within each partition.

  • layout_params (Optional[Dict[str, Any]]) – (optional) Parameters for the layout algorithm.

  • x (float) – (optional) The x-coordinate for the top-left corner of the layout. Default is 0.

  • y (float) – (optional) The y-coordinate for the top-left corner of the layout. Default is 0.

  • w (Optional[float]) – (optional) The width of the layout. If None, it will be automatically determined based on the number of partitions.

  • h (Optional[float]) – (optional) The height of the layout. If None, it will be automatically determined based on the number of partitions.

  • encode_colors (bool) – (optional) Whether to apply color encoding to nodes based on partitions. Default is True.

  • colors (Optional[List[str]]) – (optional) List of colors to use for the partitions. If None, default colors will be applied.

  • partition_key (Optional[str]) – (optional) The key for partitioning nodes. If not provided, defaults to a relevant partitioning key for the algorithm.

  • engine (Union[graphistry.Engine.EngineAbstract, Literal["auto"]]) – (optional) The execution engine for the layout, either “auto” (default), “cpu”, or “gpu”.

  • self (Plottable)

Returns:

A graph object with nodes arranged in a group-in-a-box layout.

Return type:

graphistry.Plottable.Plottable

Example 1: Basic GPU Group-in-a-Box Layout Using ECG Community Detection
g_final = g.group_in_a_box_layout(partition_alg='ecg')
Example 2: Group-in-a-Box on a precomputed partition key
g_partitioned = g.compute_cugraph('ecg')
g_final = g_partitioned.group_in_a_box_layout(partition_key='ecg')
Example 3: Custom Group-in-a-Box Layout with FA2 for Layout and Color Encoding
g_final = g.group_in_a_box_layout(
    partition_alg='louvain',
    partition_params={'resolution': 1.0},
    layout_alg=lambda g: fa2_with_circle_singletons(g),
    encode_colors=True,
    colors=['#ff0000', '#00ff00', '#0000ff']
)
Example 4: Advanced Usage with Custom Bounding Box and GPU Execution
g_final = g.group_in_a_box_layout(
    partition_alg='louvain',
    layout_alg='force_atlas2',
    x=100, y=100, w=500, h=500,  # Custom bounding box
    engine='gpu'  # Use GPU for faster layout
)
graphistry.layout.gib.gib.resolve_partition_key(g, partition_key=None, partition_alg=None)#
Parameters:

partition_alg (str | None)

graphistry.layout.gib.layout_bulk module#

graphistry.layout.gib.layout_bulk.layout_bulk_mode(self, nodes, partition_key, layout_alg, layout_params, engine)#

Handles layout for bulk mode. Applies layout to the entire graph

Assumes cross-partition edges already removed

Parameters:
  • nodes (DataFrame) – The nodes of the graph.

  • partition_key (str) – The partition key.

  • layout_alg (Optional[Union[str, Callable[[Plottable], Plottable]]]) – Layout algorithm to be applied.

  • layout_params (Optional[Dict[str, Any]]) – Parameters for the layout algorithm.

  • engine (Engine) – The engine being used (Pandas or CUDF).

  • self (Plottable)

Returns:

The resulting DataFrame of positioned nodes.

Return type:

DataFrame

graphistry.layout.gib.layout_non_bulk module#

graphistry.layout.gib.layout_non_bulk.layout_non_bulk_mode(self, node_partitions, remaining, partition_key, layout_alg, layout_params, engine, self_selfless)#

Handles the layout in non-bulk mode by applying the layout separately for each partition.

Parameters:
  • node_partitions (List[pd.DataFrame]) – List of DataFrames for node partitions.

  • remaining (DataFrame) – DataFrame of remaining nodes after filtering.

  • partition_key (str) – The partition key.

  • layout_alg (Optional[Union[str, Callable[[Plottable], Plottable]]]) – Layout algorithm to be applied.

  • layout_alg – Layout algorithm to be applied.

  • layout_params (Optional[Dict[str, Any]]) – Parameters for the layout algorithm.

  • engine (Engine) – The engine being used (Pandas or CUDF).

  • self_selfless (Plottable) – Graph excluding self-edges.

  • self (Plottable)

Returns:

Tuple containing node partitions, layout time, keep time, and layout by size.

Return type:

Tuple[List[DataFrame], float, float, Dict[int, Tuple[int, float]]]

graphistry.layout.gib.partition module#

graphistry.layout.gib.partition.partition(self, partition_alg=None, partition_params=None, partition_key='partition', engine=Engine.PANDAS)#

Label each node with a partition key. If partition key is already provided, preserve.

Supports both pandas and cudf:

Pandas (igraph): Defaults to infomap CuDF: Defaults to ecg

Parameters:
  • self (Plottable)

  • partition_alg (str | None)

  • partition_params (Dict | None)

  • engine (Engine)

graphistry.layout.gib.partitioned_layout module#

graphistry.layout.gib.partitioned_layout.partitioned_layout(self, partition_offsets, layout_alg=None, layout_params=None, partition_key='partition', bulk_mode=True, engine=Engine.PANDAS)#
Parameters:
  • partition_offsets (Dict[str, Dict[int, float]]) – {‘dx’, ‘dy’, ‘x’, ‘y’} => <partition> => float

  • layout_alg (Optional[Union[str, Callable[[Plottable], Plottable]]]) – Layout algorithm to be applied if partition_key column does not already exist; GPU defaults to fa2_layout, CPU defaults to igraph fr

  • layout_params (Optional[Dict[str, Any]]) – Parameters for the layout algorithm

  • partition_key (str) – The partition key; defaults to the layout_alg

  • bulk_mode (bool) – Whether to apply layout in bulk mode

  • engine (Engine) – The engine being used (Pandas or CUDF)

  • self (Plottable)

Returns:

The resulting Plottable object with positioned nodes

Return type:

Plottable

graphistry.layout.gib.style module#

graphistry.layout.gib.style.categorical_color_by_col(self, col, colors, engine=Engine.PANDAS)#
Parameters:
  • self (Plottable)

  • col (str)

  • colors (List[str] | None)

  • engine (Engine)

Return type:

Plottable

graphistry.layout.gib.style.lazy_paired_12()#
graphistry.layout.gib.style.style_layout(self, encode_color=True, colors=None, partition_key='partition', engine=Engine.PANDAS)#
Parameters:
  • self (Plottable)

  • colors (List[str] | None)

  • engine (Engine)

Return type:

Plottable

graphistry.layout.gib.treemap module#

graphistry.layout.gib.treemap.treemap(self, x=0, y=0, w=None, h=None, partition_key='partition', engine=Engine.PANDAS)#

Group nodes by partition key and compute treemap cell positions Output dictionary format is prop_name -> partition id -> prop_value

Parameters:
  • self (Plottable)

  • w (float | None)

  • h (float | None)

  • engine (Engine)

Return type:

Dict[str, Dict[int, float]]

Module contents#