Created
June 5, 2022 11:19
-
-
Save happyduck-git/db88119a292025f709c99b062122c653 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 Graph { | |
ArrayList<LinkedList<Node>> verticesAndEdges; | |
public Graph() { | |
verticesAndEdges = new ArrayList<LinkedList<Node>>(); | |
} | |
public void addVertedx(Node vertex) { | |
LinkedList<Node> list = new LinkedList<>(); | |
list.add(vertex); | |
verticesAndEdges.add(list); | |
} | |
public void addEdges(int from, int to) { | |
LinkedList<Node> currentList = verticesAndEdges.get(from); | |
Node dstNode = verticesAndEdges.get(to).get(0); | |
currentList.add(dstNode); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment