File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed
src/algorithms/graph/articulation-points Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -65,13 +65,19 @@ export default function articulationPoints(graph) {
65
65
// Update the low time with the smallest time of adjacent vertices.
66
66
// Get minimum low discovery time from all neighbors.
67
67
/** @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
+ ) ;
75
81
76
82
// Detect whether previous vertex is articulation point or not.
77
83
// To do so we need to check two [OR] conditions:
You can’t perform that action at this time.
0 commit comments