{"id":23080623,"url":"https://github.com/chen0040/pyalgs","last_synced_at":"2025-08-15T22:31:09.303Z","repository":{"id":57455667,"uuid":"89236358","full_name":"chen0040/pyalgs","owner":"chen0040","description":"Package pyalgs implements algorithms in Robert Sedgwick's Algorithms using Python","archived":false,"fork":false,"pushed_at":"2020-02-25T14:09:52.000Z","size":118,"stargazers_count":12,"open_issues_count":2,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-19T06:24:39.084Z","etag":null,"topics":["algorithm","data-structures","graph-algorithms","python","string-manipulation","string-search"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chen0040.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-24T12:14:55.000Z","updated_at":"2023-07-15T13:15:25.000Z","dependencies_parsed_at":"2022-09-05T20:00:51.405Z","dependency_job_id":null,"html_url":"https://github.com/chen0040/pyalgs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen0040%2Fpyalgs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen0040%2Fpyalgs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen0040%2Fpyalgs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen0040%2Fpyalgs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chen0040","download_url":"https://codeload.github.com/chen0040/pyalgs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229964387,"owners_count":18152034,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","data-structures","graph-algorithms","python","string-manipulation","string-search"],"created_at":"2024-12-16T13:15:49.997Z","updated_at":"2024-12-16T13:15:52.199Z","avatar_url":"https://github.com/chen0040.png","language":"Python","readme":"pyalgs\n======\n\nPackage pyalgs implements algorithms in the \"Algorithms\" book (http://algs4.cs.princeton.edu/home/) and Robert Sedgwick's Algorithms course using Python (Part I and Part II)\n\n.. image:: https://travis-ci.org/chen0040/pyalgs.svg?branch=master\n    :target: https://travis-ci.org/chen0040/pyalgs\n\n.. image:: https://coveralls.io/repos/github/chen0040/pyalgs/badge.svg?branch=master\n    :target: https://coveralls.io/github/chen0040/pyalgs?branch=master\n\n.. image:: https://readthedocs.org/projects/pyalgs/badge/?version=latest\n    :target: http://pyalgs.readthedocs.org/en/latest/?badge=latest\n\n.. image:: https://scrutinizer-ci.com/g/chen0040/pyalgs/badges/quality-score.png?b=master\n    :target: https://scrutinizer-ci.com/g/chen0040/pyalgs/?branch=master\n\n\nMore details are provided in the `docs`_ for implementation, complexities and further info.\n\nInstall pyalgs\n==============\n\nRun the following command to install pyalgs using pip\n\n.. code-block:: bash\n\n    $ pip install pyalgs\n\nFeatures:\n=========\n\n* Data Structure\n\n  - Stack\n\n    + Linked List\n    + Array\n\n  - Queue\n\n    + Linked List\n    + Array\n\n  - Bag\n  - HashSet\n  - HashMap\n\n    + Separate Chaining\n    + Linear Probing\n\n  - Binary Search Tree\n  - Red Black Tree\n  - Priority Queue\n\n    + MinPQ\n    + MaxPQ\n    + IndexMinPQ\n\n  - Graph\n\n    + Simple graph\n    + Edge weighted graph\n    + Directed graph (digraph)\n    + Directed edge weight graph\n\n  - Search Tries (Symbol table with string-based keys)\n\n    + R-way search tries\n    + Ternary search tries\n\n* Algorithms\n\n  - Sorting\n\n    + Selection Sort\n    + Insertion Sort\n    + Shell Sort\n    + Merge Sort\n    + Quick Sort\n    + 3-Ways Quick Sort\n    + Heap Sort\n\n  - Selection\n\n    + Binary Search\n\n  - Shuffling\n\n    + Knuth\n\n  - Union Find\n\n    + Quick Find\n    + Weighted Quick Union with path compression\n\n* Graph Algorithms\n\n  - Search\n\n    + Depth First Search\n    + Breadth First Search\n\n  - Connectivity\n\n    + Connected Components\n    + Strongly Connected Components\n\n  - Topological Sorting\n\n    + Depth First Reverse Post Order\n\n  - Directed Cycle Detection\n\n  - Minimum Spanning Tree\n\n    + Kruskal\n    + Prim (Lazy)\n    + Prim (Eager)\n\n  - Shortest Path\n\n    + Dijkstra\n    + Topological Sort (for directed acyclic graph, namely dag)\n    + Bellman-Ford (for graph with negative weight as well)\n\n  - MaxFlow MinCut\n\n    + Ford-Fulkerson\n\n* Strings\n\n  - Longest Repeated Substring\n  - String Sorting\n\n    + LSD (Least Significant Digit first radix sorting)\n    + MSD (Most Significant Digit first radix sorting)\n    + 3-Ways String Quick Sort\n\n  - String Search\n\n    + Brute force\n    + Rabin Karp\n    + Boyer Moore\n    + Knuth Morris Pratt\n\nUsage:\n======\n\nData Structure\n--------------\n\nStack\n\n\n.. code-block:: python\n\n    from pyalgs.data_structures.commons.stack import Stack\n\n    stack = Stack.create()\n    stack.push(10)\n    stack.push(1)\n\n    print [i for i in stack.iterate()]\n\n    print stack.is_empty()\n    print stack.size()\n\n    popped_item = stack.pop()\n    print popped_item\n\n\n\nQueue\n\n\n.. code-block:: python\n\n    from pyalgs.data_structures.commons.queue import Queue\n\n    queue = Queue.create()\n    queue.enqueue(10)\n    queue.enqueue(20)\n    queue.enqueue(30)\n\n    print [i for i in queue.iterate()]\n\n    print queue.size()\n    print queue.is_empty()\n\n    deleted_item = queue.dequeue())\n    print deleted_item\n\n\n\nBag\n\n\n.. code-block:: python\n\n    from pyalgs.data_structures.commons.bag import Bag\n\n    bag = Bag.create()\n\n    bag.add(10)\n    bag.add(20)\n    bag.add(30)\n\n    print [i for i in bag.iterate()]\n\n    print bag.size()\n    print bag.is_empty()\n\n\nMinimum Priority Queue\n\n.. code-block:: python\n\n    from pyalgs.data_structures.commons.priority_queue import MinPQ\n\n    pq = MinPQ.create()\n    pq.enqueue(10)\n    pq.enqueue(5)\n    pq.enqueue(12)\n    pq.enqueue(14)\n    pq.enqueue(2)\n\n    print pq.is_empty()\n    print pq.size()\n\n    print [i for i in pq.iterate()]\n\n    deleted = pq.del_min()\n    print(deleted)\n\n\nMaximum Priority Queue\n\n\n.. code-block:: python\n\n    from pyalgs.data_structures.commons.priority_queue import MaxPQ\n\n    pq = MaxPQ.create()\n    pq.enqueue(10)\n    pq.enqueue(5)\n    pq.enqueue(12)\n    pq.enqueue(14)\n    pq.enqueue(2)\n\n    print pq.is_empty()\n    print pq.size()\n\n    print [i for i in pq.iterate()]\n\n    deleted = pq.del_max()\n    print deleted\n\n\nSymbol Table using Binary Search Tree\n\n\n.. code-block:: python\n\n    from pyalgs.data_structures.commons.binary_search_tree import BinarySearchTree\n    bst = BinarySearchTree.create()\n\n    bst.put(\"one\", 1)\n    bst.put(\"two\", 2)\n    bst.put(\"three\", 3)\n    bst.put(\"six\", 6)\n    bst.put(\"ten\", 10)\n\n    for key in bst.keys():\n        print(key)\n\n    print bst.get(\"one\"))\n    print bst.contains_key(\"two\")\n\n    print bst.size()\n    print bst.is_empty()\n\n    bst.delete(\"one\")\n\n\nSymbol Table using Left Leaning Red Black Tree\n\n\n.. code-block:: python\n\n    from pyalgs.data_structures.commons.binary_search_tree import BinarySearchTree\n    bst = BinarySearchTree.create_red_black_tree()\n\n    bst.put(\"one\", 1)\n    bst.put(\"two\", 2)\n    bst.put(\"three\", 3)\n    bst.put(\"six\", 6)\n    bst.put(\"ten\", 10)\n\n    print bst.get(\"one\"))\n    print bst.contains_key(\"two\")\n\n    for key in bst.keys():\n        print(key)\n\n    print bst.size()\n    print bst.is_empty()\n\n    bst.delete(\"one\")\n\n\nSymbol Table using Hashed Map\n\n\n.. code-block:: python\n\n    from pyalgs.data_structures.commons.hashed_map import HashedMap\n    map = HashedMap.create()\n\n    map.put(\"one\", 1)\n    map.put(\"two\", 2)\n    map.put(\"three\", 3)\n    map.put(\"six\", 6)\n    map.put(\"ten\", 10)\n\n    print map.get(\"one\"))\n    print map.contains_key(\"two\")\n\n    for key in map.keys():\n        print(key)\n\n    print map.size()\n    print map.is_empty()\n\n    map.delete(\"one\")\n\n\nSymbol Table using Hashed Set\n\n\n.. code-block:: python\n\n    from pyalgs.data_structures.commons.hashed_set import HashedSet\n    set = HashedSet.create()\n\n    set.add(\"one\")\n    set.add(\"two\")\n    set.add(\"three\")\n    set.add(\"six\")\n    set.add(\"ten\")\n\n    print set.contains(\"two\")\n\n    for key in set.iterate():\n        print(key)\n\n    print set.size()\n    print set.is_empty()\n\n    set.delete(\"one\")\n\n\nUndirected Graph\n\n\n.. code-block:: python\n\n    from pyalgs.data_structures.graphs.graph import Graph\n    def create_graph():\n        G = Graph(100)\n\n        G.add_edge(1, 2)\n        G.add_edge(1, 3)\n\n        print([i for i in G.adj(1)])\n        print([i for i in G.adj(2)])\n        print([i for i in G.adj(3)])\n\n        print(G.vertex_count())\n        return G\n\n\nDirected Graph\n\n\n.. code-block:: python\n\n    from pyalgs.data_structures.graphs.graph import Digraph\n    def create_digraph():\n        G = Digraph(100)\n\n        G.add_edge(1, 2)\n        G.add_edge(1, 3)\n\n        print([i for i in G.adj(1)])\n        print([i for i in G.adj(2)])\n        print([i for i in G.adj(3)])\n\n        print(G.vertex_count())\n        return G\n\n\nEdge Weighted Graph\n\n.. code-block:: python\n\n    from pyalgs.data_structures.graphs.graph import EdgeWeightGraph, Edge\n    def create_edge_weighted_graph():\n        g = EdgeWeightedGraph(8)\n        g.add_edge(Edge(0, 7, 0.16))\n        g.add_edge(Edge(2, 3, 0.17))\n        g.add_edge(Edge(1, 7, 0.19))\n        g.add_edge(Edge(0, 2, 0.26))\n        g.add_edge(Edge(5, 7, 0.28))\n\n        print([edge for edge in G.adj(3)])\n\n        print(G.vertex_count())\n        print(', '.join([edge for edge in G.edges()]))\n        return g\n\n\nDirected Edge Weighted Graph\n\n.. code-block:: python\n\n    from pyalgs.data_structures.graphs.graph import DirectedEdgeWeightedGraph, Edge\n    def create_edge_weighted_digraph():\n        g = DirectedEdgeWeightedGraph(8)\n\n        g.add_edge(Edge(0, 1, 5.0))\n        g.add_edge(Edge(0, 4, 9.0))\n        g.add_edge(Edge(0, 7, 8.0))\n        g.add_edge(Edge(1, 2, 12.0))\n        return g\n\n\nFlow Network ( for max-flow min-cut problem)\n\n.. code-block:: python\n\n    from pyalgs.data_structures.graphs.graph import FlowNetwork, FlowEdge\n    def create_flow_network():\n    g = FlowNetwork(8)\n    g.add_edge(FlowEdge(0, 1, 10))\n    g.add_edge(FlowEdge(0, 2, 5))\n    g.add_edge(FlowEdge(0, 3, 15))\n    g.add_edge(FlowEdge(1, 4, 9))\n    g.add_edge(FlowEdge(1, 5, 15))\n    g.add_edge(FlowEdge(1, 2, 4))\n    g.add_edge(FlowEdge(2, 5, 8))\n    g.add_edge(FlowEdge(2, 3, 4))\n    g.add_edge(FlowEdge(3, 6, 16))\n    g.add_edge(FlowEdge(4, 5, 15))\n    g.add_edge(FlowEdge(4, 7, 10))\n    g.add_edge(FlowEdge(5, 7, 10))\n    g.add_edge(FlowEdge(5, 6, 15))\n    g.add_edge(FlowEdge(6, 2, 6))\n    g.add_edge(FlowEdge(6, 7, 10))\n\n    return g\n\n\nSymbol Table using R-ways Search Tries\n\n\n.. code-block:: python\n\n    from pyalgs.data_structures.strings.search_tries import RWaySearchTries\n    st = RWaySearchTries()\n\n    st.put(\"one\", 1)\n    st.put(\"two\", 2)\n    st.put(\"three\", 3)\n    st.put(\"six\", 6)\n    st.put(\"ten\", 10)\n\n    for key in st.keys():\n        print(key)\n\n    print st.get(\"one\"))\n    print st.contains_key(\"two\")\n\n    print st.size()\n    print st.is_empty()\n\n    st.delete(\"one\")\n    \n    for key in st.keys_with_prefix('t'):\n        print(key)\n\n\nSymbol Table using Ternary Search Tries\n\n\n.. code-block:: python\n\n    from pyalgs.data_structures.strings.search_tries import TernarySearchTries\n    st = TernarySearchTries()\n\n    st.put(\"one\", 1)\n    st.put(\"two\", 2)\n    st.put(\"three\", 3)\n    st.put(\"six\", 6)\n    st.put(\"ten\", 10)\n\n    for key in st.keys():\n        print(key)\n\n    print st.get(\"one\"))\n    print st.contains_key(\"two\")\n\n    print st.size()\n    print st.is_empty()\n\n    st.delete(\"one\")\n\n    for key in st.keys_with_prefix('t'):\n        print(key)\n\n\nAlgorithms\n----------\n\nUnion Find\n\n\n.. code-block:: python\n\n    from pyalgs.algorithms.commons.union_find import UnionFind\n\n    uf = UnionFind.create(10)\n\n    uf.union(1, 3)\n    uf.union(2, 4)\n    uf.union(1, 5)\n\n    print(uf.connected(1, 3))\n    print(uf.connected(3, 5))\n    print(uf.connected(1, 2))\n    print(uf.connected(1, 4))\n\n\nSorting\n\n\nThe sorting algorithms sort an array in ascending order\n\nSelection Sort\n\n.. code-block:: python\n\n    from pyalgs.algorithms.commons.sorting import SelectionSort\n\n    a = [4, 2, 1]\n    SelectionSort.sort(a)\n    print(a)\n\n\nInsertion Sort\n\n.. code-block:: python\n\n    from pyalgs.algorithms.commons.sorting import InsertionSort\n\n    a = [4, 2, 1]\n    InsertionSort.sort(a)\n    print(a)\n\n\nShell Sort\n\n.. code-block:: python\n\n    from pyalgs.algorithms.commons.sorting import ShellSort\n\n    a = [4, 2, 1, 23, 4, 5, 6, 7, 8, 9, 20, 11, 13, 34, 66]\n    ShellSort.sort(a)\n    print(a)\n\n\nMerge Sort\n\n.. code-block:: python\n\n    from pyalgs.algorithms.commons.sorting import MergeSort\n\n    a = [4, 2, 1, 23, 4, 5, 6, 7, 8, 9, 20, 11, 13, 34, 66]\n    MergeSort.sort(a)\n    print(a)\n\n\nQuick Sort\n\n.. code-block:: python\n\n    from pyalgs.algorithms.commons.sorting import QuickSort\n\n    a = [4, 2, 1, 23, 4, 5, 6, 7, 8, 9, 20, 11, 13, 34, 66]\n    QuickSort.sort(a)\n    print(a)\n\n\n3-Ways Quick Sort\n\n.. code-block:: python\n\n    from pyalgs.algorithms.commons.sorting import ThreeWayQuickSort\n\n    a = [4, 2, 1, 23, 4, 5, 6, 7, 8, 9, 20, 11, 13, 34, 66]\n    ThreeWayQuickSort.sort(a)\n    print(a)\n\n\nHeap Sort\n\n.. code-block:: python\n\n    from pyalgs.algorithms.commons.sorting import HeapSort\n\n    a = [4, 2, 1, 23, 4, 5, 6, 7, 8, 9, 20, 11, 13, 34, 66]\n    HeapSort.sort(a)\n    print(a)\n\n\n\nSelection\n\n\nBinary Selection\n\n.. code-block:: python\n\n    from pyalgs.algorithms.commons.selecting import BinarySelection\n    from pyalgs.algorithms.commons.util import is_sorted\n\n\n    a = [1, 2, 13, 22, 123]\n    assert is_sorted(a)\n    print BinarySelection.index_of(a, 13)\n\n\nShuffle\n\n\nKnuth Shuffle\n\n.. code-block:: python\n\n    from pyalgs.algorithms.commons.shuffling import KnuthShuffle\n\n    a = [1, 2, 13, 22, 123]\n    KnuthShuffle.shuffle(a)\n    print(a)\n\n\nGraph\n-----\n\nDepth First Search\n\n.. code-block:: python\n\n    from pyalgs.algorithms.graphs.search import DepthFirstSearch\n    g = create_graph()\n    s = 0\n    dfs = DepthFirstSearch(g, s)\n\n    for v in range(1, g.vertex_count()):\n        if dfs.hasPathTo(v):\n            print(str(s) + ' is connected to ' + str(v))\n            print('path is ' + ' =\u003e '.join([str(i) for i in dfs.pathTo(v)]))\n\n\nBreadth First Search\n\n.. code-block:: python\n\n    from pyalgs.algorithms.graphs.search import BreadthFirstSearch\n    g = create_graph()\n    s = 0\n    dfs = BreadthFirstSearch(g, s)\n\n    for v in range(1, g.vertex_count()):\n        if dfs.hasPathTo(v):\n            print(str(s) + ' is connected to ' + str(v))\n            print('path is ' + ' =\u003e '.join([str(i) for i in dfs.pathTo(v)]))\n\n\nConnected Components\n\nThis is for undirected graph\n\n.. code-block:: python\n\n    from pyalgs.algorithms.graphs.connectivity import ConnectedComponents\n    G = create_graph()\n\n    cc = ConnectedComponents(G)\n    print('connected component count: ' + str(cc.count()))\n\n\n    for v in range(G.vertex_count()):\n        print('id[' + str(v) + ']: ' + str(cc.id(v)))\n    for v in range(G.vertex_count()):\n        r = randint(0, G.vertex_count()-1)\n        if cc.connected(v, r):\n            print(str(v) + ' is connected to ' + str(r))\n\n\nStrongly Connected Components\n\nThis is for directed graph\n\n.. code-block:: python\n\n    from pyalgs.algorithms.graphs.connectivity import StronglyConnectedComponents\n    G = create_graph()\n\n    cc = StronglyConnectedComponents(G)\n    print('strongly connected component count: ' + str(cc.count()))\n\n\n    for v in range(G.vertex_count()):\n        print('id[' + str(v) + ']: ' + str(cc.id(v)))\n    for v in range(G.vertex_count()):\n        r = randint(0, G.vertex_count()-1)\n        if cc.connected(v, r):\n            print(str(v) + ' is connected to ' + str(r))\n\n\nTopological Sort\n\n.. code-block:: python\n\n    from pyalgs.algorithms.graphs.topological_sort import DepthFirstOrder\n    G = create_graph()\n    topological_sort = DepthFirstOrder(G)\n    print(' =\u003e '.join([str(i) for i in topological_sort.postOrder()]))\n\n\nMinimum Spanning Tree (Kruskal)\n\n.. code-block:: python\n\n    from pyalgs.algorithms.graphs.minimum_spanning_trees import KruskalMST\n    g = create_edge_weighted_graph()\n    mst = KruskalMST(g)\n\n    tree = mst.spanning_tree()\n\n    for e in tree:\n        print(e)\n\nMinimum Spanning Tree (Prim Lazy)\n\n.. code-block:: python\n\n    from pyalgs.algorithms.graphs.minimum_spanning_trees import LazyPrimMST\n    g = create_edge_weighted_graph()\n    mst = LazyPrimMST(g)\n\n    tree = mst.spanning_tree()\n\n    for e in tree:\n        print(e)\n\n\nMinimum Spanning Tree (Prim Eager)\n\n.. code-block:: python\n\n    from pyalgs.algorithms.graphs.minimum_spanning_trees import EagerPrimMST\n    g = create_edge_weighted_graph()\n    mst = EagerPrimMST(g)\n\n    tree = mst.spanning_tree()\n\n    for e in tree:\n        print(e)\n\n\nDirected Cycle Detection:\n\n.. code-block:: python\n\n    from pyalgs.algorithms.graphs.directed_cycle import DirectedCycle\n    dag = create_dag()\n        dc = DirectedCycle(dag)\n        assertFalse(dc.hasCycle())\n\n\nShortest Path (Dijkstra)\n\n.. code-block:: python\n\n    from pyalgs.algorithms.graphs.shortest_path import DijkstraShortestPath\n    g = create_edge_weighted_digraph()\n    s = 0\n    dijkstra = DijkstraShortestPath(g, s)\n    for v in range(1, g.vertex_count()):\n        if dijkstra.hasPathTo(v):\n            print(str(s) + ' is connected to ' + str(v))\n            print('shortest path is ' + ' .. '.join([str(i) for i in dijkstra.shortestPathTo(v)]))\n            print('path length is ' + str(dijkstra.path_length_to(v)))\n\n\nShortest Path (Topological Sort)\n\n.. code-block:: python\n\n    from pyalgs.algorithms.graphs.shortest_path import TopologicalSortShortestPath\n    from pyalgs.algorithms.graphs.directed_cycle import DirectedCycle\n    g = create_edge_weighted_digraph()\n    assert not DirectedCycle(g).hasCycle()\n    s = 0\n    dijkstra = TopologicalSortShortestPath(g, s)\n    for v in range(1, g.vertex_count()):\n        if dijkstra.hasPathTo(v):\n            print(str(s) + ' is connected to ' + str(v))\n            print('shortest path is ' + ' .. '.join([str(i) for i in dijkstra.shortestPathTo(v)]))\n            print('path length is ' + str(dijkstra.path_length_to(v)))\n\n\nShortest Path (Bellman-Ford for positive and negative edge graph)\n\n.. code-block:: python\n\n    from pyalgs.algorithms.graphs.shortest_path import BellmanFordShortestPath\n    from pyalgs.algorithms.graphs.directed_cycle import DirectedCycle\n    g = create_edge_weighted_digraph()\n    s = 0\n    dijkstra = BellmanFordShortestPath(g, s)\n    for v in range(1, g.vertex_count()):\n        if dijkstra.hasPathTo(v):\n            print(str(s) + ' is connected to ' + str(v))\n            print('shortest path is ' + ' .. '.join([str(i) for i in dijkstra.shortestPathTo(v)]))\n            print('path length is ' + str(dijkstra.path_length_to(v)))\n\n\nMaxFlow MinCut (Ford-Fulkerson)\n\n.. code-block:: python\n\n    from pyalgs.algorithms.graphs.max_flow import FordFulkersonMaxFlow\n    network = create_flow_network()\n    ff = FordFulkersonMaxFlow(network, 0, 7)\n    print('max-flow: '+str(ff.max_flow_value()))\n\n\nStrings\n-------\n\nLongest Repeated Substring\n\n.. code-block:: python\n\n  from pyalgs.algorithms.strings.longest_repeated_substring import LongestRepeatedSubstringSearch\n  start, len = LongestRepeatedSubstringSearch.lrs('Hello World', 'World Record')\n  print('Hello World'[start:(start+len+1)])\n\n\nSort (LSD)\n\n.. code-block:: python\n\n    from pyalgs.algorithms.strings.sorting import LSD\n    LSD.sort(['good', 'cool', 'done', 'come'])\n\n\nSort (MSD)\n\n.. code-block:: python\n\n    from pyalgs.algorithms.strings.sorting import MSD\n    words = 'more details are provided in the docs for implementation, complexities and further info'.split(' ')\n    print(words)\n    MSD.sort(words)\n    print(words)\n\n\nSort (3-Ways String Quick Sort)\n\n.. code-block:: python\n\n    from pyalgs.algorithms.strings.sorting import String3WayQuickSort\n    words = 'more details are provided in the docs for implementation, complexities and further info'.split(' ')\n    print(words)\n    String3WayQuickSort.sort(words)\n    print(words)\n\n\nSubstring Search (Brute force)\n\n.. code-block:: python\n\n    from pyalgs.algorithms.strings.substring_search import BruteForceSubstringSearch\n    ss = BruteForceSubstringSearch('find')\n    print(ss.search_in('I can find it here'))\n    print(ss.search_in('It is not here'))\n\n\nSubstring Search (Rabin Karp)\n\n.. code-block:: python\n\n    from pyalgs.algorithms.strings.substring_search import RabinKarp\n    ss = RabinKarp('find')\n    print(ss.search_in('I can find it here'))\n    print(ss.search_in('It is not here'))\n\n\nSubstring Search (Boyer Moore)\n\n.. code-block:: python\n\n    from pyalgs.algorithms.strings.substring_search import BoyerMoore\n    ss = BoyerMoore('find')\n    print(ss.search_in('I can find it here'))\n    print(ss.search_in('It is not here'))\n\n\nSubstring Search (Knuth Morris Pratt)\n\n.. code-block:: python\n\n    from pyalgs.algorithms.strings.substring_search import KnuthMorrisPratt\n    ss = KnuthMorrisPratt('find')\n    print(ss.search_in('I can find it here'))\n    print(ss.search_in('It is not here'))\n\n\n.. _`docs`: http://pyalgs.readthedocs.org/en/latest/\n.. _`documentation`: http://pyalgs.readthedocs.org/en/latest/","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchen0040%2Fpyalgs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchen0040%2Fpyalgs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchen0040%2Fpyalgs/lists"}