def draw_network(self, anim):
        """Draws solution's graph using networkx
        
        Parameters
        ----------
        AnimationDing0
            AnimationDing0 object
            
        """

        g = nx.Graph()
        ntemp = []
        nodes_pos = {}
        demands = {}
        demands_pos = {}
        for no, node in self._nodes.items():
            g.add_node(node)
            ntemp.append(node)
            coord = self._problem._coord[no]
            nodes_pos[node] = tuple(coord)
            demands[node] = 'd=' + str(node.demand())
            demands_pos[node] = tuple([a+b for a, b in zip(coord, [2.5]*len(coord))])

        depot = self._nodes[self._problem._depot._name]
        for r in self.routes():
            n1 = r._nodes[0:len(r._nodes)-1]
            n2 = r._nodes[1:len(r._nodes)]
            e = list(zip(n1, n2))
            e.append((depot, r._nodes[0]))
            e.append((r._nodes[-1], depot))
            g.add_edges_from(e)

        plt.figure()
        ax = plt.gca()
        ax.get_xaxis().set_visible(False)
        ax.get_yaxis().set_visible(False)

        if anim is not None:
            nx.draw_networkx(g, nodes_pos, with_labels=False, node_size=50)
            plt.savefig(anim.file_path +
                        anim.file_prefix +
                        (4 - len(str(anim.counter))) * '0' +
                        str(anim.counter) + '.png',
                        dpi=150,
                        bbox_inches='tight')
            anim.counter += 1
            plt.close()
        else:
            nx.draw_networkx(g, nodes_pos)
            nx.draw_networkx_labels(g, demands_pos, labels=demands)
            plt.show()
def draw_network ( self , anim ) : g = nx . Graph ( ) ntemp = [ ] nodes_pos = { } demands = { } demands_pos = { } for no , node in self . _nodes . items ( ) : g . add_node ( node ) ntemp . append ( node ) coord = self . _problem . _coord [ no ] nodes_pos [ node ] = tuple ( coord ) demands [ node ] = 'd=' + str ( node . demand ( ) ) demands_pos [ node ] = tuple ( [ a + b for a , b in zip ( coord , [ 2.5 ] * len ( coord ) ) ] ) depot = self . _nodes [ self . _problem . _depot . _name ] for r in self . routes ( ) : n1 = r . _nodes [ 0 : len ( r . _nodes ) - 1 ] n2 = r . _nodes [ 1 : len ( r . _nodes ) ] e = list ( zip ( n1 , n2 ) ) e . append ( ( depot , r . _nodes [ 0 ] ) ) e . append ( ( r . _nodes [ - 1 ] , depot ) ) g . add_edges_from ( e ) plt . figure ( ) ax = plt . gca ( ) ax . get_xaxis ( ) . set_visible ( False ) ax . get_yaxis ( ) . set_visible ( False ) if anim is not None : nx . draw_networkx ( g , nodes_pos , with_labels = False , node_size = 50 ) plt . savefig ( anim . file_path + anim . file_prefix + ( 4 - len ( str ( anim . counter ) ) ) * '0' + str ( anim . counter ) + '.png' , dpi = 150 , bbox_inches = 'tight' ) anim . counter += 1 plt . close ( ) else : nx . draw_networkx ( g , nodes_pos ) nx . draw_networkx_labels ( g , demands_pos , labels = demands ) plt . show ( )
Draws solution's graph using networkx
        
        Parameters
        ----------
        AnimationDing0
            AnimationDing0 object