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

Method test_add_vertices

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

Source from the content-addressed store, hash-verified

325 assert (num in random_vertices) == directed_graph.contains_vertex(num)
326
327 def test_add_vertices(self) -> None:
328 random_vertices: list[int] = random.sample(range(101), 20)
329
330 # build empty graphs
331 undirected_graph: GraphAdjacencyMatrix = GraphAdjacencyMatrix(
332 vertices=[], edges=[], directed=False
333 )
334 directed_graph: GraphAdjacencyMatrix = GraphAdjacencyMatrix(
335 vertices=[], edges=[], directed=True
336 )
337
338 # run add_vertex
339 for num in random_vertices:
340 undirected_graph.add_vertex(num)
341
342 for num in random_vertices:
343 directed_graph.add_vertex(num)
344
345 # test add_vertex worked
346 for num in random_vertices:
347 self.__assert_graph_vertex_exists_check(
348 undirected_graph, directed_graph, num
349 )
350
351 def test_remove_vertices(self) -> None:
352 random_vertices: list[int] = random.sample(range(101), 20)

Callers

nothing calls this directly

Calls 3

add_vertexMethod · 0.95

Tested by

no test coverage detected