- kernighan_lin_bisection(G, partition=None, max_iter=10, weight='weight', seed=None)¶
Partition a graph into two blocks using the Kernighan–Lin algorithm.
This algorithm partitions a network into two sets by iteratively swapping pairs of nodes to reduce the edge cut between the two sets. The pairs are chosen according to a modified form of Kernighan-Lin, which moves node individually, alternating between sides to keep the bisection balanced.
Pair of iterables containing an initial partition. If not specified, a random balanced partition is used.
Maximum number of times to attempt swaps to find an improvemement before giving up.
Edge data key to use as weight. If None, the weights are all set to one.
- seedinteger, random_state, or None (default)
Indicator of random number generation state. See Randomness. Only used if partition is None
A pair of sets of nodes representing the bipartition.
If partition is not a valid partition of the nodes of the graph.
Kernighan, B. W.; Lin, Shen (1970). “An efficient heuristic procedure for partitioning graphs.” Bell Systems Technical Journal 49: 291–307. Oxford University Press 2011.