Esempio n. 1
0
int main(){

//	BellmanFord BF(readFile("10000Test.txt"));
//	cout << "Done Reading\n";
//	while (1){
//		int start, end;
//		cin >> start >> end;
//		cout << BF.getShortestPathYen(start, end) << " ";
//		cout << BF.getShortestPath(start, end) << endl;
//	}

	FibonacciHeap<int> Fib;
	while (1){
		printf("1-Insert\n2-removeMin\n");
		int choice;
		cin >> choice;
		switch (choice){
		case 1:
			int y;
			cin >> y;
			Fib.insert(y);
			break;
		case 2:
			Fib.extractMin();
			break;
		default:
			break;
		}
		cout << "Minimum Element: " << Fib.getMin() << "\tSize : " << Fib.size() << endl;
	}
	while (1);
}
Esempio n. 2
0
int main() {
    FibonacciHeap<int> mQ = FibonacciHeap<int>();
    int arr[RUN];
    for (int i = 0; i < RUN; i++) {
        arr[i] = i;
    }
    for (int i = 0; i < RUN; i++) {
        mQ.insertNode(arr + i, arr[i]);
    }
#ifdef DEBUG
    cout<<"Printing Heap"<<endl;
    mQ.printHeap();
#endif
    for (int i = 0; i < RUN; i++) {
        assert(*(mQ.extractMin()) == i);
    }
#ifdef DEBUG
    cout<<"Printing Heap"<<endl;
    mQ.printHeap();
#endif
    for (int i = 0; i < RUN/2; i++) {
        mQ.insertNode(arr + i, arr[i]);
    }
#ifdef DEBUG
    cout<<"Printing Heap"<<endl;
    mQ.printHeap();
#endif

#ifdef DEBUG
    cout<<"Decreasing Key 50 to 5"<<endl;
#endif
    mQ.decreaseKey(arr +4, -1);
#ifdef DEBUG
    mQ.printHeap();
#endif
    assert(*mQ.extractMin() == 4);
    return 0;
}
Esempio n. 3
0
int main()
{
    file.open("fibonacciHeap.txt");
    FibonacciHeap<int> heap;

    for(int i = 0; i < 1000; i++)
        heap.insert(i);

    cout<<"minimo "<<heap.getMinimumKey()<<endl;
    heap.extractMin();
    cout<<"minimo "<<heap.getMinimumKey()<<endl;

    heap.decreaseKey(999,-2);
    cout<<"minimo "<<heap.getMinimumKey()<<endl;

    printHeap(heap);
    file.close();
    return 0;
}