From 1dd480b906df4bf9affb7a3694c41129792b6851 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Fri, 11 May 2018 15:40:59 +0300 Subject: [PATCH] Add Tarjan's algorithm. --- .../graph/articulation-points/articulationPoints.js | 6 +++--- src/algorithms/graph/bridges/README.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/algorithms/graph/articulation-points/articulationPoints.js b/src/algorithms/graph/articulation-points/articulationPoints.js index 37c4bd0c..b4a5d939 100644 --- a/src/algorithms/graph/articulation-points/articulationPoints.js +++ b/src/algorithms/graph/articulation-points/articulationPoints.js @@ -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; diff --git a/src/algorithms/graph/bridges/README.md b/src/algorithms/graph/bridges/README.md index 709e66b4..3fd721b0 100644 --- a/src/algorithms/graph/bridges/README.md +++ b/src/algorithms/graph/bridges/README.md @@ -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)