Skip to main content
Glama

encode_point_size

Set node size encoding in Graphistry visualizations to represent data values like scores or categories through visual scaling for clearer graph analysis.

Instructions

Set node size encoding for a graph using Graphistry's encode_point_size API.

Args:
    graph_id (str): The ID of the graph to modify.
    column (str): The node column to use for size encoding (e.g., 'score', 'type').
    categorical_mapping (dict, optional): Map of category values to sizes. Example: {'mac': 50, 'macbook': 100}. If not provided, Graphistry will auto-assign sizes.
    default_mapping (float, optional): Size to use for values not in categorical_mapping. Example: 20.
    as_continuous (bool, optional): If True, treat the column as continuous and use a size gradient. Example: True for numeric columns like 'score'.

Returns:
    dict: { 'graph_id': ..., 'url': ... } with the updated visualization URL.

Example:
    encode_point_size(graph_id, column='score', as_continuous=True)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
graph_idYes
columnYes
categorical_mappingNo
default_mappingNo

Implementation Reference

  • The main handler function for the 'encode_point_size' tool. It is registered as an MCP tool via @mcp.tool() decorator. The function retrieves the graph from cache, applies node size encoding using Graphistry's encode_point_size method based on the specified column and mappings, updates the cache, and returns the updated graph URL.
    @mcp.tool()
    async def encode_point_size(
        graph_id: str,
        column: str,
        categorical_mapping: Optional[dict] = None,
        default_mapping: Optional[float] = None,
    ) -> Dict[str, Any]:
        """
        Set node size encoding for a graph using Graphistry's encode_point_size API.
    
        Args:
            graph_id (str): The ID of the graph to modify.
            column (str): The node column to use for size encoding (e.g., 'score', 'type').
            categorical_mapping (dict, optional): Map of category values to sizes. Example: {'mac': 50, 'macbook': 100}. If not provided, Graphistry will auto-assign sizes.
            default_mapping (float, optional): Size to use for values not in categorical_mapping. Example: 20.
            as_continuous (bool, optional): If True, treat the column as continuous and use a size gradient. Example: True for numeric columns like 'score'.
    
        Returns:
            dict: { 'graph_id': ..., 'url': ... } with the updated visualization URL.
    
        Example:
            encode_point_size(graph_id, column='score', as_continuous=True)
        """
        if graph_id not in graph_cache:
            raise ValueError(f"Graph not found: {graph_id}")
        g = graph_cache[graph_id]["graph"]
        kwargs = {"column": column}
        if categorical_mapping:
            kwargs["categorical_mapping"] = categorical_mapping
        if default_mapping is not None:
            kwargs["default_mapping"] = default_mapping
        g = g.encode_point_size(**kwargs)
        graph_cache[graph_id]["graph"] = g
        return {"graph_id": graph_id, "url": g.plot(render=False)}

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/graphistry/graphistry-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server