Created
June 5, 2022 10:57
-
-
Save happyduck-git/66e0bc600b80f26c47a72591aee3dc6c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public class Node { | |
int data; | |
public Node(int data) { | |
this.data = data; | |
} | |
} | |
public class Graph { | |
int size; | |
ArrayList<Node> vertices; | |
int[][] matrix; | |
//Constructor | |
public Graph(int size) { | |
this.size = size; | |
vertices = new ArrayList<>(); | |
matrix = new matrix[size][size]; | |
} | |
//vertex 추가하기! | |
public void addVertex(Node node) { | |
vertices.add(node); | |
} | |
//edges 추가하기! | |
public void addEdges(int from, int to) { | |
matrix[from][to] = 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment