MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / test_remove_vertices

Method test_remove_vertices

graphs/graph_adjacency_matrix.py:351–373  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

349 )
350
351 def test_remove_vertices(self) -> None:
352 random_vertices: list[int] = random.sample(range(101), 20)
353
354 # build graphs WITHOUT edges
355 undirected_graph = GraphAdjacencyMatrix(
356 vertices=random_vertices, edges=[], directed=False
357 )
358 directed_graph = GraphAdjacencyMatrix(
359 vertices=random_vertices, edges=[], directed=True
360 )
361
362 # test remove_vertex worked
363 for num in random_vertices:
364 self.__assert_graph_vertex_exists_check(
365 undirected_graph, directed_graph, num
366 )
367
368 undirected_graph.remove_vertex(num)
369 directed_graph.remove_vertex(num)
370
371 self.__assert_graph_vertex_does_not_exist_check(
372 undirected_graph, directed_graph, num
373 )
374
375 def test_add_and_remove_vertices_repeatedly(self) -> None:
376 random_vertices1: list[int] = random.sample(range(51), 20)

Callers

nothing calls this directly

Tested by

no test coverage detected