Skip to content

Instantly share code, notes, and snippets.

@happyduck-git
Created June 5, 2022 10:57
Show Gist options
  • Save happyduck-git/66e0bc600b80f26c47a72591aee3dc6c to your computer and use it in GitHub Desktop.
Save happyduck-git/66e0bc600b80f26c47a72591aee3dc6c to your computer and use it in GitHub Desktop.
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