public void bfs(UndirectedNode root) {
        Queue<UndirectedNode> queue = new LinkedList<UndirectedNode>();
        queue.add(root);
        root.visited = true;
        while (!queue.isEmpty()) {
            UndirectedNode curNode = queue.poll();
            System.out.println(curNode.data + " ");
            for (UndirectedNode n : curNode.edgeNodes) {
                if (!n.visited) {
                    n.visited = true;
                    queue.add(n);
                }
            }
        }

    }