Skip to content

ShalevAsor/Ex3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is directed weighted graph?

simple graph made up of vetices and edges.
the difference btween simple unweighted graph to weighted graph
is that each edge on a weight graph has weight wich is a positive number.
the difference between directed graph to simple undirected graph is that
each edge in direceted graph has a direction.
edge between node 1 and node 2 is NOT equals to edge between node 2 to node 1.
you can find much more information about directed graph here

The benefits of using GraphAlgo:

  • Low Complexity
  • Support more than one mil verteices and ten mil edges
  • each public class has tests
  • support algorithms like Dijkstra's and Bfs
  • each un-trivail metohd attached with explanations
  • support ploting the graph and create randomly positions
  • quick access to nodes/edges To see the comparison with other graphs click here

How it works?

add node into the graph : add_node(, )
connect two nodes with a weight: add_edge(,, )
remove node from the graph: remove_node()
Note: this method will remove all the edges that this node was associate with
remove edge from the graph: remove_edge(,)
dictunary of all the nodes in the graph : get_all_v()
dictunary of all the node that connected to the node_id : all_in_edges_of_node(<node_id>)
dictunary of all the node that connected from the node_id : all_out_edges_of_node(<node_id>)
For more information, i recommend diving into the code, there is explanations attached to each method.

GraphAlgo

This class supports few algorithms like dfs tarjan and dijkstra's
it allows to save the graph into a json format and load a graph from json format
the dfs and tarjan algo used to find out if this graph is strongly connected and the connected commponents
methods:

  • connected_components: return all the strongly connected commponents in the graph
    what is strongly connected graph ?
    it means there is a path from each node in the graph to every other node
    for example:
    this graph is Not strongly connected

this graph is strongly connected

for more information about strongly connected graph : click here

dijkstra's algorithm used in the methods shortest_path

  • Shortest path: return the shortest path between two nodes in the graph and the length of the path.
    the shortest path will be the path with the minimalist edges weight
    for example :
    shortest
    the shortest path from node 1 to 2 is : 1---> 3--->2

  • plot_garph: plot the graph - if the vertices has no positions the will be places in randomly (elegant)
    example:

About

Directed weighted graph in python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages