0% found this document useful (0 votes)
13 views

Assignment 9

Uploaded by

binayparamanik3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Assignment 9

Uploaded by

binayparamanik3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

Topic: Logis cs Tree applica on

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>

#define MAX_WAREHOUSES 100


#define INF INT_MAX

typedef struct InventoryItem {


char name[50];
int quan ty;
float unit_cost;
struct InventoryItem *next;
} InventoryItem;

typedef struct Warehouse {


char name[50];
char loca on[100];
int capacity;
struct InventoryItem *inventory;
struct Warehouse *next;
} Warehouse;

typedef struct Region {


char name[50];
struct Region *child;
struct Region *sibling;
Warehouse *warehouses;

} Region;

typedef struct Graph {


int ver ces[MAX_WAREHOUSES][MAX_WAREHOUSES];
int num_ver ces;
} Graph;

// Func on to ini alize a graph


void ini alize_graph(Graph *g, int num_ver ces) {
g->num_ver ces = num_ver ces;
for (int i = 0; i < num_ver ces; i++) {
for (int j = 0; j < num_ver ces; j++) {
g->ver ces[i][j] = (i == j) ? 0 : INF;
}
}
}

// Func on to add an edge to the graph


void add_edge(Graph *g, int from, int to, int weight) {
g->ver ces[from][to] = weight;
}

int min_distance(int dist[], int visited[], int num_ver ces) {


int min = INF, min_index;
for (int v = 0; v < num_ver ces; v++) {
if (!visited[v] && dist[v] <= min) {
min = dist[v];
min_index = v;
}

}
return min_index;
}

// Func on to find the shortest path using Dijkstra's algorithm


void dijkstra(Graph *g, int start_node, int end_node) {
int dist[MAX_WAREHOUSES], visited[MAX_WAREHOUSES], parent[MAX_WAREHOUSES];

for (int i = 0; i < g->num_ver ces; i++) {


dist[i] = INF;
visited[i] = 0;
parent[i] = -1;
}

dist[start_node] = 0;

for (int count = 0; count < g->num_ver ces - 1; count++) {


int u = min_distance(dist, visited, g->num_ver ces);
visited[u] = 1;

for (int v = 0; v < g->num_ver ces; v++) {


if (!visited[v] && g->ver ces[u][v] && dist[u] != INF && dist[u] + g->ver ces[u][v] <
dist[v]) {
dist[v] = dist[u] + g->ver ces[u][v];
parent[v] = u;
}
}
}
// Print the shortest path

int current = end_node;


prin ("Shortest Path: ");
while (current != -1) {
prin ("%d ", current);
current = parent[current];
}
prin ("\nDistance: %d\n", dist[end_node]);
}

// Func ons to create regions and warehouses


Region* createRegion(char *name) {
Region *newRegion = (Region *)malloc(sizeof(Region));
strcpy(newRegion->name, name);
newRegion->child = NULL;
newRegion->sibling = NULL;
newRegion->warehouses = NULL;
return newRegion;
}

void addChildRegion(Region *parent, char *name) {


Region *child = createRegion(name);
child->sibling = parent->child;
parent->child = child;
}

Warehouse* createWarehouse(char *name, char *loca on, int capacity) {


Warehouse *newWarehouse = (Warehouse *)malloc(sizeof(Warehouse));
strcpy(newWarehouse->name, name);
strcpy(newWarehouse->loca on, loca on);

newWarehouse->capacity = capacity;
newWarehouse->inventory = NULL;
newWarehouse->next = NULL;
return newWarehouse;
}

void addWarehouse(Region *region, char *name, char *loca on, int capacity) {
Warehouse *warehouse = createWarehouse(name, loca on, capacity);
warehouse->next = region->warehouses;
region->warehouses = warehouse;
}

void printWarehouses(Region *region) {


Warehouse *current = region->warehouses;
while (current != NULL) {
prin ("Name: %s, Loca on: %s, Capacity: %d\n", current->name, current->loca on,
current->capacity);
current = current->next;
}
}

Warehouse* findWarehouse(Region *region, char *name) {


Warehouse *current = region->warehouses;
while (current != NULL) {
if (strcmp(current->name, name) == 0) {
return current;
}
current = current->next;
}
return NULL;

void updateWarehouse(Warehouse *warehouse, char *newName, char *newLoca on, int


newCapacity) {
strcpy(warehouse->name, newName);
strcpy(warehouse->loca on, newLoca on);
warehouse->capacity = newCapacity;
}

void deleteWarehouse(Region *region, char *name) {


Warehouse *current = region->warehouses;

Warehouse *prev = NULL;

while (current != NULL && strcmp(current->name, name) != 0) {


prev = current;
current = current->next;
}

if (current == NULL) {
prin ("Warehouse not found.\n");
return;

if (prev == NULL) {
region->warehouses = current->next;
} else {
prev->next = current->next;
}
free(current);

// Inventory Management Func ons


InventoryItem* createInventoryItem(char *name, int quan ty, float unit_cost) {
InventoryItem *newItem = (InventoryItem *)malloc(sizeof(InventoryItem));
strcpy(newItem->name, name);
newItem->quan ty = quan ty;
newItem->unit_cost = unit_cost;
newItem->next = NULL;
return newItem;
}

void addInventoryItem(Warehouse *warehouse, char *name, int quan ty, float unit_cost) {
InventoryItem *item = createInventoryItem(name, quan ty, unit_cost);
item->next = warehouse->inventory;
warehouse->inventory = item;
}

void printInventory(Warehouse *warehouse) {


InventoryItem *current = warehouse->inventory;
while (current != NULL) {
prin ("Item: %s, Quan ty: %d\n", current->name, current->quan ty);
current = current->next;
}
}

InventoryItem* findInventoryItem(Warehouse *warehouse, char *name) {


InventoryItem *current = warehouse->inventory;
while (current != NULL) {

if (strcmp(current->name, name) == 0) {
return current;
}
current = current->next;
}
return NULL;
}

void updateInventoryItem(InventoryItem *item, int newQuan ty, float unit_cost) {


item->quan ty = newQuan ty;
}

void deleteInventoryItem(Warehouse *warehouse, char *name) {


InventoryItem *current = warehouse->inventory;
InventoryItem *prev = NULL;

while (current != NULL && strcmp(current->name, name) != 0) {


prev = current;
current = current->next;
}

if (current == NULL) {
prin ("Inventory item not found.\n");
return;
}

if (prev == NULL) {
warehouse->inventory = current->next;
} else {

prev->next = current->next;
}

free(current);
}

// Func on to calculate the total cost of inventory items in a warehouse


float calculateTotalCost(Warehouse *warehouse) {
float totalCost = 0.0;
InventoryItem *current = warehouse->inventory;
while (current != NULL) {
totalCost += current->quan ty * current->unit_cost;
current = current->next;
}
return totalCost;
}

// Func on to report analy cs for a warehouse


void reportAnaly cs(Warehouse *warehouse) {
int totalItems = 0;
int totalQuan ty = 0;
float totalCost = calculateTotalCost(warehouse);
InventoryItem *current = warehouse->inventory;
while (current != NULL) {
totalItems++;
totalQuan ty += current->quan ty;
current = current->next;
}
float averageCost = (totalItems > 0) ? totalCost / totalQuan ty : 0.0;

prin ("\nWarehouse Analy cs:\n");


prin ("Total Items: %d\n", totalItems);
prin ("Total Quan ty: %d\n", totalQuan ty);
prin ("Total Cost: %.2f\n", totalCost);
prin ("Average Cost per Item: %.2f\n", averageCost);
}

void userInterface() {
Region *region = createRegion("Main Region");
int choice;
char warehouseName[50];
char loca on[100];
int capacity;
char itemName[50];
int quan ty;
float unit_cost;
int from, to, weight, start_node, end_node;
Warehouse *warehouse;
InventoryItem *item;
Graph g;
ini alize_graph(&g, MAX_WAREHOUSES);

do {
prin ("\nWarehouse Management System\n");
prin ("1. Add Warehouse\n");
prin ("2. Delete Warehouse\n");
prin ("3. Add Inventory Item\n");
prin ("4. Update Inventory Item\n");

prin ("5. Delete Inventory Item\n");


prin ("6. Print Warehouses\n");
prin ("7. Print Inventory\n");
prin ("8. Calculate Total Cost\n");
prin ("9. Report Analy cs\n");
prin ("10. Add Route\n");
prin ("11. Find Shortest Route\n");
prin ("12. Exit\n");
prin ("Enter your choice: ");
scanf("%d", &choice);

switch (choice) {
case 1:
prin ("Enter warehouse name: ");
scanf("%s", warehouseName);
prin ("Enter loca on: ");
scanf("%s", loca on);
prin ("Enter capacity: ");
scanf("%d", &capacity);
addWarehouse(region, warehouseName, loca on, capacity);
prin ("Warehouse added.\n");
break;
case 2:
prin ("Enter warehouse name to delete: ");
scanf("%s", warehouseName);
deleteWarehouse(region, warehouseName);
prin ("Warehouse deleted.\n");
break;
case 3:

prin ("Enter warehouse name: ");


scanf("%s", warehouseName);
warehouse = findWarehouse(region, warehouseName);
if (warehouse != NULL) {
prin ("Enter item name: ");
scanf("%s", itemName);
prin ("Enter quan ty: ");
scanf("%d", &quan ty);
prin ("Enter unit cost: ");
scanf("%f", &unit_cost);
addInventoryItem(warehouse, itemName, quan ty, unit_cost);
prin ("Inventory item added.\n");
} else {
prin ("Warehouse not found.\n");
}
break;
case 4:
prin ("Enter warehouse name: ");
scanf("%s", warehouseName);
warehouse = findWarehouse(region, warehouseName);
if (warehouse != NULL) {
prin ("Enter item name to update: ");
scanf("%s", itemName);
item = findInventoryItem(warehouse, itemName);
if (item != NULL) {
prin ("Enter new quan ty: ");
scanf("%d", &quan ty);
prin ("Enter new unit cost: ");
scanf("%f", &unit_cost);

updateInventoryItem(item, quan ty, unit_cost);


prin ("Inventory item updated.\n");
} else {
prin ("Inventory item not found.\n");
}
} else {
prin ("Warehouse not found.\n");
}
break;
case 5:
prin ("Enter warehouse name: ");
scanf("%s", warehouseName);
warehouse = findWarehouse(region, warehouseName);
if (warehouse != NULL) {
prin ("Enter item name to delete: ");
scanf("%s", itemName);
deleteInventoryItem(warehouse, itemName);
prin ("Inventory item deleted.\n");
} else {
prin ("Warehouse not found.\n");
}
break;
case 6:
printWarehouses(region);
break;
case 7:
prin ("Enter warehouse name: ");
scanf("%s", warehouseName);
warehouse = findWarehouse(region, warehouseName);

if (warehouse != NULL) {
printInventory(warehouse);
} else {
prin ("Warehouse not found.\n");
}
break;
case 8:
prin ("Enter warehouse name: ");
scanf("%s", warehouseName);
warehouse = findWarehouse(region, warehouseName);
if (warehouse != NULL) {
float totalCost = calculateTotalCost(warehouse);
prin ("Total Cost of Inventory: %.2f\n", totalCost);
} else {
prin ("Warehouse not found.\n");
}
break;
case 9:
prin ("Enter warehouse name: ");
scanf("%s", warehouseName);
warehouse = findWarehouse(region, warehouseName);
if (warehouse != NULL) {
reportAnaly cs(warehouse);
} else {
prin ("Warehouse not found.\n");
}
break;
case 10:
prin ("Enter from warehouse index: ");

scanf("%d", &from);
prin ("Enter to warehouse index: ");
scanf("%d", &to);
prin ("Enter route weight: ");
scanf("%d", &weight);
add_edge(&g, from, to, weight);
prin ("Route added.\n");
break;
case 11:
prin ("Enter start warehouse index: ");
scanf("%d", &start_node);
prin ("Enter end warehouse index: ");
scanf("%d", &end_node);
dijkstra(&g, start_node, end_node);
break;
case 12:
prin ("Exi ng the system.\n");
break;
default:
prin ("Invalid choice. Please try again.\n");
break;
}
} while (choice != 12);
}

int main() {
userInterface();
return 0;
}

Output:
Topic:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>

#define INF INT_MAX


#define MAX_STATIONS 100
#define MAX_NAME_LEN 100

typedef struct Node {


int sta on;
int travelTime;
struct Node* next;
} Node;

typedef struct {
int id;
char name[MAX_NAME_LEN];
char loca on[MAX_NAME_LEN];
int pla ormCount;
} Sta on;

typedef struct Graph {

int numSta ons;


Sta on* sta ons[MAX_STATIONS]; // Array of pointers to Sta on
Node* adjList[MAX_STATIONS];
} Graph;

typedef struct {
int travelTime;
int transfers;
int cketPrice;
} CostFactors;

Graph* createGraph(int numSta ons) {


Graph* graph = (Graph*)malloc(sizeof(Graph));
graph->numSta ons = numSta ons;

for (int i = 0; i < numSta ons; i++) {


graph->adjList[i] = NULL;
}

return graph;
}

Node* createNode(int sta on, int travelTime) {


Node* newNode = (Node*)malloc(sizeof(Node));
newNode->sta on = sta on;
newNode->travelTime = travelTime;
newNode->next = NULL;

return newNode;
}

void addEdge(Graph* graph, int src, int dest, int travelTime) {


Node* newNode = createNode(dest, travelTime);
newNode->next = graph->adjList[src];

graph->adjList[src] = newNode;

newNode = createNode(src, travelTime);


newNode->next = graph->adjList[dest];
graph->adjList[dest] = newNode;
}

void addSta on(Graph* graph, int id, const char* name, const char* loca on, int
pla ormCount) {
if (graph->numSta ons >= MAX_STATIONS) {
prin ("Maximum number of sta ons reached.\n");

return;
}

Sta on* newSta on = (Sta on*)malloc(sizeof(Sta on));


if (newSta on == NULL) {
prin ("Memory alloca on failed.\n");
return;
}

newSta on->id = id;

strncpy(newSta on->name, name, MAX_NAME_LEN);


strncpy(newSta on->loca on, loca on, MAX_NAME_LEN);
newSta on->pla ormCount = pla ormCount;

graph->sta ons[graph->numSta ons] = newSta on;


graph->numSta ons++;
prin ("Sta on added: %s\n", name);
}

void removeSta on(Graph* graph, int id) {


int index = -1;
for (int i = 0; i < graph->numSta ons; i++) {
if (graph->sta ons[i]->id == id) {
index = i;
break;
}
}

if (index == -1) {
prin ("Sta on not found.\n");
return;
}

free(graph->sta ons[index]);
for (int i = index; i < graph->numSta ons - 1; i++) {
graph->sta ons[i] = graph->sta ons[i + 1];
}

graph->numSta ons--;
prin ("Sta on removed.\n");
}

void updateSta on(Graph* graph, int id, const char* name, const char* loca on, int
pla ormCount) {
for (int i = 0; i < graph->numSta ons; i++) {
if (graph->sta ons[i]->id == id) {
strncpy(graph->sta ons[i]->name, name, MAX_NAME_LEN);
strncpy(graph->sta ons[i]->loca on, loca on, MAX_NAME_LEN);

graph->sta ons[i]->pla ormCount = pla ormCount;


prin ("Sta on updated: %s\n", name);
return;
}
}

prin ("Sta on not found.\n");


}

int minDistance(int dist[], int sptSet[], int numSta ons) {


int min = INF, minIndex;

for (int v = 0; v < numSta ons; v++) {


if (sptSet[v] == 0 && dist[v] <= min) {
min = dist[v];
minIndex = v;
}
}
return minIndex;
}

void dijkstra(Graph* graph, int src, int dest) {


int dist[MAX_STATIONS];
int sptSet[MAX_STATIONS];
int parent[MAX_STATIONS];

for (int i = 0; i < graph->numSta ons; i++) {


dist[i] = INF;
sptSet[i] = 0;

parent[i] = -1;
}

dist[src] = 0;

for (int count = 0; count < graph->numSta ons - 1; count++) {


int u = minDistance(dist, sptSet, graph->numSta ons);
sptSet[u] = 1;

for (Node* pCrawl = graph->adjList[u]; pCrawl != NULL; pCrawl = pCrawl->next) {


int v = pCrawl->sta on;
if (!sptSet[v] && dist[u] != INF && dist[u] + pCrawl->travelTime < dist[v]) {
dist[v] = dist[u] + pCrawl->travelTime;
parent[v] = u;
}
}
}

// Print the result or store it


if (dist[dest] == INF) {
prin ("No path found from %d to %d.\n", src, dest);
} else {
prin ("Shortest path from %d to %d is %d\n", src, dest, dist[dest]);
prin ("Path: %d", dest);
int crawl = dest;
while (parent[crawl] != -1) {
prin (" <- %d", parent[crawl]);
crawl = parent[crawl];
}

prin ("\n");
}
}

void removeEdge(Graph* graph, int src, int dest) {


Node** curr = &(graph->adjList[src]);
while (*curr != NULL) {
if ((*curr)->sta on == dest) {
Node* temp = *curr;
*curr = (*curr)->next;
free(temp);
break;
}
curr = &((*curr)->next);
}

curr = &(graph->adjList[dest]);
while (*curr != NULL) {
if ((*curr)->sta on == src) {
Node* temp = *curr;
*curr = (*curr)->next;
free(temp);
break;
}
curr = &((*curr)->next);
}
}
void displayRoute(int parent[], int dest) {

// Check if there's no route to the des na on


if (parent[dest] == -1) {
prin ("No route to des na on.\n");
return;
}

// Create a stack to store the path


int stack[MAX_STATIONS];
int top = -1;

// Traverse from des na on to source and store the path in the stack
int crawl = dest;
while (parent[crawl] != -1) {
stack[++top] = crawl;
crawl = parent[crawl];
}
stack[++top] = crawl;

// Print the route


prin ("Route: ");
while (top >= 0) {
prin ("%d", stack[top--]);
if (top >= 0) {
prin (" -> ");
}
}
prin ("\n");
}

void dijkstraWithDisrup on(Graph* graph, int src, int dest) {


int dist[MAX_STATIONS];
int sptSet[MAX_STATIONS];
int parent[MAX_STATIONS];

for (int i = 0; i < graph->numSta ons; i++) {


dist[i] = INF;
sptSet[i] = 0;
parent[i] = -1;
}

dist[src] = 0;

for (int count = 0; count < graph->numSta ons - 1; count++) {


int u = minDistance(dist, sptSet, graph->numSta ons);
sptSet[u] = 1;

for (Node* pCrawl = graph->adjList[u]; pCrawl != NULL; pCrawl = pCrawl->next) {


int v = pCrawl->sta on;
if (!sptSet[v] && dist[u] != INF && dist[u] + pCrawl->travelTime < dist[v]) {
dist[v] = dist[u] + pCrawl->travelTime;
parent[v] = u;
}
}
}

if (dist[dest] == INF) {
prin ("No path found from %d to %d.\n", src, dest);
} else {

prin ("Shortest path length: %d\n", dist[dest]);


displayRoute(parent, dest);
}
}

void handleDisrup on(Graph* graph, int disruptedSrc, int disruptedDest, int start, int end,
int travelTime) {
// Remove the edge represen ng the disrup on
removeEdge(graph, disruptedSrc, disruptedDest);

// Find alterna ve routes using the modified graph

prin ("Finding alterna ve routes from %d to %d a er disrup on between %d and


%d...\n", start, end, disruptedSrc, disruptedDest);
dijkstraWithDisrup on(graph, start, end);

// Restore the disrupted edge if you want to reuse the original graph
addEdge(graph, disruptedSrc, disruptedDest, travelTime);
}

int calculateTransfers(int parent[], int start, int end) {


int transfers = 0;

int current = end;

while (parent[current] != -1) {


transfers++;
current = parent[current];
}
return transfers - 1; // -1 because the first sta on is not a transfer
}

int calculateRouteCost(Graph* graph, int dist[], int parent[], int start, int end, CostFactors
factors) {
int travelTime = dist[end];
if (travelTime == INF) {
prin ("No valid path exists.\n");
return INF;
}

int transfers = calculateTransfers(parent, start, end);


int cketPrice = factors. cketPrice * transfers;

int totalCost = (factors.travelTime * travelTime) + (factors.transfers * transfers) +


cketPrice;
return totalCost;
}

void dijkstraWithCostCalcula on(Graph* graph, int src, int dest, CostFactors factors) {
int dist[MAX_STATIONS];
int sptSet[MAX_STATIONS];
int parent[MAX_STATIONS];

for (int i = 0; i < graph->numSta ons; i++) {


dist[i] = INF;
sptSet[i] = 0;
parent[i] = -1;
}
dist[src] = 0;

for (int count = 0; count < graph->numSta ons - 1; count++) {


int u = minDistance(dist, sptSet, graph->numSta ons);
sptSet[u] = 1;

for (Node* pCrawl = graph->adjList[u]; pCrawl != NULL; pCrawl = pCrawl->next) {


int v = pCrawl->sta on;
if (!sptSet[v] && dist[u] != INF && dist[u] + pCrawl->travelTime < dist[v]) {
dist[v] = dist[u] + pCrawl->travelTime;
parent[v] = u;
}
}
}

int cost = calculateRouteCost(graph, dist, parent, src, dest, factors);


if (cost == INF) {
prin ("No path found from %d to %d due to disrup on.\n", src, dest);
} else {
prin ("Total cost of the shortest path from %d to %d is: %d\n", src, dest, cost);
prin ("Path: %d", dest);
int crawl = dest;
while (parent[crawl] != -1) {
prin (" <- %d", parent[crawl]);
crawl = parent[crawl];
}
prin ("\n");
}
}
void findAlterna veRouteUI(Graph* graph) {

int start, end;


CostFactors factors;

prin ("Enter Start Sta on ID: ");


scanf("%d", &start);
prin ("Enter End Sta on ID: ");
scanf("%d", &end);

// Define cost factors


prin ("Enter cost weight for travel me: ");
scanf("%d", &factors.travelTime);
prin ("Enter cost weight for transfers: ");
scanf("%d", &factors.transfers);
prin ("Enter base cket price: ");
scanf("%d", &factors. cketPrice);

prin ("Finding alterna ve route from %d to %d...\n", start, end);


dijkstraWithCostCalcula on(graph, start, end, factors);
}

void displayMenu() {
prin ("\nTrain Journey Alterna ve Route Applica on\n");
prin ("1. Add Sta on\n");
prin ("2. Add Route\n");
prin ("3. Remove Route (Simulate Disrup on)\n");
prin ("4. Find Alterna ve Route\n");
prin ("5. Exit\n");
prin ("Enter your choice: ");
}

void addSta onUI(Graph* graph) {


int id, pla ormCount;
char name[MAX_NAME_LEN];
char loca on[MAX_NAME_LEN];

prin ("Enter Sta on ID: ");


scanf("%d", &id);
prin ("Enter Sta on Name: ");
scanf("%s", name);
prin ("Enter Sta on Loca on: ");
scanf("%s", loca on);
prin ("Enter Number of Pla orms: ");
scanf("%d", &pla ormCount);

addSta on(graph, id, name, loca on, pla ormCount);


}

void addRouteUI(Graph* graph) {


int src, dest, travelTime;
prin ("Enter Source Sta on ID: ");
scanf("%d", &src);
prin ("Enter Des na on Sta on ID: ");
scanf("%d", &dest);
prin ("Enter Travel Time: ");
scanf("%d", &travelTime);
addEdge(graph, src, dest, travelTime);
}

void removeRouteUI(Graph* graph) {


int src, dest;
prin ("Enter Source Sta on ID of the route to remove: ");
scanf("%d", &src);
prin ("Enter Des na on Sta on ID of the route to remove: ");
scanf("%d", &dest);

removeEdge(graph, src, dest);


}

int main() {
Graph* graph = createGraph(5); // Example with ini al capacity of 5 sta ons
int choice;

while (1) {
displayMenu();
scanf("%d", &choice);

switch (choice) {
case 1:
addSta onUI(graph);
break;
case 2:
addRouteUI(graph);
break;
case 3:
removeRouteUI(graph);
break;

case 4:
findAlterna veRouteUI(graph);
break;
case 5:
// Free allocated memory and exit
for (int i = 0; i < graph->numSta ons; i++) {
Node* pCrawl = graph->adjList[i];
while (pCrawl != NULL) {
Node* temp = pCrawl;
pCrawl = pCrawl->next;
free(temp);
}
}
for (int i = 0; i < graph->numSta ons; i++) {
free(graph->sta ons[i]);
}
free(graph);
return 0;
default:
prin ("Invalid choice. Please try again.\n");
}
}

return 0;
}
Output:

You might also like