File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
pydatastructs/graphs/tests Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -30,3 +30,23 @@ def test_AdjacencyMatrix():
3030 assert raises (ValueError , lambda : g .add_edge ('v' , 'x' ))
3131 assert raises (ValueError , lambda : g .add_edge (2 , 3 ))
3232 assert raises (ValueError , lambda : g .add_edge (3 , 2 ))
33+ assert g .num_vertices () == 3
34+ v_3 = AdjacencyMatrixGraphNode (3 , 3 )
35+ g .add_vertex (v_3 )
36+ assert g .num_vertices () == 4
37+ g .add_edge (3 , 1 , 0 )
38+ g .add_edge (3 , 2 , 0 )
39+ g .add_edge (2 , 3 , 0 )
40+ assert g .is_adjacent (3 , 1 ) is True
41+ assert g .is_adjacent (0 , 2 ) is False
42+ assert g .is_adjacent (1 , 3 ) is False
43+ assert g .is_adjacent (2 , 3 ) is True
44+ assert g .is_adjacent (3 , 2 ) is True
45+ neighbors = g .neighbors (3 )
46+ assert neighbors == [v_1 , v_2 ]
47+ neighbors = g .neighbors (2 )
48+ assert neighbors == [v_0 , v_3 ]
49+ g .remove_vertex (3 )
50+ neighbors = g .neighbors (2 )
51+ assert neighbors == [v_0 ]
52+ assert g .num_vertices () == 3
You can’t perform that action at this time.
0 commit comments