Code Monkey home page Code Monkey logo

graph_algorithm's Introduction

Graph_Algorithm

Graph_Algorithm is a library for Four main graph algorithms : Graph Search, Topological Sort , Shortest Path , Spanning Tree.

Graphs are excellent tools for modelling complex relationship. Generally we focus on :

  1. Visit all the nodes present within it in order to process them [BFS and DFS]
  2. Establishing precedence relationship between various nodes in a graph [Topological Sort]
  3. Finding shortest or lower cost path from one point to other [Dijkstra's Algorithm]
  4. Covering all nodes in a graph with minimum cost [Minimum Spanning Tree]

You should totally check out the Demo for implementation details.

Usage

If you want to use the algorithms in your code it is as simple as:

from Graph_Algorithm import Adjacency_Matrix,Breadth_First,Depth_First
import numpy as np

g=Adjacency_Matrix(9,directed=True)
g.add_edge(0,1)
g.add_edge(1,2)
g.add_edge(2,7)
g.add_edge(2,4)
g.add_edge(2,3)
g.add_edge(1,5)
g.add_edge(5,6)
g.add_edge(6,3)
g.add_edge(3,4)
g.add_edge(6,8)

for i in range(9):
	print("Adjacent to :",i,g.get_adjacent_vertices(i))
				
g.display()

Breadth_First.search(g,1) # For BFS
visited = np.zeros(g.numVertices)
Depth_First.search(g,visited,1) # For DFS

Contributing:

Some codes and idea taken from various internet sources. Contributions are always welcome.

graph_algorithm's People

Contributors

abhianan avatar ananabh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.