Graphlib Module Of Python Standard Library

Overview:

  • With the module graphlib Python has started introducing graph capabilities into the standard library.

  • The graphlib module has a class TopologicalSorter which sorts the nodes of a graph in topological order.

Graph Terminology:

  • Mathematically a graph contains two sets. A node set and an edge set. Node set consists of nodes and the edge set consists of edges connecting two nodes. 
  • The edge set is a two element subset of the node set. If the edges of a graph has a direction the graph is a directed graph or digraph.
  • If the digraph does not have any cycles it is called directed acyclic graph. Nodes of such graph with no cycles can be sorted. Sorting means one node is ordered before another.

 


Copyright 2023 © pythontic.com