Registry / devops / graphlib

graphlib

JSON →
library0.9.5pypypi✓ verified 30d ago

A Python library providing a simple Graph API for directed graphs. Current version 0.9.5, released periodically with minimal breaking changes.

devops
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

from graphlib import TopologicalSorter
from graphlib import CycleError
from graphlib import GenericAlias

Create a directed graph, add edges, topologically sort, and detect cycles.

from graphlib import Graph g = Graph() g.add_edge('A', 'B') g.add_edge('B', 'C') # Perform topological sort order = list(g.topological_sort()) print(order) # Output: ['A', 'B', 'C'] (or similar) # Check if graph has cycle print(g.has_cycle()) # Output: False
Debug
Known footguns
breakingIn version 0.9.0, the Graph class constructor changed: graphlib no longer accepts a list of edges as argument; use add_edge() instead.
gotchaThe library does not support multiple edges between same nodes; adding duplicate edge silently succeeds but only one edge is stored.
deprecatedThe method 'topological_sort' returns a generator, not a list. Some code incorrectly wraps it with list() twice, causing error or empty result.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
14 hits · last 30 days
gptbot
3
bytedance
3
amazonbot
2
ahrefsbot
1
Resources