def bipartite_as_graph(self) -> Graph:  # pragma: no cover
        """Returns a :class:`graphviz.Graph` representation of this bipartite graph."""
        if Graph is None:
            raise ImportError('The graphviz package is required to draw the graph.')
        graph = Graph()
        nodes_left = {}  # type: Dict[TLeft, str]
        nodes_right = {}  # type: Dict[TRight, str]
        node_id = 0
        for (left, right), value in self.bipartite._edges.items():
            if left not in nodes_left:
                name = 'node{:d}'.format(node_id)
                nodes_left[left] = name
                label = str(self.subjects_by_id[left])
                graph.node(name, label=label)
                node_id += 1
            if right not in nodes_right:
                name = 'node{:d}'.format(node_id)
                nodes_right[right] = name
                label = str(self.automaton.patterns[right][0])
                graph.node(name, label=label)
                node_id += 1
            edge_label = value is not True and str(value) or ''
            graph.edge(nodes_left[left], nodes_right[right], edge_label)
        return graph
def bipartite_as_graph ( self ) -> Graph : if Graph is None : raise ImportError ( 'The graphviz package is required to draw the graph.' ) graph = Graph ( ) nodes_left = { } nodes_right = { } node_id = 0 for ( left , right ) , value in self . bipartite . _edges . items ( ) : if left not in nodes_left : name = 'node{:d}' . format ( node_id ) nodes_left [ left ] = name label = str ( self . subjects_by_id [ left ] ) graph . node ( name , label = label ) node_id += 1 if right not in nodes_right : name = 'node{:d}' . format ( node_id ) nodes_right [ right ] = name label = str ( self . automaton . patterns [ right ] [ 0 ] ) graph . node ( name , label = label ) node_id += 1 edge_label = value is not True and str ( value ) or '' graph . edge ( nodes_left [ left ] , nodes_right [ right ] , edge_label ) return graph
Returns a :class:`graphviz.Graph` representation of this bipartite graph.