{"id":1320,"library":"altgraph","title":"altgraph","description":"altgraph is a foundational Python library for creating and manipulating directed and undirected graphs (networks). It provides a robust set of tools for graph data structures and basic algorithms, often used as a dependency in projects like PyInstaller. The current version is 0.17.5, with sporadic but active maintenance and releases typically a few times a year.","status":"active","version":"0.17.5","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/altgraph","tags":["graph","network","pyinstaller"],"install":[{"cmd":"pip install altgraph","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"Graph","correct":"from altgraph.Graph import Graph"},{"note":"Used for Graphviz integration.","symbol":"Dot","correct":"from altgraph.Dot import Dot"}],"quickstart":{"code":"from altgraph.Graph import Graph\n\n# Create a new graph\ng = Graph()\n\n# Add nodes\ng.add_node(\"Start\")\ng.add_node(\"Mid\")\ng.add_node(\"End\")\n\n# Add edges\ng.add_edge(\"Start\", \"Mid\")\ng.add_edge(\"Mid\", \"End\")\ng.add_edge(\"Start\", \"End\", label=\"direct\")\n\nprint(f\"Nodes: {list(g.nodes())}\")\nprint(f\"Edges: {list(g.edges())}\")\nprint(f\"Successors of 'Start': {list(g.forw_nodes(\"Start\"))}\")\nprint(f\"Predecessors of 'End': {list(g.back_nodes(\"End\"))}\")\n\n# Example of iterating over nodes and edges\nfor node in g.nodes():\n    print(f\"Node: {node}\")\n\nfor head, tail, data in g.edges():\n    print(f\"Edge: {head} -> {tail} (data: {data})\")","lang":"python","description":"Demonstrates creating a simple directed graph, adding nodes and edges, and basic traversal operations."},"warnings":[{"fix":"Upgrade to a supported Python version (3.6+) or pin altgraph to a version less than 0.17 (e.g., `altgraph==0.16.1`).","message":"Version 0.17.0 and newer dropped support for Python 2.x and older Python 3.x versions (3.3, 3.4, 3.5). If you are using these older Python interpreters, you must use altgraph < 0.17.","severity":"breaking","affected_versions":">=0.17.0"},{"fix":"Install Graphviz separately for your operating system (e.g., `sudo apt-get install graphviz` on Debian/Ubuntu, `brew install graphviz` on macOS, or download from graphviz.org).","message":"When using `altgraph.Dot` for visualizing graphs, the Graphviz system package must be installed and accessible in your system's PATH. This is an external dependency, not a Python package.","severity":"gotcha","affected_versions":"All"},{"fix":"Consider `NetworkX` or `igraph` for complex graph analysis, or use `altgraph` as a foundational layer and implement custom algorithms as needed.","message":"altgraph provides fundamental graph structures and basic algorithms. For advanced graph analytics, highly optimized performance on massive graphs, or a richer set of algorithms (e.g., shortest path, centrality), users might need to integrate with more specialized libraries like NetworkX or igraph.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}