New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

graphsp

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphsp

Graphsp Package for Graph Data Structure

  • 1.0.0
  • PyPI
  • Socket score

Maintainers
1

Graphsp

Project description

This project implements algorithms associated with Graph Data Structure.

The following is the list of algorithm this library implements:

  • Breadth First Search
  • Depth First Search
  • Dijkstra (Single Source Shortest Path)
  • Floyd Warshall (All Pairs Shortest Path)

Installation

pip install graphsp

Usage

from graphsp import Graph

Initializing graph object

graph = graphsp.Graph(n, graph_type)
  • n = Total number of nodes
  • graph_type = directed / undirected [in string]

Initializing & Populating the graph

graph = graphsp.Graph(5, "undirected")

graph.bulk_link([(0, 4, 5), (0, 1, 1), (1, 4, 3),
                 (1, 3, 1), (1, 2, 15), (2, 3, 2), (3, 4, 3)])

print(graph.detect_cycle())

Using different algorithms

dfs = DFS(n, graph)
print(dfs.dfs(start_node))

bfs = BFS(n, graph)
print(bfs.bfs(start_node))

dj = Dijkstra(n, graph)
print(dj.dijkstra(start_node))

bf = BellmanFord(n, graph)
print(bf.bellman_ford(start_node))

fw = FloydWarshall(n, graph)
print(fw.floyd_warshall())

ts = TopoSorting(n, graph)
print(ts.topo_sorting())

pr = Prim(n, graph)
print(pr.prim())

ks = Kruskal(n, graph)
print(ks.kruskal())

kr = Kosaraju(n, graph)
print(kr.kosaraju())
  • n = Total number of nodes
  • start_node = Number on the desired starting node
  • graph = Object of Graph class

Github repository

https://github.com/jainam2385/graphsp

License

© 2022 Jainam Shah
This repository is licensed under the MIT license. See LICENSE for details.

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc