-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestCreateTranspose.c
More file actions
56 lines (44 loc) · 1.21 KB
/
TestCreateTranspose.c
File metadata and controls
56 lines (44 loc) · 1.21 KB
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
//
// Algoritmos e Estruturas de Dados --- 2024/2025
//
// Joaquim Madeira, Joao Manuel Rodrigues - Dec 2024
//
// Graph EXAMPLE : Creating and displaying graphs
//
#include <assert.h>
#include "Graph.h"
int main(void) {
// What kind of graph is dig01?
Graph* dig01 = GraphCreate(6, 1, 0);
GraphAddEdge(dig01, 1, 2);
GraphAddEdge(dig01, 1, 4);
GraphAddEdge(dig01, 3, 4);
printf("The graph:\n");
// Displaying in DOT format
GraphDisplayDOT(dig01);
GraphCheckInvariants(dig01);
// Create the transpose of dig01
Graph* dig02 = GraphCreateTranspose(dig01);
printf("The transpose graph:\n");
// Displaying in DOT format
GraphDisplayDOT(dig02);
GraphCheckInvariants(dig02);
// Reading a directed graph from file
FILE* file = fopen("DG_2.txt", "r");
Graph* dig03 = GraphFromFile(file);
fclose(file);
// Displaying in DOT format
GraphDisplayDOT(dig03);
GraphCheckInvariants(dig03);
// Create the transpose of dig03
Graph* dig04 = GraphCreateTranspose(dig03);
printf("The transpose graph:\n");
// Displaying in DOT format
GraphDisplayDOT(dig04);
GraphCheckInvariants(dig04);
GraphDestroy(&dig01);
GraphDestroy(&dig02);
GraphDestroy(&dig03);
GraphDestroy(&dig04);
return 0;
}