Created
October 17, 2017 10:13
-
-
Save eneskaya/1d046f7aea20828148881b7b0b4c6e59 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module (adtgraph_tests). | |
-include_lib("eunit/include/eunit.hrl"). | |
addAndRemoveVertices_test() -> | |
G = adtgraph:createG(ud), | |
G1 = adtgraph:addVertex(G, 1), | |
G2 = adtgraph:addVertex(G1, 2), | |
V = adtgraph:getVertexes(G2), | |
?assertEqual([1,2], V), | |
G3 = adtgraph:deleteVertex(G2, 1), | |
V1 = adtgraph:getVertexes(G3), | |
?assertEqual([2], V1). | |
addAndRemoveEdges_test() -> | |
G = adtgraph:createG(ud), | |
G1 = adtgraph:addVertex(G, 1), | |
G2 = adtgraph:addVertex(G1, 2), | |
G3 = adtgraph:addVertex(G2, 3), | |
G4 = adtgraph:addVertex(G3, 4), | |
G5 = adtgraph:addEdge(G4, 1, 2), | |
G6 = adtgraph:addEdge(G5, 1, 3), | |
G7 = adtgraph:addEdge(G6, 2, 4), | |
?assertEqual([1,2,3,4], adtgraph:getVertexes(G4)), | |
?assertEqual([1,2,1,3,2,4], adtgraph:getEdges(G7)), | |
G8 = adtgraph:deleteEdge(G7, 2, 4), | |
?assertEqual([1,2,1,3], adtgraph:getEdges(G8)). | |
attributes_test() -> | |
G = adtgraph:createG(ud), | |
G1 = adtgraph:addVertex(G, 1), | |
G2 = adtgraph:addVertex(G1, 2), | |
G3 = adtgraph:addVertex(G2, 3), | |
G4 = adtgraph:addVertex(G3, 4), | |
G5 = adtgraph:addEdge(G4, 1, 2), | |
G6 = adtgraph:addEdge(G5, 1, 3), | |
G7 = adtgraph:addEdge(G6, 2, 4), | |
G8 = adtgraph:setAtV(G7, 1, some_attr, 42), | |
G9 = adtgraph:setAtE(G8, {1, 3}, weight, -42), | |
?assertEqual(42, adtgraph:getValV(G9, 1, some_attr)), | |
?assertEqual(-42, adtgraph:getValE(G9, {1, 3}, weight)). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment