Skip to content

Dannikk/dfs_bfs_animation_-using-networkx-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dfs, bfs animation using networkx

This is my student project, the task of which is to learn how to visualize algorithms on graphs. In this work, I have animated the work of DFS and BFS. To work with graphs, I used the networkx package and the matplotlib and celluloid packages to create a .gif file.

Documentation

Documentation hosted on free documentation hosting Read the docs

Install dependencies

It's require to install third-party dependencies. For this write in the python console.

pip install -r requirements

Example of using the program

First of all it is necessary to fill the text file with adjacency lists.

NB: The file should contain only lines of the form: node1: node2, node3...

For example the content of the file located in "../input/graph.txt" the demo and default for the main function.

A: B, C
B: D, E
C: F, G
D: H
E: I, J

Then it is enough to call the main function with the required argument start - node from which the search will start. Optionally, it is possible to specify a text file with a graph, the algorithm to be animated and the directory in which you want to save the file.

The default arguments are "../input/graph.txt", depth-first search, "../output/".

For example:

from src.main import main
main(start='A', algorithm='bfs')

Or by running in the console:

python main.py A -algo bfs

NB: To open help for running a script with valid arguments, you must type in console:

python main.py -h

Result:

help


Result:

BFS_gif

And for:

from src.main import main
main(start='A', algorithm='dfs')

Or by running in the console:

python main.py A -algo dfs

DFS_gif

Contacts:

About

dfs_bfs_animation_(using networkx)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages