int main(){ //-----------------------------------------Loading and Printing the Graph------------------------------ graph *G; FILE* f; f = fopen("cost.txt", "r"); G = loadGraph(f); printf("\n Edges and Costs: \n"); for(int i = 0; i < G->noOfEdges; i++){ printf("[%d <-> %d] --- cost = %d \n", G->pEdge[i].source , G->pEdge[i].destination, G->pEdge[i].weight); } //------------------------------------------------END--------------------------------------------------- //-----------------------------------------------PRIM--------------------------------------------------- int V[50][50], Q[50], H[50], n = 0, r = 0, k=0; //----| Data for Prim's Alg // ce reprezinta??? k = prim(V, Q, H, n, r, G); printf("\n Prim: \n"); displayMST(H, n); printf("\n MST cost = %d \n", k); //-----------------------------------------------END------------------------------------------------------ //---------------------------------------------Kruskall--------------------------------------------------- int p, m, L[20]; //----| Data for Kruskall's Alg krusk(n, m, L, G); //-----------------------------------------------END----------------------------------------------------- system("pause"); }
int main() { InitGraphics(); SetWindowTitle("CS106 Pathfinder"); cout << "This masterful piece of work is a graph extravaganza!" << endl << "The main attractions include a lovely visual presentation of the graph" << endl << "along with an implementation of Dijkstra's shortest path algorithm and" << endl << "the computation of a minimal spanning tree. Enjoy!" << endl; Graph graph; Map<coordT> nodeCor; string loc1, loc2, image; image = loadGraphFile(graph, nodeCor); drawMap(graph, nodeCor); while (true) { int choice = promptForChoice(); switch (choice) { case 1: graph.clear(); nodeCor.clear(); image = loadGraphFile(graph, nodeCor); drawMap(graph, nodeCor); break; case 2: cout << endl; loc1 = getLocName("Click on starting location... ", nodeCor); loc2 = getLocName("Click on ending location... ", nodeCor); displayMinPath(graph, nodeCor, loc1, loc2); break; case 3: InitGraphics(); DrawNamedPicture(image); drawVertices(nodeCor); displayMST(graph, nodeCor); break; case 4: displayDomSet(graph, nodeCor); break; case 5: exit(0); } } return (0); }