def test_addDuplicateEdge(): G = g.createGraph() g.addNode(G, 'Room 1') g.addNode(G, 'Room 2') g.addEdge(G, 'Room 1', 'Room 2') g.addEdge(G, 'Room 1', 'Room 2') assert len(list(G.edges)) == 1
def test_shortestPathInvalidRoomOrigin(): G = g.createGraph() g.addNode(G, 'Room 1') g.addNode(G, 'Room -1') g.addEdge(G, 'Room 1', 'Room -1') assert g.shortestPath( G, 'Room -1') == "Please move a little, you are between two rooms."
def test_shortestPath(): G = g.createGraph() g.addNode(G, 'Room 1') g.addNode(G, 'Room 2') g.addNode(G, 'Room 3') g.addNode(G, 'Room 4') g.addEdge(G, 'Room 1', 'Room 2') g.addEdge(G, 'Room 1', 'Room 3') g.addEdge(G, 'Room 2', 'Room 4') g.addEdge(G, 'Room 3', 'Room 2') assert g.shortestPath(G, 'Room 4') == "Room 4 -> Room 2 -> Room 1"
def test_addEdgeInvalidNodes(): G = g.createGraph() g.addNode(G, 'Room -1') g.addNode(G, 'Room -2') g.addEdge(G, 'Room -1', 'Room -2') assert not list(G.edges)
def test_addEdgeToEmptyGraph(): G = g.createGraph() assert not list(G.edges) g.addEdge(G, 'Room 1', 'Room 2') assert not list(G.edges)