Time limit: 5000ms Memory limit: 256mb -------------------------Copy the following code, complete it and submit--------------------- /* I, <Your Full Name>, am submitting the assignment for an individual project. I declare that the assignment here submitted is original except for source material explicitly acknowledged, the piece of work, or a part of the piece of work has not been submitted for more than one purpose (i.e. to satisfy the requirements in two different courses) without declaration. I also acknowledge that I am aware of University policy and regulations on honesty in academic work, and of the disciplinary guidelines and procedures applicable to breaches of such policy and regulations, as contained in the University website http://www.cuhk.edu.hk/policy/academichonesty/. It is also understood that assignments without a properly signed declaration by the student concerned will not be graded by the teacher(s). */ #include <stdio.h> #include <stdlib.h> #include <string.h> typedef enum {ADD = 1, DELETE, QUERY, ERROR_OP} OP; // this linked list has no head or tail, which means that if this list is empty, then it equals NULL struct linkedListNode { int id; struct linkedListNode* next; }; typedef struct linkedListNode* ListNode; ListNode CreateNode(int id) { ListNode node = (ListNode) malloc(sizeof(struct linkedListNode)); node->id = id; node->next = NULL; return node; } // Stack ADT struct stack { int capacity; int* arr; int size; }; typedef struct stack* StackADT; StackADT CreateStack(int capacity) { StackADT s = (StackADT) malloc(sizeof(struct stack)); s->arr = (int*) malloc(capacity * sizeof(int)); s->capacity = capacity; s->size = 0; return s; } int IsEmpty(StackADT s) { return s->size == 0; } void Push(StackADT s, int value) { if (s->size < s->capacity) { s->arr[s->size++] = value; } } void Pop(StackADT s) { if (!IsEmpty(s)) { s->size--; } } int Top(StackADT s) { return s->arr[s->size-1]; } // graph // We use array to maintain nodes instead of the hashTables. // For example, G[i] is exactly the adjacency list of the node i struct graph { int n; ListNode* G; }; typedef struct graph* GraphADT; GraphADT CreateGraph(int n) { GraphADT myGraph = (GraphADT) malloc(sizeof(struct graph)); myGraph->n = n; myGraph->G = (ListNode*) malloc(n * sizeof(ListNode)); memset(myGraph->G, 0, n * sizeof(ListNode)); return myGraph; } // In our test case, each edge is only added once void AddEdge(GraphADT myGraph, int u, int v) { // write your code here } void DeleteEdge(GraphADT myGraph, int u, int v) { // write your code here } // check whether there is path from u to v. If there is a path, return 1. Otherwise, return 0. // please use DFS int Query(GraphADT myGraph, int u, int v) { StackADT myStack = CreateStack(myGraph->n); int* color = (int*) malloc(myGraph->n * sizeof(int)); memset(color, 0, myGraph->n * sizeof(int)); // write your code here } OP get_op() { char str[20]; scanf("%s", str); if (strcmp(str, "add") == 0) { return ADD; } else if (strcmp(str, "delete") == 0) { return DELETE; } else if (strcmp(str, "query") == 0) { return QUERY; } else { return ERROR_OP; } } int main() { int n, u, v; scanf("%d", &n); GraphADT myGraph = CreateGraph(n); scanf("%d", &n); for(int i=0; i<n; i++) { switch (get_op()) { case ADD: scanf(" %d%d", &u, &v); AddEdge(myGraph, u, v); break; case DELETE: scanf(" %d%d", &u, &v); DeleteEdge(myGraph, u, v); break; case QUERY: scanf(" %d%d", &u, &v); if (Query(myGraph, u, v)) { printf("true\n"); } else { printf("false\n"); } break; default: printf("Error Input\n"); } } } -----------------------------------------End of Code----------------------------------------- Description: Implement the graph ADT, which is a directed unweighted graph. This graph ADT supports limited operations as it assumes that the number of nodes is already known. The graph ADT in this problem only supports three operations: 1. AddEdge(u, v): add an edge to the graph 2. DeleteEdge(u, v): delete an edge from the graph 3. Query(u, v): check whether there is path from u to v. If there is a path, return 1. Otherwise, return 0. Input: The first line contains one integer: N, which is the number of nodes in the graph. The next line contains one integer: N, which is the number of operations. The next N lines, each of which contains one of these operations: 1. add u v (two Integers) or 2. delete u v (two Integers) 3. query u v (two Integers) Output: Each line is the result of query. Sample Input 1: 6 10 add 1 0 add 0 2 query 1 2 query 2 1 add 3 4 add 5 4 add 4 2 query 5 2 delete 4 2 query 3 2 Sample Output 1: true false true false