@@ -140,4 +140,71 @@ describe('articulationPoints', () => {
140
140
vertexD ,
141
141
] ) ;
142
142
} ) ;
143
+
144
+ it ( 'should find articulation points in yet another graph #1' , ( ) => {
145
+ const vertexA = new GraphVertex ( 'A' ) ;
146
+ const vertexB = new GraphVertex ( 'B' ) ;
147
+ const vertexC = new GraphVertex ( 'C' ) ;
148
+ const vertexD = new GraphVertex ( 'D' ) ;
149
+ const vertexE = new GraphVertex ( 'E' ) ;
150
+
151
+ const edgeAB = new GraphEdge ( vertexA , vertexB ) ;
152
+ const edgeAC = new GraphEdge ( vertexA , vertexC ) ;
153
+ const edgeBC = new GraphEdge ( vertexB , vertexC ) ;
154
+ const edgeCD = new GraphEdge ( vertexC , vertexD ) ;
155
+ const edgeDE = new GraphEdge ( vertexD , vertexE ) ;
156
+
157
+ const graph = new Graph ( ) ;
158
+
159
+ graph
160
+ . addEdge ( edgeAB )
161
+ . addEdge ( edgeAC )
162
+ . addEdge ( edgeBC )
163
+ . addEdge ( edgeCD )
164
+ . addEdge ( edgeDE ) ;
165
+
166
+ const articulationPointsSet = articulationPoints ( graph ) ;
167
+
168
+ expect ( articulationPointsSet ) . toEqual ( [
169
+ vertexD ,
170
+ vertexC ,
171
+ ] ) ;
172
+ } ) ;
173
+
174
+ it ( 'should find articulation points in yet another graph #2' , ( ) => {
175
+ const vertexA = new GraphVertex ( 'A' ) ;
176
+ const vertexB = new GraphVertex ( 'B' ) ;
177
+ const vertexC = new GraphVertex ( 'C' ) ;
178
+ const vertexD = new GraphVertex ( 'D' ) ;
179
+ const vertexE = new GraphVertex ( 'E' ) ;
180
+ const vertexF = new GraphVertex ( 'F' ) ;
181
+ const vertexG = new GraphVertex ( 'G' ) ;
182
+
183
+ const edgeAB = new GraphEdge ( vertexA , vertexB ) ;
184
+ const edgeAC = new GraphEdge ( vertexA , vertexC ) ;
185
+ const edgeBC = new GraphEdge ( vertexB , vertexC ) ;
186
+ const edgeCD = new GraphEdge ( vertexC , vertexD ) ;
187
+ const edgeCE = new GraphEdge ( vertexC , vertexE ) ;
188
+ const edgeCF = new GraphEdge ( vertexC , vertexF ) ;
189
+ const edgeEG = new GraphEdge ( vertexE , vertexG ) ;
190
+ const edgeFG = new GraphEdge ( vertexF , vertexG ) ;
191
+
192
+ const graph = new Graph ( ) ;
193
+
194
+ graph
195
+ . addEdge ( edgeAB )
196
+ . addEdge ( edgeAC )
197
+ . addEdge ( edgeBC )
198
+ . addEdge ( edgeCD )
199
+ . addEdge ( edgeCE )
200
+ . addEdge ( edgeCF )
201
+ . addEdge ( edgeEG )
202
+ . addEdge ( edgeFG ) ;
203
+
204
+ const articulationPointsSet = articulationPoints ( graph ) ;
205
+
206
+ expect ( articulationPointsSet ) . toEqual ( [
207
+ vertexC ,
208
+ ] ) ;
209
+ } ) ;
143
210
} ) ;
0 commit comments