mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-12-26 07:01:18 +08:00
Add Tarjan's algorithm.
This commit is contained in:
parent
25703c37ac
commit
1dd480b906
@ -38,15 +38,15 @@ export default function articulationPoints(graph) {
|
||||
* @param {GraphVertex} previousVertex
|
||||
*/
|
||||
enterVertex: ({ currentVertex, previousVertex }) => {
|
||||
// Tick discovery time.
|
||||
discoveryTime += 1;
|
||||
|
||||
// Put current vertex to visited set.
|
||||
visitedSet[currentVertex.getKey()] = new VisitMetadata({
|
||||
discoveryTime,
|
||||
lowDiscoveryTime: discoveryTime,
|
||||
});
|
||||
|
||||
// Tick discovery time.
|
||||
discoveryTime += 1;
|
||||
|
||||
if (previousVertex) {
|
||||
// Update children counter for previous vertex.
|
||||
visitedSet[previousVertex.getKey()].independantChildrenCount += 1;
|
||||
|
@ -21,6 +21,6 @@ An undirected connected graph with no cut edges
|
||||
|
||||
## References
|
||||
|
||||
- [GeeksForGeeks on YouTube](https://www.youtube.com/watch?time_continue=110&v=thLQYBlz2DM)
|
||||
- [Wikipedia](https://en.wikipedia.org/wiki/Bridge_%28graph_theory%29#Tarjan.27s_Bridge-finding_algorithm)
|
||||
- [GeeksForGeeks](https://www.geeksforgeeks.org/bridge-in-a-graph/)
|
||||
- [GeeksForGeeks on YouTube](https://www.youtube.com/watch?time_continue=110&v=thLQYBlz2DM)
|
||||
|
Loading…
Reference in New Issue
Block a user