def test_naming_of_adjmatrix(adjmatrix): namedmatrix = gt.nameAdjMatrix(adjmatrix) assert isinstance(namedmatrix, pd.DataFrame) assert all(namedmatrix.columns == namedmatrix.index) assert namedmatrix.index.size == pd.np.sqrt(namedmatrix.size)
def test_invalid_search_adjmatrix(adjmatrix): named = gt.nameAdjMatrix(adjmatrix, 'a') with pytest.raises(AssertionError): _ = gt.search.BFSmatrix(adjmatrix=named, startnode='A') _ = gt.search.BFSmatrix(adjmatrix=adjmatrix, startnode='A')
def test_weighted_dfs(adjmatrix, expected): namedmatrix = gt.nameAdjMatrix(adjmatrix) _, result = gt.search.DFS(adjmatrix=namedmatrix, startnode='A') assert list(result) == expected
def test_search_valid_adjmatrix(adjmatrix): named = gt.nameAdjMatrix(adjmatrix, 'a') _ = gt.search.BFSmatrix(adjmatrix=named, startnode='A') assert True
def test_not_fully_connected_graph(adjmatrix): named = gt.nameAdjMatrix(adjmatrix, mode='n') _, result = gt.search.BFSmatrix(adjmatrix=named, startnode='1') assert len(result) == pd.np.sqrt(named.size)