Esempio n. 1
0
 def test_pairwise(self):
     a = [1, 2, 3]
     b = [4, 5, 6]
     c = [6, 7, 8]
     it = [a, b, c]
     pw = list(graph.pairwise(it))
     self.assertListEqual(list(pw[0]), [a, b])
     self.assertListEqual(list(pw[1]), [b, c])
Esempio n. 2
0
    def test_d3_forced_layout(self):
        self.assertRaises(
            NotImplementedError,
            self.gr.d3_forced_layout
        )
        self.gr.node_labels_to_ints()

        # list tuples (index, {'nodeID': index})
        for node in self.gr.graph.nodes(data=True):
            self.assertEqual(node[0], node[1]['nodeID'])

        # get d3 layout and check source and target are present
        # note I have set first label to zero
        edges, nodes = self.gr.d3_forced_layout()
        for pair in graph.pairwise([1, 2, 3]):
            present = False
            for edge in edges:
                if (
                        edge['source'] == pair[0]-1 and
                        edge['target'] == pair[1]-1
                ):
                    present = True
            self.assertTrue(present)