Skip to content

Commit

Permalink
added test for conversions of directed graph to adjacency graph
Browse files Browse the repository at this point in the history
  • Loading branch information
eileen-kuehn committed Jul 29, 2018
1 parent 84dc630 commit 2677c76
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions graphi_unittests/types_unittests/test_undirected.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import textwrap

from graphi.graph_io import csv

try:
import unittest2 as unittest
except ImportError:
Expand Down Expand Up @@ -48,3 +52,20 @@ def test_update(self):
})
undirected_graph.update(second_graph)
self.assertIn(undirected.UndirectedEdge[2:3], undirected_graph)

def test_conversion(self):
literal = textwrap.dedent("""
1,2,3,4,5,6,7,8
0,1,1,1,1,2,0,1
1,0,0,0,0,0,0,0
1,0,0,0,0,0,0,0
1,0,0,0,0,0,0,0
1,0,0,0,0,0,0,0
2,0,0,0,0,0,1,0
0,0,0,0,0,1,0,0
1,0,0,0,0,0,0,0
""".strip())
graph = csv.graph_reader(literal.splitlines(), undirected=True)
self.assertTrue(slice("6", "1") in graph)
al_graph = adjacency_graph.AdjacencyGraph(graph, max_distance=1)
self.assertTrue(slice("6", "1") in al_graph)

0 comments on commit 2677c76

Please sign in to comment.