You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+38-10Lines changed: 38 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,8 @@
3
3
### Description ###
4
4
5
5
The package aims to create visual outputs for popular graph algorithms.
6
-
Currently: BFSand DFS
7
-
I plan to implement more algorithms: Prim's and Kruskal's Algorithms etc
6
+
Currently: BFS, DFS, Topological Sort, Prim's MST and Kruskal's MST
7
+
I plan to implement more algorithms: A* Search etc
8
8
9
9
It is not just limited to getting a visual output, but the algorithms will be optimised by using heuristics for non-polynomial time algorithms. This project aims to create a better understanding of the working of graph algorithms, improve the computation time and optimising the algorithms. It could be used by analysts as well as students and teachers, as a teaching aid.
10
10
@@ -14,16 +14,17 @@ To run the package: pip install graph-algo-vis
14
14
15
15
### BFS and DFS ###
16
16
Import:
17
-
from graph_algo_vis import dfs_traversal
17
+
from graph_algo_vis import dfs_traversal, bfs_traversal
18
18
19
19
Instantiation:
20
-
g = dfs_traversal.DFS()
20
+
d = dfs_traversal.DFS()
21
+
b = bfs_traversal.BFS()
21
22
22
23
Visualize the input graph:
23
-
g.draw_graph("input.txt")
24
+
d.draw_graph("input.txt")
24
25
25
26
Visualize the result of DFS:
26
-
g.depth_first_search("input.txt")
27
+
d.depth_first_search("input.txt")
27
28
28
29
### Topological Sort ###
29
30
Import:
@@ -33,7 +34,19 @@ Instantiation:
33
34
g = topological_sort.Top_Sort()
34
35
35
36
Visualize the input graph and result:
36
-
g.topological_sort("input.txt")
37
+
g.topological_sort("input.txt")
38
+
39
+
### Prim's and Kruskal's MST ###
40
+
Import:
41
+
from graph_algo_vis import primsMST, kruskalsMST
42
+
43
+
Instantiation:
44
+
p = primsMST.Prims()
45
+
k = kruskalsMST.Krusals()
46
+
47
+
Visualize the input graph and result:
48
+
p.prims("input.txt")
49
+
k.kruskals("input.txt")
37
50
38
51
### Pre requisites ###
39
52
@@ -44,7 +57,7 @@ To run this package run you must have matplotlib and networkx libraries installe
44
57
Input is taken from the file
45
58
#### input.txt ####
46
59
47
-
Sample input for BFSand DFS
60
+
Sample input for BFS, DFS, Prim's MST and Kruskal's MST
48
61
```
49
62
4
50
63
0 5 10 5
@@ -102,12 +115,27 @@ Directed Acyclic Graph (DAG) is a linear ordering of vertices such that for ever
Prim's and Kruskal's algorithms are greedy algorithms that find a minimum spanning tree for
123
+
a weighted, connected, undirected graph.
124
+
125
+
Minimum Spanning Tree (MST) : A spanning tree with a weight less than or equal to the weight of every other spanning tree. The weight of a spanning tree is the sum of weights given to each edge of the spanning tree.
126
+
127
+
The edges coloured in Red represent the edges included in the MST
0 commit comments