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
| import java.util.HashSet; | |
| import java.util.LinkedList; | |
| class Vertex{ | |
| private String name; | |
| private LinkedList<Edge> edgeList; | |
| public Vertex(String name){ | |
| this.name = name; | |
| edgeList = new LinkedList<>(); |
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
| //new class to store level of each node along with the node | |
| static class QueueNode{ | |
| Node node; | |
| int level; | |
| public QueueNode(Node node, int level){ | |
| this.node = node; | |
| this.level = level; | |
| } | |
| } |
NewerOlder