File tree Expand file tree Collapse file tree
src/algorithms/graph/articulation-points Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -65,13 +65,19 @@ export default function articulationPoints(graph) {
6565 // Update the low time with the smallest time of adjacent vertices.
6666 // Get minimum low discovery time from all neighbors.
6767 /** @param {GraphVertex } neighbor */
68- visitedSet [ currentVertex . getKey ( ) ] . lowDiscoveryTime = currentVertex . getNeighbors ( ) . reduce (
69- ( lowestDiscoveryTime , neighbor ) => {
70- const neighborLowTime = visitedSet [ neighbor . getKey ( ) ] . lowDiscoveryTime ;
71- return neighborLowTime < lowestDiscoveryTime ? neighborLowTime : lowestDiscoveryTime ;
72- } ,
73- visitedSet [ currentVertex . getKey ( ) ] . lowDiscoveryTime ,
74- ) ;
68+ visitedSet [ currentVertex . getKey ( ) ] . lowDiscoveryTime = currentVertex . getNeighbors ( )
69+ . filter ( earlyNeighbor => earlyNeighbor . getKey ( ) !== previousVertex . getKey ( ) )
70+ /**
71+ * @param {number } lowestDiscoveryTime
72+ * @param {GraphVertex } neighbor
73+ */
74+ . reduce (
75+ ( lowestDiscoveryTime , neighbor ) => {
76+ const neighborLowTime = visitedSet [ neighbor . getKey ( ) ] . lowDiscoveryTime ;
77+ return neighborLowTime < lowestDiscoveryTime ? neighborLowTime : lowestDiscoveryTime ;
78+ } ,
79+ visitedSet [ currentVertex . getKey ( ) ] . lowDiscoveryTime ,
80+ ) ;
7581
7682 // Detect whether previous vertex is articulation point or not.
7783 // To do so we need to check two [OR] conditions:
You can’t perform that action at this time.
0 commit comments