public LinkedList<GraphEdge> primAlgorithm() {
		int[] tmpSolution = new int[graph.size() + 1];
		LinkedList<GraphEdge> solution = new LinkedList<>();
		int visitedNodes = 0;
		Heap heap = new Heap(graph.size());

		// initialize heap nodes and solution array
		for(int i = 1; i <= graph.size(); i++) {
			heap.add(i, Integer.MAX_VALUE);
			tmpSolution[i] = 0;
		}
		heap.decreasePriority(1, 0); // set root node priority from +inf to 0

		while(visitedNodes != graph.size()) {
			GraphNode node = graph.getNode(heap.extractMin());
			node.visit();
			visitedNodes++;
			if(node.outDeg() != 0) { // if this node has adjacents
				for(GraphEdge cursor : node.getAdjacentNodes()) { // for the adjacents to the node
					GraphNode adjacentNode = cursor.getToNode();
					if(!adjacentNode.wasVisited()) {
						HeapNode tempNode = heap.getNode(adjacentNode.id()); // heap node with the adjacent
						if(cursor.weight() < tempNode.priority()) {
							heap.decreasePriority(adjacentNode.id(), cursor.weight());
							tmpSolution[adjacentNode.id()] = node.id();
						}
					}
				}
			}
		}
		graph.resetNodes();
		for(int i = 2; i < tmpSolution.length; i++)
			solution.addLast(graph.getEdge(i, tmpSolution[i]));
		return solution;
	}