Add the chapter of Graph (#303)

* Update the chapter graph

* Update the chapter graph

* Update the chapter graph

* Update the chapter graph
This commit is contained in:
Yudong Jin
2023-01-28 23:56:41 +08:00
committed by GitHub
parent 3d197feb30
commit f58068c838
23 changed files with 699 additions and 2 deletions

View File

@ -20,6 +20,33 @@ class Trunk {
};
public class PrintUtil {
/**
* Print a matrix (Array)
* @param <T>
* @param matrix
*/
public static <T> void printMatrix(T[][] matrix) {
System.out.println("[");
for (T[] row : matrix) {
System.out.println(" " + row + ",");
}
System.out.println("]");
}
/**
* Print a matrix (List)
* @param <T>
* @param matrix
*/
public static <T> void printMatrix(List<List<T>> matrix) {
System.out.println("[");
for (List<T> row : matrix) {
System.out.println(" " + row + ",");
}
System.out.println("]");
}
/**
* Print a linked list
* @param head