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

This documentation was generated offline from a
`load-all`

image. If you want, you can also
browse the documentation from within the UI developer tools. See
the Factor website
for more information.

Factor 0.99 x86.64 (2190, heads/master-6e7f0bbb26, Feb 1 2023 16:51:50)