apply_modularity_weighted_layout
Optimize graph visualization by applying modularity-based weighted layout to reveal community structures and relationships in network data.
Instructions
Apply modularity weighted layout to the graph using Graphistry's modularity_weighted_layout API.
Args:
graph_id (str): The ID of the graph to modify.
Returns:
dict: { 'graph_id': ..., 'url': ... } with the updated visualization URL.
Example:
apply_modularity_weighted_layout(graph_id)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| graph_id | Yes |
Implementation Reference
- The @mcp.tool()-decorated handler function that applies Graphistry's modularity_weighted_layout to the specified graph from cache and returns the updated visualization URL. This is both the implementation and registration of the tool.async def apply_modularity_weighted_layout(graph_id: str) -> Dict[str, Any]: """ Apply modularity weighted layout to the graph using Graphistry's modularity_weighted_layout API. Args: graph_id (str): The ID of the graph to modify. Returns: dict: { 'graph_id': ..., 'url': ... } with the updated visualization URL. Example: apply_modularity_weighted_layout(graph_id) """ if graph_id not in graph_cache: raise ValueError(f"Graph not found: {graph_id}") g = graph_cache[graph_id]["graph"] g = g.modularity_weighted_layout() graph_cache[graph_id]["graph"] = g return {"graph_id": graph_id, "url": g.plot(render=False)}