Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d226bd8

Browse filesBrowse files
committed
small tweaks
1 parent e3957d7 commit d226bd8
Copy full SHA for d226bd8

File tree

8 files changed

+15
-7
lines changed
Filter options

8 files changed

+15
-7
lines changed

‎lib/ADTlib.a

Copy file name to clipboard
-63.5 KB
Binary file not shown.

‎modules/Graph/UndirectedGraph/README.md

Copy file name to clipboardExpand all lines: modules/Graph/UndirectedGraph/README.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
This is an implementations of [undirected graph](https://en.wikipedia.org/wiki/Graph_(discrete_mathematics)#Undirected_graph) using adjecency list. An undirected graph is graph, i.e., a set of objects (called vertices or nodes) that are connected together, where all the edges are bidirectional. An undirected graph is sometimes called an undirected network.
1+
This is an implementations of [undirected graph](https://en.wikipedia.org/wiki/Graph_(discrete_mathematics)#Undirected_graph) using adjecency list. An undirected graph is graph, i.e., a set of objects (called vertices or nodes) that are connected together, where all the edges are bidirectional. This means that if {v,w} is an edge, we can travel both from v to w and from w to v. An undirected graph is sometimes called an undirected network.
22

33
# Performance
44
<img align="right" width=310 alt="undirected graph picture" src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/bc/Undirected_graph_no_background.svg/1200px-Undirected_graph_no_background.svg.png">

‎modules/Graph/WeightedUndirectedGraph/README.md

Copy file name to clipboardExpand all lines: modules/Graph/WeightedUndirectedGraph/README.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
This is an implementations of [weighted undirected graph](https://www.codewars.com/kata/5aaea7a25084d71006000082) using adjecency list. A weighted undirected graph is an undirected graph with the exception that each edge has a "weight" associated with it.
1+
This is an implementations of [weighted undirected graph](https://www.codewars.com/kata/5aaea7a25084d71006000082) using adjecency list. A weighted undirected graph is the same as a undirected graph except that each edge has a weight or cost associated with it.
22

33
# Performance
44
<img align="right" width=360 alt="weighted undirected graph picture" src="https://study.com/cimages/multimages/16/weighted_graph4176817323068517144.png">

‎modules/Graph/WeightedUndirectedGraph/WeightedUndirectedGraph.c

Copy file name to clipboardExpand all lines: modules/Graph/WeightedUndirectedGraph/WeightedUndirectedGraph.c
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void wug_minspantree(wu_graph G)
126126
static void print_min_span_tree(wu_graph G, int* E, int n)
127127
{
128128
cost total_weight = 0;
129-
for (int i = 1; i < n; i++)
129+
for (int i = 1; i < n; i++)
130130
{
131131
// vertex is not included in the minimum spanning tree
132132
if (E[i] == INT_MIN)
@@ -147,7 +147,7 @@ static void print_min_span_tree(wu_graph G, int* E, int n)
147147
ed = ed->nextedge;
148148
}
149149
}
150-
printf("Total weight = %d\n", total_weight);
150+
printf("Total weight = %d\n", total_weight);
151151
}
152152

153153
void wug_print(wu_graph G)
@@ -212,7 +212,7 @@ static void pq_init(PQueue* PQ, unsigned int size)
212212
assert((*PQ)->arr != NULL); // allocation failure
213213

214214
(*PQ)->pos = calloc(size, sizeof(int));
215-
assert((*PQ)->pos != NULL); // allocation failure
215+
assert((*PQ)->pos != NULL); // allocation failure
216216

217217
(*PQ)->capacity = size;
218218
(*PQ)->curr_size = size;
@@ -253,7 +253,7 @@ static n pq_remove(PQueue PQ)
253253

254254
// swap positions
255255
PQ->pos[root.v] = PQ->curr_size-1;
256-
PQ->pos[PQ->arr[PQ->curr_size-1].v] = ROOT;
256+
PQ->pos[PQ->arr[PQ->curr_size-1].v] = ROOT;
257257

258258
PQ->arr[ROOT] = PQ->arr[PQ->curr_size-1];
259259

‎tests/makefile

Copy file name to clipboardExpand all lines: tests/makefile
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ADT to be tested (Stack/ Queue/ PriorityQueue/ RedBlackTree/ HashTable/ DirectedGraph/ UndirectedGraph/ WeightedUndirectedGraph)
2-
ADT_TO_BE_TESTED = WeightedUndirectedGraph
2+
ADT_TO_BE_TESTED = HashTable
33

44
# compiler
55
CC = gcc

‎tests/test_DirectedGraph.c

Copy file name to clipboardExpand all lines: tests/test_DirectedGraph.c
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ void visit(Vertex x);
77

88
int main(void)
99
{
10+
// create graph
1011
dir_graph A;
1112
dg_init(&A, 6, visit);
13+
14+
// the directed graph:
15+
// https://cgi.di.uoa.gr/~k08/manolis/2021-2022/lectures/Graphs.pdf , page 139
1216
dg_insert(A, 1, 4);
1317
dg_insert(A, 1, 2);
1418
dg_insert(A, 2, 3);

‎tests/test_UndirectedGraph.c

Copy file name to clipboardExpand all lines: tests/test_UndirectedGraph.c
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ void visit(Vertex x);
77

88
int main(void)
99
{
10+
// create graph
1011
undir_graph A;
1112
ug_init(&A, 5, visit);
1213

14+
// random graph
1315
ug_insert(A, 4, 0);
1416
ug_insert(A, 2, 1);
1517
ug_insert(A, 3, 2);
@@ -18,6 +20,7 @@ int main(void)
1820
// print graph
1921
ug_print(A); printf("\n");
2022

23+
// perfrom simple path check between vertices (3-1)
2124
ug_simplepathcheck(A, 3, 1);
2225

2326
// free graph

‎tests/test_WeightedUndirectedGraph.c

Copy file name to clipboardExpand all lines: tests/test_WeightedUndirectedGraph.c
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
int main(void)
66
{
7+
// create graph
78
wu_graph A;
89
wug_init(&A, 7);
910

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.