package printed before hand”); System.out.println(ver.size()-1); f.format((ver.size()-1)+”%n”); /**
package minimum_spanning_tree;import java.io.BufferedReader;import java.io.FileReader;import java.util.*; /** * * @author Ashish * PRIMs MST */ class Node { int val; int key; Node parent; public Node(int val) { this.val = val; this.key = Integer.MAX_VALUE; this.parent = null; } } /** * MinHeap class to construct the PRIM MST */ class MinHeap { int capacity; Node arr; int pos; int size; public MinHeap(int capacity) { this.capacity = capacity; this.size = capacity; this.arr = new Nodecapacity; this.pos = new intsize; } void swap(Node arr, int i, int j) { Node temp = arri; arri = arrj; arrj = temp; int tempIndex = posarri.val; posarri.val = posarrj.val; posarrj.val = tempIndex; } int parent(int i) { return (i-1)/2; } int left(int i) { return 2*i + 1; } int right(int i) { return 2*i + 2; } Node extractMin() { if(size <= 0) { System.out.println("Heap underflow"); return null; } if(size == 1) { size--; return arr0; } Node root = arr0; arr0 = arrsize-1; // change indices posarrsize-1.val = 0; posroot.val = size-1; size--; minHeapify(0); return root; } void minHeapify(int i) { int l = left(i); int r = right(i); int smallest = i; if(l < size && arrl.key < arrsmallest.key) smallest = l; if(r < size && arrr.key < arrsmallest.key) smallest = r; if(smallest != i) { swap(arr,i,smallest); minHeapify(smallest); } } void fixUpwards(int i) { while(i != 0 && arri.key < arrparent(i).key) { swap(arr,i,parent(i)); i = parent(i); } } void decreaseKey(Node v, int newKey) { int index = posv.val; if(arrindex.key < newKey) { System.out.println("New key is greater."); return; } arrindex.key = newKey; fixUpwards(index); } boolean isInMinHeap(Node node) { if(posnode.val < size) return true; return false; } } class MyLinkedList extends LinkedList