-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathquestion35.c
69 lines (57 loc) · 1.19 KB
/
question35.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
http://practice.geeksforgeeks.org/problems/euler-circuit-and-path/1
*/
#include <stdio.h>
#include <stdlib.h>
#define MAX 100
struct adjListNode{
int data;
struct adjListNode *next;
};
struct adjList{
struct adjListNode *head;
};
struct graph{
int vertices;
struct adjList *arr;
};
struct adjListNode *newNode(int data){
struct adjListNode *temp = (struct adjListNode *)malloc(sizeof(struct adjListNode));
temp->data = data;
temp->next = NULL;
return temp;
}
void createEdge(int start, int end, struct graph *newGraph){
struct adjListNode *temp = newNode(end);
if(newGraph->arr[start].head){
temp->next = newGraph->arr[start].head;
newGraph->arr[start].head = temp;
}else{
newGraph->arr[start].head = temp;
}
}
void dfs(int index, struct graph *newGraph, int *visited){
visited[index] = 1;
struct adjListNode *temp = newGraph->arr[index].head;
while(temp){
if(visited[temp->data] == 0){
dfs(temp->data, newGraph, visited);
}
temp = temp->next;
}
}
void init(int *visited, int vertices){
int i;
for(i=0;i<vertices;i++){
visited[i] = 0;
}
}
int main(){
int cases;
int i;
for(i=0;i<cases;i++){
int vertices,edges;
scanf("%d %d", vertices, edges);
}
return 0;
}