-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file illustrates the sample usage of GraphBuilder.java
- Loading branch information
1 parent
36308c5
commit 7cf55d7
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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(); | ||
} | ||
} |