예제 #1
0
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)
예제 #2
0
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')
예제 #3
0
def test_weighted_dfs(adjmatrix, expected):
    namedmatrix = gt.nameAdjMatrix(adjmatrix)
    _, result = gt.search.DFS(adjmatrix=namedmatrix, startnode='A')
    assert list(result) == expected
예제 #4
0
def test_search_valid_adjmatrix(adjmatrix):
    named = gt.nameAdjMatrix(adjmatrix, 'a')
    _ = gt.search.BFSmatrix(adjmatrix=named, startnode='A')
    assert True
예제 #5
0
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)