brainstorm/tools.py
def draw_network(network, file_name='network.png'):
    """Write a diagram for a network to a file.

    Args:
        network (brainstorm.structure.Network): Network to be drawn.
        file_name (Optional[str]): Defaults to 'network.png'.
    Note:
        This tool requires the pygraphviz library to be installed.
    Raises:
        ImportError: If pygraphviz can not be imported.
    """

    try:
        import pygraphviz as pgv
        graph = pgv.AGraph(directed=True)
        for k, v in network.architecture.items():
                for out_view, dest_list in v['@outgoing_connections'].items():
                    for dest in dest_list:
                        graph.add_edge(k, dest.split('.')[0])

        graph.draw(file_name, prog='dot')
        print('Network drawing saved as {}'.format(file_name))

        try:
            from IPython.display import Image
            return Image(filename=file_name)
        except ImportError:
            return None
    except ImportError as err:
        print("pygraphviz is required for drawing networks but was not found.")
        raise err
Write a diagram for a network to a file.

    Args:
        network (brainstorm.structure.Network): Network to be drawn.
        file_name (Optional[str]): Defaults to 'network.png'.
    Note:
        This tool requires the pygraphviz library to be installed.
    Raises:
        ImportError: If pygraphviz can not be imported.
    
Write a diagram for a network to a file.
Write a diagram for a network to a file .
def draw_network(network, file_name='network.png'):
    try:
        import pygraphviz as pgv
        graph = pgv.AGraph(directed=True)
        for k, v in network.architecture.items():
                for out_view, dest_list in v['@outgoing_connections'].items():
                    for dest in dest_list:
                        graph.add_edge(k, dest.split('.')[0])
        graph.draw(file_name, prog='dot')
        print('Network drawing saved as {}'.format(file_name))
        try:
            from IPython.display import Image
            return Image(filename=file_name)
        except ImportError:
            return None
    except ImportError as err:
        print("pygraphviz is required for drawing networks but was not found.")
        raise err
def draw_network ( network , file_name = 'network.png' ) : try : import pygraphviz as pgv graph = pgv . AGraph ( directed = True ) for k , v in network . architecture . items ( ) : for out_view , dest_list in v [ '@outgoing_connections' ] . items ( ) : for dest in dest_list : graph . add_edge ( k , dest . split ( '.' ) [ 0 ] ) graph . draw ( file_name , prog = 'dot' ) print ( 'Network drawing saved as {}' . format ( file_name ) ) try : from IPython . display import Image return Image ( filename = file_name ) except ImportError : return None except ImportError as err : print ( "pygraphviz is required for drawing networks but was not found." ) raise err
Write a diagram for a network to a file.
Write a diagram for a network to a file .
"""Write a diagram for a network to a file.

    Args:
        network (brainstorm.structure.Network): Network to be drawn.
        file_name (Optional[str]): Defaults to 'network.png'.
    Note:
        This tool requires the pygraphviz library to be installed.
    Raises:
        ImportError: If pygraphviz can not be imported.
    """
If pygraphviz can not be imported.
If pygraphviz can not be imported .
ImportError
network
Network to be drawn.
Network to be drawn .
file_name
Defaults to 'network.png'.
Defaults to ' network . png ' .