Add Tarjan's algorithm.

This commit is contained in:
Oleksii Trekhleb 2018-05-11 15:40:59 +03:00
parent 25703c37ac
commit 1dd480b906
2 changed files with 4 additions and 4 deletions

View File

@ -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;

View File

@ -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)