<?xml version="1.0" encoding="UTF-8"?>
<Worksheet><Version major="6" minor="1"/><View-Properties><Zoom percentage="100"/></View-Properties><Styles><Layout alignment="left" firstindent="0.0" leftmargin="0.0" linespacing="0.0" name="_pstyle7" rightmargin="0.0" spaceabove="0.0" spacebelow="0.0"/><Layout alignment="left" firstindent="0.0" leftmargin="0.0" linespacing="0.0" name="_pstyle6" rightmargin="0.0" spaceabove="0.0" spacebelow="0.0"/><Layout alignment="left" firstindent="0.0" leftmargin="0.0" linespacing="0.0" name="_pstyle5" rightmargin="0.0" spaceabove="12.0" spacebelow="0.0"/><Layout alignment="left" firstindent="0.0" leftmargin="0.0" linespacing="0.0" name="_pstyle4" rightmargin="0.0" spaceabove="0.0" spacebelow="0.0"/><Layout alignment="centred" firstindent="0.0" leftmargin="0.0" linespacing="0.0" name="_pstyle3" rightmargin="0.0" spaceabove="0.0" spacebelow="0.0"/><Layout alignment="centred" firstindent="0.0" leftmargin="0.0" linespacing="0.0" name="_pstyle2" rightmargin="0.0" spaceabove="8.0" spacebelow="8.0"/><Layout alignment="centred" firstindent="0.0" leftmargin="0.0" linespacing="0.0" name="_pstyle1" pagebreak-before="true" rightmargin="0.0" spaceabove="12.0" spacebelow="12.0"/><Layout alignment="centred" bullet="none" linespacing="0.5" name="Maple Output"/><Layout alignment="left" firstindent="0.0" leftmargin="0.0" linespacing="0.0" name="Normal" rightmargin="0.0" spaceabove="0.0" spacebelow="0.0"/><Layout alignment="left" firstindent="0.0" leftmargin="0.0" linespacing="0.0" name="_pstyle13" rightmargin="0.0" spaceabove="12.0" spacebelow="0.0"/><Layout alignment="left" firstindent="0.0" leftmargin="0.0" linespacing="0.0" name="_pstyle12" rightmargin="0.0" spaceabove="12.0" spacebelow="0.0"/><Font background="[0,0,0]" bold="true" executable="true" family="Monospaced" foreground="[255,0,0]" name="Maple Input" opaque="false" size="12"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="Text" opaque="false" size="12" underline="false"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="_pstyle6" readonly="false" size="12" underline="false"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="_pstyle4" readonly="false" size="12" underline="false"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="_pstyle3" readonly="false" size="12" underline="false"/><Font background="[0,0,0]" bold="true" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="true" name="_cstyle5" readonly="false" size="9" underline="false"/><Font background="[0,0,0]" bold="true" executable="true" family="Monospaced" foreground="[255,0,0]" italic="false" name="_cstyle4" readonly="false" size="12" underline="false"/><Font background="[0,0,0]" bold="true" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="_cstyle3" readonly="false" size="16" underline="false"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="true" name="_cstyle2" readonly="false" size="12" underline="false"/><Font background="[0,0,0]" bold="true" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="_cstyle1" readonly="false" size="20" underline="false"/><Font background="[0,0,0]" family="Times New Roman" foreground="[0,0,255]" name="2D Output" opaque="false" readonly="true" size="12"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="Normal" readonly="false" size="12" underline="false"/><Font background="[0,0,0]" family="Times New Roman" name="Page Number" underline="false"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="_pstyle13" readonly="false" size="9" underline="false"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="_pstyle12" readonly="false" size="12" underline="false"/></Styles><Page-Numbers enabled="false" first-number="1" first-numbered-page="1" horizontal-location="right" style="Page Number" vertical-location="bottom"/><Group><Input><Text-field layout="_pstyle1" style="_cstyle1">Max Flow - Min Cut</Text-field><Text-field layout="_pstyle2" style="_cstyle2"><Font encoding="ISO8859-1">by Laurie L. Lacey, Ph.D., Schenectady County Community College, Schenectady NY, USA, laceyll@gw.sunysccc.edu, \251 2004 Laurie L. Lacey</Font></Text-field><Text-field layout="_pstyle3" style="_pstyle3">NOTE: This worksheet constructs a maplet that can be used by the student in a Discrete math class to investigate network flows.  </Text-field><Text-field layout="_pstyle4" style="_pstyle4"/></Input></Group><Section><Title><Text-field layout="_pstyle5" style="_cstyle3">Introduction</Text-field></Title><Text-field layout="_pstyle6" style="_pstyle6">When this maplet is run, it allows the student to examine the Max Flow - Min Cut Theorem.  Students can compare the value of the maximum flow to the value of the minimum cut, and determine the edges of the minimum cut as well as the saturated edges. Students can observe the graph with the minimum cut edges removed.  The maplet was constructed using Maple 9.5.  A sample graph has been loaded into the first textfield so the student can see the syntax.</Text-field><Text-field layout="_pstyle4" style="_pstyle4"/><Text-field layout="_pstyle6" style="_pstyle6"/><Group><Input><Text-field layout="_pstyle7" prompt="&gt; " style="_cstyle4">restart:</Text-field></Input></Group></Section><Section><Title><Text-field layout="_pstyle6" style="_pstyle6"/></Title><Group><Input><Text-field layout="_pstyle7" prompt="&gt; " style="_cstyle4">restart;with(Maplets[Elements]):
with(networks):#The networks package is accessed so that we may examine the graphs.</Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input"><Font italic="false" underline="false"> #alter the graph to delete the edges of the minimum cut                                     </Font></Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">Mincutplot := proc() <Font italic="false" underline="false">local G,s,t,f,H;                                                      </Font>
	G:= Maplets[Tools][Get]('TF1'::algebraic);                                                     
	s:= Maplets[Tools][Get]('TF2'::algebraic);                                                     
	t:= Maplets[Tools][Get]('TF3'::algebraic); 
   	f:=edges(G) minus mincut(G,s,t);      
	H:=induce(f,G):draw(H);
end proc:</Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">#calculate the maximum flow for the given network </Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input"><Font italic="false" underline="false">Flow := proc() </Font> <Font italic="false" underline="false">
	local G,s,t;</Font>                                                                           
	G:= Maplets[Tools][Get]('TF1'::algebraic);                                       
	s:= Maplets[Tools][Get]('TF2'::algebraic);                                       
	t:= Maplets[Tools][Get]('TF3'::algebraic); <Font italic="false" underline="false">
   </Font>     <Font italic="false" underline="false">
	flow(G,s,t);  
end proc:</Font></Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">#calculate the saturated edges of the maximum flow                                            </Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input"><Font italic="false" underline="false">SaturatedEdges := proc() </Font> <Font italic="false" underline="false">
	local G,s,t,eset,comp;</Font>  
	eset := 'eset': comp := 'comp':                                               
	G:= Maplets[Tools][Get]('TF1'::algebraic);                             
	s:= Maplets[Tools][Get]('TF2'::algebraic);                                       
	t:= Maplets[Tools][Get]('TF3'::algebraic); <Font italic="false" underline="false">
   </Font>     <Font italic="false" underline="false">
	flow(G,s,t,eset); eset; 
end proc:</Font></Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">#calculate the saturated vertices of the maximum flow </Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input"><Font italic="false" underline="false">SaturatedVertices := proc() </Font> <Font italic="false" underline="false">
	local G,s,t,eset,comp;</Font>    
	eset := 'eset': comp := 'comp':                                                                                 	G:= Maplets[Tools][Get]('TF1'::algebraic);                                       
	s:= Maplets[Tools][Get]('TF2'::algebraic);                                       
	t:= Maplets[Tools][Get]('TF3'::algebraic); <Font italic="false" underline="false">
   </Font>     <Font italic="false" underline="false">
      flow(G,s,t,eset,comp); comp; 
end proc:</Font></Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input"><Font italic="false" underline="false"> #calculate the edges of the minimum cut   </Font></Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input"><Font italic="false" underline="false">MinCut := proc()</Font> <Font italic="false" underline="false">
	local G,s,t;                                                                                           	</Font>
	G:= Maplets[Tools][Get]('TF1'::algebraic);                                       
	s:= Maplets[Tools][Get]('TF2'::algebraic);                                       
	t:= Maplets[Tools][Get]('TF3'::algebraic); <Font italic="false" underline="false">
   </Font>   <Font italic="false" underline="false">
	mincut(G,s,t);  
end proc:</Font></Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input"><Font italic="false" underline="false">#calculate the value of the minimum cut for comparison with value of maximum flow           </Font></Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input"><Font italic="false" underline="false">MinCutValue := proc()  
	local G,s,t,vf;vf:='vf':                                                                 </Font>
	G:= Maplets[Tools][Get]('TF1'::algebraic);                                       
	s:= Maplets[Tools][Get]('TF2'::algebraic);                                       
	t:= Maplets[Tools][Get]('TF3'::algebraic); <Font italic="false" underline="false">
	</Font>    <Font italic="false" underline="false">
	mincut(G,s,t,vf):vf;  
end proc:</Font></Text-field></Input></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input">#The Maximum Flow - Minimum Cut Maplet</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle7" prompt="&gt; " style="_cstyle4">maplet := Maplet( Window( 'title'="Max Cut-Min Flow" ,BoxColumn('vscroll'='always',
                   BoxColumn(["Enter the graph with capacities ",                 
                   TextField['TF1']( 	
			value="graph({a,2,3,z,4,5,6},{[a,2],[a,5],[a,4],[4,2],[2,3],
				[4,5],[5,6],[6,3],[4,z],[3,z],[6,z]},
				weights=[3,5,2,1,2,2,3,2,3,4,3])",
			('width' = 70)) 
                ],  
		BoxRow(["Enter the source vertex: ",TextField['TF2'](value='a')],
			["Enter the sink vertex: ",TextField['TF3'](value='z')]),
                TextBox['TB1'](),TextBox['TB2']()),              
                BoxRow( Plotter['PL1']('height'=300,'width'=300),
                Plotter['PL2']('height'=300,'width'=300)),
                                                                                                         
		[
                                                                      
                Button("Draw", Evaluate('PL1' = 'draw(TF1)') ),                                                                         Button("Clear",  
			Action(SetOption('TF1' = ""),
				SetOption('TF2'=""),SetOption('TF3'=""),SetOption('TB1'=""),
				SetOption('TB2'=""),Evaluate( 'PL1' = "" ),Evaluate('PL2'=""))),                                                                                                                                                		Button("Flow",Evaluate( 'TB1'="Flow",Argument('TF1'),Argument('TF2'),Argument('TF3'))),                                 
		Button("Satedges", Evaluate('TB2'="SaturatedEdges",Argument('TF1'),Argument('TF2'),Argument('TF3'))),                                                                       									Button("Satverts",Evaluate('TB2'="SaturatedVertices",
			Argument('TF1'),Argument('TF2'),Argument('TF3'))), 
                                                                                  
		Button("Min Cut",Evaluate( 'TB1'="MinCut",Argument('TF1'),Argument('TF2'),Argument('TF3'))),                            
		Button("Val Min Cut",Evaluate('TB2'="MinCutValue",Argument('TF1'),
			Argument('TF2'),Argument('TF3'))),                                                                              
		Button("Display Min Cut ", 
			Evaluate( 'PL2'="Mincutplot",Argument('TF1'),Argument('TF2'),Argument('TF3'))),
  
                 
                Button("Help", RunDialog('MD1')),
                Button("Close", Shutdown(['TF1']))
   ]
  )),
     MessageDialog['MD1']( "For example, enter graph({1,2,3,4},{{1,2},{3,4},{2,3},{2,4}},weights=[1,2,3,4]), or else, enter petersen(), cube(3), etc.", 'type'='information' )                                    ):
      
Maplets[Display](maplet);</Text-field></Input><Output><Text-field layout="Maple Output" style="2D Output"><Equation>NiM3I1Ffc2dyYXBoKHxmcmEsMiwzLHosNCw1LDZ8aHIsfGZyW2EsMl0sW2EsNV0sW2EsNF0sWzQsMl0sWzIsM10sfn5+fn5bNCw1XSxbNSw2XSxbNiwzXSxbNCx6XSxbMyx6XSxbNix6XXxocix+fn5+fndlaWdodHM9WzMsNSwyLDEsMiwyLDMsMiwzLDQsM10pNiI=</Equation></Text-field></Output></Group><Group><Input><Text-field layout="Normal" prompt="&gt; " style="Maple Input"/></Input></Group><Group><Input><Text-field layout="Normal" style="Text">This is a very simple maplet that is designed to introduce the Max Flow Min Cut Theorem.   The reader is encouraged to add basic error routines and to modify the Maplet to accomodate applications of the Theorem.  The reader should note that the graphs are assumed to not be multigraphs and to not have multiple sources or sinks.  The capacities were also assumed to be integers.  The reader should further note that Maple tends to number the edges in the order they are entered.  The notation and format were adapted from the Maplet Tutorial available with Maple 9.5 [1].  My thanks to Goodaire and Parmenter [2] for writing a text with a number of examples that helped me test the Maplet.</Text-field></Input></Group></Section><Section><Title><Text-field layout="_pstyle12" style="_pstyle12">[1] Examples, Maplet Tutorial , Maple 9.5,  Maplesoft, A Division of Waterloo Maple Inc. 2004.</Text-field></Title><Text-field layout="_pstyle12" style="_pstyle12">[2] Goodaire, E. and Parmenter, M., <Font italic="true">Discrete Mathematics with Graph Theory</Font>, second edition, Prentice Hall, Upper Saddle River, NJ, 2002, pp. 448-454.</Text-field></Section><Group><Input><Text-field layout="_pstyle13" style="_pstyle13"><Font style="_cstyle5">Disclaimer:</Font> While every effort has been made to validate the solutions in this worksheet, Waterloo Maple Inc. and the contributors are not responsible for any errors contained and are not liable for any damages resulting from the use of this material.</Text-field></Input></Group><Text-field layout="Normal" style="Normal"/><Text-field layout="Normal" style="Normal"/><Text-field/><Text-field/><Text-field/><Text-field/><Text-field/><Text-field/><Text-field/><Text-field/><Text-field/><Text-field/><Text-field/><Text-field/><Text-field/><Text-field/><Text-field/><Text-field/></Worksheet>