Group-in-a-Box Layout

Group-in-a-Box Layout#

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)