示例#1
0
 def test_graph_planar(self):
     g1 = Graph([
         (0, 1), (2, 7), (1, 5), (1, 6), (3, 6), (0, 4), (3, 7), (2, 5),
         (3, 4), (0, 2),
     ])
     self.assertTrue(is_planar(g1))
     self.assertEqual([4, 4], link_assortment(g1))
     self.assertEqual([4, 0, 0, 0], contracted_link_assortment(g1))
示例#2
0
    def __set_selection(self, item: QListWidgetItem) -> None:
        """Show the data of collection.

        Save the layout position to keep the graphs
        will be in same appearance.
        """
        for button in (
                self.delete_button,
                self.configure_button,
                self.duplicate_button,
        ):
            button.setEnabled(item is not None)
        self.selection_window.clear()
        if item is None:
            return
        # Preview item
        link_is_node = self.graph_link_as_node.isChecked()
        item_preview = QListWidgetItem(item.text())
        row = self.collection_list.row(item)
        g = self.collections[row]
        self.ground_engine = self.collections_layouts[row]
        item_preview.setIcon(
            graph2icon(g,
                       self.selection_window.iconSize().width(),
                       link_is_node,
                       self.graph_show_label.isChecked(),
                       self.prefer.monochrome_option,
                       pos=self.ground_engine))
        self.selection_window.addItem(item_preview)
        # Set attributes
        self.edges_text.setText(str(list(g.edges)))
        self.nl_label.setText(str(len(g.vertices)))
        self.nj_label.setText(str(len(g.edges)))
        self.dof_label.setText(str(g.dof()))
        self.is_degenerate_label.setText(str(g.is_degenerate()))
        self.link_assortment_label.setText(str(link_assortment(g)))
        self.contracted_link_assortment_label.setText(
            str(contracted_link_assortment(g)))
        # Buttons
        self.duplicate_button.setEnabled(link_is_node)
        self.configure_button.setEnabled(not link_is_node)
        self.merge_button.setEnabled(not link_is_node)
        self.__grounded()