-
Notifications
You must be signed in to change notification settings - Fork 0
/
Prac4_MinimumCutEdges.cpp
92 lines (71 loc) · 1.97 KB
/
Prac4_MinimumCutEdges.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Implement the Code for finding Minimum
// cut edges and cut vertices for a graph
#include "UndirectedGraphMatrix.h"
#include <iostream>
int main(){
using namespace std;
UndirectedGraphMatrix graphA("Euler", 8);
// adding some edges in graph A
// 1 5
// / \ / \
// 0 2----4 6
// \ / \ /
// 3 7
graphA.addEdge(0,1);
graphA.addEdge(1,2);
graphA.addEdge(2,3);
graphA.addEdge(0,3);
graphA.addEdge(4,5);
graphA.addEdge(5,6);
graphA.addEdge(6,7);
graphA.addEdge(7,4);
graphA.addEdge(2,4);
graphA.displayGraph();
graphA.minimumCutSet();
UndirectedGraphMatrix graphB("Kirchoff", 8);
// adding some edges in graph A
// 0 - 1 --- 4 - 5
// | x | | x |
// 2 - 3 --- 6 - 7
graphB.addEdge(0,1);
graphB.addEdge(2,3);
graphB.addEdge(0,3);
graphB.addEdge(1,2);
graphB.addEdge(0,2);
graphB.addEdge(1,3);
graphB.addEdge(4,5);
graphB.addEdge(5,6);
graphB.addEdge(6,7);
graphB.addEdge(7,4);
graphB.addEdge(4,6);
graphB.addEdge(5,7);
graphB.addEdge(1,4);
graphB.addEdge(3,6);
graphB.displayGraph();
graphB.minimumCutVertex();
UndirectedGraphMatrix graphC("Tesla", 10);
// adding some edges in graph A
// 0 - 1 --- 4----5----6---7
// | x | | | / |
// 2 - 3 ---' | 8---9
// '--------'
graphC.addEdge(0,1);
graphC.addEdge(2,3);
graphC.addEdge(0,3);
graphC.addEdge(1,2);
graphC.addEdge(0,2);
graphC.addEdge(1,4);
graphC.addEdge(4,3);
graphC.addEdge(4,5);
graphC.addEdge(5,6);
graphC.addEdge(6,7);
graphC.addEdge(6,8);
graphC.addEdge(7,9);
graphC.addEdge(7,8);
graphC.addEdge(5,9);
graphC.addEdge(8,9);
graphC.displayGraph();
graphC.minimumCutVertex();
graphC.minimumCutSet();
return 0;
}