public Graph cloneGraph() {
		Graph graphCopy = new Graph();
		
		HashSet<Node> processed = new HashSet<Node>();
		LinkedList<Node> queue = new LinkedList<Node>();
		LinkedList<Node> queueCopy = new LinkedList<Node>();
		Node currNode, currNodeCopy;
		int index;
		
		for (Node n : nodes) {
			if (!processed.contains(n)) {
				queue.add(n);
				queueCopy.add(new Node(n.getName()));
				
				// breadth first search
				while (!queue.isEmpty()) {
					currNode = queue.remove();
					currNodeCopy = queueCopy.remove();
					
					processed.add(currNode);
					graphCopy.addNode(currNodeCopy);
					
					// build new node
					for (Node m : currNode.connectedTo) {
						if (!processed.contains(m)) {
							index = queue.indexOf(m);
							if (index == -1) { // if neighbor is not already in the queue (no cycle)
								queue.add(m);
								Node node = new Node(m.getName());
								queueCopy.add(node);
								currNodeCopy.addEdge(node);
							} else
								currNodeCopy.addEdge(queueCopy.get(index)); // node already created but not finished
						}
					}
				}
			}
		}
		
		return graphCopy;
	}