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

Method test_contains_vertex

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

Source from the content-addressed store, hash-verified

309 assert directed_graph.directed
310
311 def test_contains_vertex(self) -> None:
312 random_vertices: list[int] = random.sample(range(101), 20)
313
314 # Build graphs WITHOUT edges
315 undirected_graph = GraphAdjacencyMatrix(
316 vertices=random_vertices, edges=[], directed=False
317 )
318 directed_graph = GraphAdjacencyMatrix(
319 vertices=random_vertices, edges=[], directed=True
320 )
321
322 # Test contains_vertex
323 for num in range(101):
324 assert (num in random_vertices) == undirected_graph.contains_vertex(num)
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)

Callers

nothing calls this directly

Calls 2

contains_vertexMethod · 0.95

Tested by

no test coverage detected