-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathGraphBuilderUsage.java
More file actions
34 lines (30 loc) · 903 Bytes
/
GraphBuilderUsage.java
File metadata and controls
34 lines (30 loc) · 903 Bytes
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
class GraphBuilderUsage{
//Usage Exmaple
public static void makeGraphUsage(){
int N = 6, E = 8;
int[] from = new int[]{0,0,0,1,1,2,2,4};
int[] to = new int[]{2,4,5,4,5,3,4,5};
int[][] graph = GraphBuilder.makeGraph(N, E, from, to, true);
for(int i = 0; i< N; i++){
System.out.print(i+": ");
for(int j:graph[i])System.out.print(j+" ");
System.out.println();
}
}
//Usage Example
public static void makeGraphWithEdgeInfoUsage(){
int N = 6, E = 8;
int[] from = new int[]{0,0,0,1,1,2,2,4};
int[] to = new int[]{2,4,5,4,5,3,4,5};
int[][][] graph = GraphBuilder.makeGraphWithEdgeInfo(N, E, from, to, true);
for(int i = 0; i< N; i++){
System.out.print(i+": ");
for(int[] j:graph[i])System.out.print("["+j[0]+", "+j[1]+", "+j[2]+"],");
System.out.println();
}
}
public static void main(String[] args){
makeGraphUsage();
makeGraphWithEdgeInfoUsage();
}
}