Close
Close window
MinCut - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.
Maplesoft logo
Maplesoft logo

Online Help

All Products Maple MapleSim


[フレーム] [フレーム]

GraphTheory

MinCut

find a minimal cut that separates two vertices

Calling Sequence

MinCut(G, s, t)

Parameters

G

-

graph

s, t

-

vertices of the graph

Options

flows = Matrix

The flow matrix from computing the MaxFlow from s to t, this allows MinCut to skip calling MaxFlow, and to just calculate the cut using the pre-computed flows.

output = name or list

The values to be returned from the calculation. Valid values are size, cutset, partition, or a list of any combination of those. The default is cutset.

Description

The MinCut command finds a minimal cut of G that separates s and t, that is, a removal of edges so that t is no longer reachable from s. The cut is minimal in the sense that the sum of the weights of the edges removed is as low as possible.

In the case that t is not reachable from s in G, no work is done and the cut-set is considered to be .

Otherwise, the minimal cut is computed using MaxFlow per the Max-Flow Min-Cut Theorem which says that the total weight of the minimal cut is the same as the value of the maximal flow between two vertices.

If G is not a weighted graph then every edge is treated as having a weight of 1, and thus the minimal cut is minimal in the sense of the number of edges cut.

For undirected graphs, the cut always disconnects the graph, but for directed graphs, IsConnected may still return true. However, even in directed graphs, IsReachable will always show that t can no longer be reached from s after the cut is made.

Note that the size of the minimal cut is unique, but there may be many possible choices of cut-sets that achieve the minimum size.

By default, the output is a cut-set as a set of edges. By using the output option, the size of the cut-set, or the induced partition on the vertices can be returned instead. The induced partition is two sets of vertices, the first is the set of all vertices reachable from s, and the second is the set of vertices from which t is reachable; they are always disjoint.

Examples

>

withGraphTheory:

>

G6Graph1,2,1,6,2,3,2,4,3,4,3,5,4,5,5,6

G6Graph 1: an undirected graph with 6 vertices and 8 edges

(1)
>

cut1MinCutG6,1,6

cut11,6,5,6

(2)
>

IsCutSetG6,cut1

true

(3)
>

HighlightEdgesG6,cut1

>

DrawGraphG6

>

W6GraphA,B,1,A,F,6,B,C,1,C,D,1,D,E,1,E,F,5

W6Graph 2: a directed weighted graph with 6 vertices and 6 arcs

(4)
>

cut2,part2MinCutW6,A,F,output=cutset,partition

cut2,part2A,F,D,E,A,B,C,D,E,F

(5)
>

W6pDeleteArcW6,cut2,inplace=false

W6pGraph 3: a directed weighted graph with 6 vertices and 4 arcs

(6)
>

IsReachableW6p,A,F

false

(7)
>

HighlightEdgesW6,cut2

>

DrawGraphW6,layout=circle

MinCut can also be used on a precomputed flow

>

NGraph1,2,2,1,4,8,2,3,2,2,5,6,3,2,2,3,6,2,4,3,6,4,5,2,5,4,2,5,6,8

NGraph 4: a directed weighted graph with 6 vertices and 10 arcs

(8)
>

DrawGraphN,layout=network

>

c,MMaxFlowN,1,6

c,M8,020600000040020002004020000006000000

(9)
>

s,part,cut3MinCutN,1,6,flows=M,output=:-size,partition,cutset

s,part,cut38,1,3,4,2,5,6,1,2,3,2,3,6,4,5

(10)
>

c=s

8=8

(11)
>

DeleteArcN,cut3

Graph 4: a directed weighted graph with 6 vertices and 6 arcs

(12)
>

IsReachableN,1,6

false

(13)
>

StyleSubgraphN,part1,vertexstylesheet=color=Goldenrod,edgestylesheet=color=Goldenrod

>

StyleSubgraphN,part2,vertexstylesheet=color=Blue,edgestylesheet=color=Blue

Notice that after removing the cut-set, the graph is still connected as an undirected graph.

>

DrawGraphN,layout=tree

Compatibility

The GraphTheory[MinCut] command was introduced in Maple 2024.

For more information on Maple 2024 changes, see Updates in Maple 2024 .

See Also


Download Help Document

AltStyle によって変換されたページ (->オリジナル) /