CoolFace
Apppublic

LPXian/Graph-News.AI

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
visualize_graph.py24 linesDownload Raw Back to root
1from app.graph.builder import app_graph2import os3 4def visualize():5    # Get the graph image bytes6    try:7        graph_png = app_graph.get_graph().draw_mermaid_png()8        9        # Save to file10        output_path = "graph_visualization.png"11        with open(output_path, "wb") as f:12            f.write(graph_png)13            14        print(f"Graph visualization saved to: {os.path.abspath(output_path)}")15        print("You can now open this image file to see your StateGraph structure.")16        17    except Exception as e:18        print(f"Error generating graph: {e}")19        print("Note: You might need to install 'pygraphviz' or 'grandalf' for some formats,")20        print("or ensure you have an internet connection if using the Mermaid API.")21 22if __name__ == "__main__":23    visualize()24