Skip to content

Commit

Permalink
Created GraphBuilderUsage.java
Browse files Browse the repository at this point in the history
This file illustrates the sample usage of GraphBuilder.java
  • Loading branch information
taran-1407 authored Oct 1, 2020
1 parent 36308c5 commit 7cf55d7
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions GraphBuilder/GraphBuilderUsage.java
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();
}
}

0 comments on commit 7cf55d7

Please sign in to comment.