def test_bipartite(self): graph = movie_actor(True) biadjacency = graph.biadjacency names_row = graph.names_row names_col = graph.names_col image = svg_bigraph(biadjacency, names_row, names_col) self.assertEqual(image[1:4], 'svg') image = svg_bigraph(biadjacency, display_edges=False) self.assertEqual(image[1:4], 'svg') image = svg_bigraph(biadjacency, reorder=False) self.assertEqual(image[1:4], 'svg') n_row, n_col = biadjacency.shape position_row = np.random.random((n_row, 2)) position_col = np.random.random((n_col, 2)) edge_labels = [(0, 1, 0), (1, 1, 1), (3, 10, 2)] image = svg_bigraph(biadjacency=biadjacency, names_row=np.arange(n_row), names_col=np.arange(n_col), labels_row=np.arange(n_row), labels_col=np.arange(n_col), scores_row=np.arange(n_row), scores_col=np.arange(n_col), seeds_row=[0, 1], seeds_col=[1, 2], position_row=position_row, position_col=position_col, color_row='red', color_col='white', width=200, height=200, margin=10, margin_text=5, scale=3, node_size=5, node_size_min=1, node_size_max=30, node_weights_row=np.arange(n_row), node_weights_col=np.arange(n_col), display_node_weight=True, node_width=2, node_width_max=5, edge_labels=edge_labels, edge_width=2, edge_width_min=0.3, edge_width_max=4, edge_color='red', display_edge_weight=True, font_size=14) self.assertEqual(image[1:4], 'svg')
def test_disconnect(self): adjacency = test_graph_disconnect() position = np.random.random((adjacency.shape[0], 2)) image = svg_graph(adjacency, position) self.assertEqual(image[1:4], 'svg') biadjacency = test_bigraph_disconnect() image = svg_bigraph(biadjacency) self.assertEqual(image[1:4], 'svg')
def test_membership(self): adjacency = bow_tie() membership = sparse.csr_matrix([[.5, .5], [0, 0], [1, 0], [0, 1], [0, 1]]) image = svg_graph(adjacency, membership=membership) self.assertEqual(image[1:4], 'svg') biadjacency = star_wars() membership_row = sparse.csr_matrix([[.5, .5], [0, 0], [1, 0], [0, 1]]) membership_col = sparse.csr_matrix([[.5, .5], [0, 0], [1, 0]]) image = svg_bigraph(biadjacency, membership_row=membership_row, membership_col=membership_col) self.assertEqual(image[1:4], 'svg')