-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFordFulkerson.java
82 lines (66 loc) · 1.59 KB
/
FordFulkerson.java
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
https://powcoder.com
代写代考加微信 powcoder
Assignment Project Exam Help
Add WeChat powcoder
import java.io.*;
import java.util.*;
public class FordFulkerson {
public static ArrayList<Integer> pathDFS(Integer source, Integer destination, WGraph graph){
ArrayList<Integer> Stack = new ArrayList<Integer>();
/* YOUR CODE GOES HERE
//
//
//
//
//
//
//
*/
return Stack;
}
public static void fordfulkerson(Integer source, Integer destination, WGraph graph, String filePath){
String answer="";
String myMcGillID = "26000000"; //Please initialize this variable with your McGill ID
int maxFlow = 0;
/* YOUR CODE GOES HERE
//
//
//
//
//
//
//
*/
answer += maxFlow + "\n" + graph.toString();
writeAnswer(filePath+myMcGillID+".txt",answer);
System.out.println(answer);
}
public static void writeAnswer(String path, String line){
BufferedReader br = null;
File file = new File(path);
// if file doesnt exists, then create it
try {
if (!file.exists()) {
file.createNewFile();
}
FileWriter fw = new FileWriter(file.getAbsoluteFile(),true);
BufferedWriter bw = new BufferedWriter(fw);
bw.write(line+"\n");
bw.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (br != null)br.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
public static void main(String[] args){
String file = args[0];
File f = new File(file);
WGraph g = new WGraph(file);
fordfulkerson(g.getSource(),g.getDestination(),g,f.getAbsolutePath().replace(".txt",""));
}
}