{"library":"pydot","code":"import pydot\nimport os\n\n# Ensure Graphviz dot executable is found. On some systems or environments,\n# pydot might not find it automatically. This is for demonstration; usually,\n# ensuring Graphviz is in PATH is enough.\n# You might need to set this if Graphviz is installed in a non-standard location.\n# For example, on Windows: os.environ[\"PATH\"] += os.pathsep + 'C:/Program Files/Graphviz/bin'\n\ngraph = pydot.Dot('my_graph', graph_type='digraph')\n\nnode_a = pydot.Node('A', style='filled', fillcolor='red')\nnode_b = pydot.Node('B', style='filled', fillcolor='blue')\nnode_c = pydot.Node('C')\n\ngraph.add_node(node_a)\ngraph.add_node(node_b)\ngraph.add_node(node_c)\n\ngraph.add_edge(pydot.Edge(node_a, node_b, label='edge_ab'))\ngraph.add_edge(pydot.Edge(node_b, node_c, label='edge_bc', color='green'))\ngraph.add_edge(pydot.Edge(node_c, node_a, label='edge_ca', arrowhead='vee'))\n\n# Save the graph to a PNG file\ntry:\n    graph.write_png('output_graph.png')\n    print(\"Graph saved to output_graph.png\")\nexcept pydot.InvocationException as e:\n    print(f\"Error generating graph: {e}\")\n    print(\"Make sure Graphviz is installed and its 'dot' executable is in your system PATH.\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to create a directed graph using pydot, add nodes with custom styles, connect them with edges, and save the resulting visualization as a PNG image. It includes basic error handling for common Graphviz executable issues.","tag":null,"tag_description":null,"last_tested":"2026-04-24","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}