8000 GitHub - gp2112/Graph: A graph implementation in Python for Graph's class
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

gp2112/Graph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

A graph implementation in Python for Graph's class

How to use?

Getting a graph from a pajek file

import graph

file_name = input()

g = graph.pajek_read(file_name)

Depth-First Search

g.bfs(source) # do DFS from vertex Source

g.bfs(source, dest=dest) # do DFS from vertex Source and, 
                          # when it passes throught vertex dest, it returns True and stop the search

Breadth-First Search

g.bfs(source) # Do BFS from vertex Source

g.bfs(source, dest=dest) # Do BFS from vertex Source and, as DFS, 
                         # returns True and stop the search when hits vertex dest

Dijkstra (minimum weighted paths)

dists = g.dijkstra(source) # return all minimum distances betwheen source vertex when all others

Prim (minimum spanning tree)

min_tree, weight_sum = g.prim(source) # return a new graph that represents the minimum spanning tree from g graph
                                      # and returns it's weight sum
                                      

About

A graph implementation in Python for Graph's class

Resources

License

Stars

Watchers

Forks

Languages

0