|
1 |
| -# pbgraphs.ts |
2 |
| -pbGraphs.ts is a graph library for TypeScript |
| 1 | +# pbGraphs.ts |
| 2 | +pbGraphs.ts is a graph library for TypeScript. |
| 3 | + |
| 4 | +## Requirements |
| 5 | +TypeScript 3.4+. The resulting JavaScript 5+ works in browsers, NodeJS and Java's script engine. |
| 6 | + |
| 7 | +## Dependencies |
| 8 | +There are no dependencies. |
| 9 | + |
| 10 | +## Getting Started |
| 11 | +It is easy to get started. Simply include the sources in your project. Check out test.ts in the src directory for an example. |
| 12 | + |
| 13 | +## Avaialble in 12 different programming languages |
| 14 | +pbGraphs-java has been implemented with [progsbase](https://www.progsbase.com), so the library is available for 12 different programming languages. |
| 15 | + |
| 16 | +Try [all functions online](https://repo.progsbase.com/repoviewer/no.inductive.libraries/DirectedGraphs/0.1.14/) and see the implementations in different languages. |
| 17 | + |
| 18 | +## Functions |
| 19 | + |
| 20 | +### Graph Equality |
| 21 | +``` |
| 22 | +function DirectedGraphsEqual(a : DirectedGraph, b : DirectedGraph) : boolean |
| 23 | +``` |
| 24 | + |
| 25 | +Returns true of the two directed graphs are equal. |
| 26 | + |
| 27 | +### Graph Components |
| 28 | +``` |
| 29 | +function GetGraphComponents(g : DirectedGraph, componentMembership : NumberArrayReference) : boolean |
| 30 | +``` |
| 31 | + |
| 32 | +Places the list of strongly connected components in componentMembership. Returns false if graphs does not quality as undirected. |
| 33 | + |
| 34 | +### Topological Sort |
| 35 | +``` |
| 36 | +function TopologicalSort(g : DirectedGraph, list : NumberArrayReference) : boolean |
| 37 | +``` |
| 38 | + |
| 39 | +Places the topological sort of the graph in `list`. |
| 40 | + |
| 41 | +### Searches |
| 42 | + |
| 43 | +* Depth-first Search |
| 44 | +``` |
| 45 | +function DepthFirstSearch(g : DirectedGraph, start : number, list : NumberArrayReference) : void |
| 46 | +``` |
| 47 | + |
| 48 | +Places the depth-first sort ordering of the graph in `list`. |
| 49 | + |
| 50 | +* Breadth-first Search |
| 51 | +``` |
| 52 | +function BreadthFirstSearch(g : DirectedGraph, start : number, list : NumberArrayReference) : void |
| 53 | +``` |
| 54 | + |
| 55 | +Places the breadth-first sort ordering of the graph in `list`. |
| 56 | + |
| 57 | +### Shortest Paths |
| 58 | + |
| 59 | +* Dijkstra's Algorithm |
| 60 | +``` |
| 61 | +function DijkstrasAlgorithm(g : DirectedGraph, src : number, dist : NumberArrayReference, distSet : BooleanArrayReference, prev : NumberArrayReference) : void |
| 62 | +``` |
| 63 | + |
| 64 | +Performs Dijkstra's algorithm on the graph `g` from `src`. Whether nodes are reachable is placed in `distSet`, the shortest distances in `dist`, and the previous node in the shortest paths in `prev`. |
| 65 | + |
| 66 | +* Bellman-Ford Algorithm |
| 67 | +``` |
| 68 | +function BellmanFordAlgorithm(g : DirectedGraph, src : number, dist : NumberArrayReference, distSet : BooleanArrayReference, prev : NumberArrayReference) : boolean |
| 69 | +``` |
| 70 | + |
| 71 | +Performs the Bellman-Ford algorithm on the graph `g` from `src`. Whether nodes are reachable is placed in `distSet`, the shortest distances in `dist`, and the previous node in the shortest paths in `prev`. |
| 72 | + |
| 73 | + |
| 74 | +* Floyd-Warshall Algorithm |
| 75 | +``` |
| 76 | +function FloydWarshallAlgorithm(g : DirectedGraph, distances : Distances) : boolean |
| 77 | +``` |
| 78 | + |
| 79 | +Performs the Floyd-Warshall algorithm on the graph `g`. The shortest distances between each pair of nodes are placed in `distances`. |
| 80 | + |
| 81 | +### Minimum Spanning Trees |
| 82 | + |
| 83 | +* Prim's Algorithm |
| 84 | +``` |
| 85 | +function PrimsAlgorithm(g : DirectedGraph, forest : Forest) : boolean |
| 86 | +``` |
| 87 | + |
| 88 | +Performs the Prim's algorithm on the graph `g`. All minimum spanning trees of the graph are placed in `forest`. Returns false if graphs does not quality as undirected. |
| 89 | + |
| 90 | + |
| 91 | +* Kruskal's Algorithm |
| 92 | +``` |
| 93 | +function KruskalsAlgorithm(g : DirectedGraph, forest : Forest) : boolean |
| 94 | +``` |
| 95 | + |
| 96 | +Performs the Kruskal's algorithm on the graph `g`. All minimum spanning trees of the graph are placed in `forest`. Returns false if graphs does not quality as undirected. |
| 97 | + |
| 98 | +### Cycles |
| 99 | + |
| 100 | +* Cycle Detection |
| 101 | +``` |
| 102 | +function DirectedGraphContainsCycleDFS(g : DirectedGraph) : boolean |
| 103 | +``` |
| 104 | + |
| 105 | +Return true if there are cycles in the graph `g`. |
| 106 | + |
| 107 | +* Cycle Counting |
| 108 | +``` |
| 109 | +function DirectedGraphCountCyclesDFS(g : DirectedGraph) : number |
| 110 | +``` |
| 111 | + |
| 112 | +Return the number of cycles in the graph `g`. |
| 113 | + |
| 114 | +* Get All Cyles |
| 115 | +``` |
| 116 | +function DirectedGraphGetCyclesDFS(g : DirectedGraph) : Cycle [] |
| 117 | +``` |
| 118 | + |
| 119 | +Returns the list of cycles in the graph `g`. |
0 commit comments