In graph theory, a bipartite graph is one in which the nodes can be divided into exactly two independent sets (i.e., there are no edges between nodes in the same set).

USING: formatting locals math.parser sequences
graphviz graphviz.notation graphviz.render ;
:: partite-set ( n color -- cluster )
color <cluster>
color =color
[node color =color ];
n <iota> [
number>string color prepend add-node
] each ;
:: K_n,m ( n m -- )
<graph>
[node "point" =shape ];
[graph "t" =labelloc "dot" =layout "LR" =rankdir ];
n "#FF0000" partite-set
m "#0000FF" partite-set
add-edge ! between clusters
! set label last so that clusters don't inherit it
n m "K %d,%d" sprintf =label
preview ;

3 3 K_n,m

3 4 K_n,m

5 4 K_n,m