-
Notifications
You must be signed in to change notification settings - Fork 1
/
Lab1.java
27 lines (24 loc) 路 839 Bytes
/
Lab1.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
import java.util.Scanner;
/*
Find number of even and odd vertices
*/
public class Lab1 {
private static final Scanner SCANNER = new Scanner(System.in);
public static void main(String[] args) {
int vertices = SCANNER.nextInt();
int[][] matrix = getMatrix(vertices);
UnDirectedGraph graph = UnDirectedGraph.fromMatrix(matrix);
System.out.println(graph);
System.out.println(graph.evenVertices());
System.out.println(graph.oddVertices());
}
private static int[][] getMatrix(int vertices) {
int[][] matrix = new int[vertices][vertices];
for (int row = 0 ; row < vertices ; row++) {
for (int column = 0 ; column < vertices ; column++) {
matrix[row][column] = SCANNER.nextInt();
}
}
return matrix;
}
}