# -*- tcl -*- # Graph ops tests - Minimum spanning tree/forest per Bipartite # Copyright (c) 2008 Andreas Kupries # All rights reserved. # RCS: @(#) $Id: bipartite.test,v 1.3 2009/09/15 19:24:12 andreas_kupries Exp $ # Syntax: struct::graph::op::isBipartite? G ?partitionvar? # ------------------------------------------------------------------------- # Wrong # args: Missing, Too many test graphop-t${treeimpl}-g${impl}-s${setimpl}-st${stkimpl}-q${queimpl}-bipartite-1.0 {bipartite, wrong args, missing} { catch {struct::graph::op::isBipartite?} msg set msg } [tcltest::wrongNumArgs struct::graph::op::isBipartite? {g ?bipartitionvar?} 0] test graphop-t${treeimpl}-g${impl}-s${setimpl}-st${stkimpl}-q${queimpl}-bipartite-1.1 {bipartite, wrong args, too many} { catch {struct::graph::op::isBipartite? g x y} msg set msg } [tcltest::tooManyArgs struct::graph::op::isBipartite? {g ?bipartitionvar?}] # ------------------------------------------------------------------------- # Logical arguments checks and failures # ------------------------------------------------------------------------- # Ok arguments. test graphop-t${treeimpl}-g${impl}-s${setimpl}-st${stkimpl}-q${queimpl}-bipartite-3.0 {bipartite, empty graph} { SETUP set result [struct::graph::op::isBipartite? mygraph] mygraph destroy set result } 1 test graphop-t${treeimpl}-g${impl}-s${setimpl}-st${stkimpl}-q${queimpl}-bipartite-3.1 {bipartite, nodes, no arcs} { SETUP mygraph node insert 0 1 2 3 4 5 set result [struct::graph::op::isBipartite? mygraph] mygraph destroy set result } 1 test graphop-t${treeimpl}-g${impl}-s${setimpl}-st${stkimpl}-q${queimpl}-bipartite-3.2 {bipartite, no} { SETUP_D set result [struct::graph::op::isBipartite? mygraph] mygraph destroy set result } 0 test graphop-t${treeimpl}-g${impl}-s${setimpl}-st${stkimpl}-q${queimpl}-bipartite-3.3 {bipartite, yes} { SETUP_E set result [struct::graph::op::isBipartite? mygraph] mygraph destroy set result } 1 test graphop-t${treeimpl}-g${impl}-s${setimpl}-st${stkimpl}-q${queimpl}-bipartite-3.4 {bipartite, yes} { SETUP_F set result [struct::graph::op::isBipartite? mygraph] mygraph destroy set result } 1 test graphop-t${treeimpl}-g${impl}-s${setimpl}-st${stkimpl}-q${queimpl}-bipartite-3.5 {bipartite, yes} { SETUP_G set result [struct::graph::op::isBipartite? mygraph] mygraph destroy set result } 1 test graphop-t${treeimpl}-g${impl}-s${setimpl}-st${stkimpl}-q${queimpl}-bipartite-3.6 {bipartite, yes} { SETUP_C set result [struct::graph::op::isBipartite? mygraph] mygraph destroy set result } 1 # ------------------------------------------------------------------------- # Ok arguments, get the partitions. test graphop-t${treeimpl}-g${impl}-s${setimpl}-st${stkimpl}-q${queimpl}-bipartite-4.0 {bipartite, empty graph} { SETUP set result {} struct::graph::op::isBipartite? mygraph result mygraph destroy set result } {{} {}} test graphop-t${treeimpl}-g${impl}-s${setimpl}-st${stkimpl}-q${queimpl}-bipartite-4.1 {bipartite, nodes, no arcs} { SETUP set result {} mygraph node insert 0 1 2 3 4 5 struct::graph::op::isBipartite? mygraph result mygraph destroy bicanon $result } {{} {0 1 2 3 4 5}} test graphop-t${treeimpl}-g${impl}-s${setimpl}-st${stkimpl}-q${queimpl}-bipartite-4.3 {bipartite, yes} { SETUP_E set result {} struct::graph::op::isBipartite? mygraph result mygraph destroy bicanon $result } {{1b 2b 3b 4b 5b 6b 7b 8b} {1w 2w 3w 4w 5w 6w 7w 8w}} test graphop-t${treeimpl}-g${impl}-s${setimpl}-st${stkimpl}-q${queimpl}-bipartite-4.4 {bipartite, yes} { SETUP_F set result {} struct::graph::op::isBipartite? mygraph result mygraph destroy bicanon $result } {{1b 2b 3b 4b} {1w 2w 3w 4w}} test graphop-t${treeimpl}-g${impl}-s${setimpl}-st${stkimpl}-q${queimpl}-bipartite-4.5 {bipartite, yes} { SETUP_G set result {} struct::graph::op::isBipartite? mygraph result mygraph destroy bicanon $result } {{1b 2b 3b 4b 5b} {1w 2w 3w 4w 5w}} test graphop-t${treeimpl}-g${impl}-s${setimpl}-st${stkimpl}-q${queimpl}-bipartite-4.6 {bipartite, yes} { SETUP_C set result {} struct::graph::op::isBipartite? mygraph result mygraph destroy bicanon $result } {{A D F} {B C E}} # ---------------------------------------------------