graphs.karger ============= .. py:module:: graphs.karger .. autoapi-nested-parse:: An implementation of Karger's Algorithm for partitioning a graph. Attributes ---------- .. autoapisummary:: graphs.karger.TEST_GRAPH Functions --------- .. autoapisummary:: graphs.karger.partition_graph Module Contents --------------- .. py:function:: partition_graph(graph: dict[str, list[str]]) -> set[tuple[str, str]] Partitions a graph using Karger's Algorithm. Implemented from pseudocode found here: https://en.wikipedia.org/wiki/Karger%27s_algorithm. This function involves random choices, meaning it will not give consistent outputs. Args: graph: A dictionary containing adacency lists for the graph. Nodes must be strings. Returns: The cutset of the cut found by Karger's Algorithm. >>> graph = {'0':['1'], '1':['0']} >>> partition_graph(graph) {('0', '1')} .. py:data:: TEST_GRAPH