Python pygraphviz.AGraph() Examples

The following are 30 code examples of pygraphviz.AGraph(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pygraphviz , or try the search function .
Example #1
Source File: utils.py    From ENAS-pytorch with Apache License 2.0 6 votes vote down vote up
def draw_network(dag, path):
    makedirs(os.path.dirname(path))
    graph = pgv.AGraph(directed=True, strict=True,
                       fontname='Helvetica', arrowtype='open') # not work?

    checked_ids = [-2, -1, 0]

    if -1 in dag:
        add_node(graph, -1, 'x[t]')
    if -2 in dag:
        add_node(graph, -2, 'h[t-1]')

    add_node(graph, 0, dag[-1][0].name)

    for idx in dag:
        for node in dag[idx]:
            if node.id not in checked_ids:
                add_node(graph, node.id, node.name)
                checked_ids.append(node.id)
            graph.add_edge(idx, node.id)

    graph.layout(prog='dot')
    graph.draw(path) 
Example #2
Source File: graph.py    From slpkg with GNU General Public License v3.0 6 votes vote down vote up
def dependencies(self, deps_dict):
        """Generate graph file with depenndencies map tree
        """
        try:
            import pygraphviz as pgv
        except ImportError:
            if self.image == "ascii" and not os.path.isfile("/usr/bin/graph-easy"):
                print("Require 'grap_easy': Install with 'slpkg -s sbo graph-easy'")
            else:
                print("Require 'pygraphviz: Install with 'slpkg -s sbo pygraphviz'")
            raise SystemExit()
        if self.image != "ascii":
            self.check_file()
        try:
            G = pgv.AGraph(deps_dict)
            G.layout(prog="fdp")
            if self.image == "ascii":
                G.write(f"{self.image}.dot")
                self.graph_easy()
            G.draw(self.image)
        except IOError:
            raise SystemExit()
        if os.path.isfile(self.image):
            print(f"Graph image file '{self.image}' created")
        raise SystemExit() 
Example #3
Source File: visual.py    From cyaron with GNU Lesser General Public License v3.0 6 votes vote down vote up
def visualize(graph, output_path="a.png"):
    """visualize(graph, **kwargs) -> None
        Graph/Merger graph -> the graph/Merger that will be visualized
        string output_path-> the output path of the image
    """

    if isinstance(graph, Merger): graph = Merger.G
    G = pgv.AGraph(directed=graph.directed)

    G.add_nodes_from([i for i in xrange(1, len(graph.edges))])
    for edge in graph.iterate_edges():
        G.add_edge(edge.start, edge.end, label=edge.weight)
        
    G.node_attr['shape'] = 'egg'
    G.node_attr['width'] = '0.25'
    G.node_attr['height'] = '0.25'
    G.edge_attr['arrowhead'] = 'open'

    G.layout(prog='dot')
    G.draw(output_path) 
Example #4
Source File: diagrams_pygraphviz.py    From transitions with MIT License 6 votes vote down vote up
def generate(self, title=None):
        """ Generate a DOT graph with pygraphviz, returns an AGraph object """
        if not pgv:  # pragma: no cover
            raise Exception('AGraph diagram requires pygraphviz')

        title = '' if not title else title

        self.fsm_graph = pgv.AGraph(label=title, **self.machine.machine_attributes)
        self.fsm_graph.node_attr.update(self.machine.style_attributes['node']['default'])
        self.fsm_graph.edge_attr.update(self.machine.style_attributes['edge']['default'])
        states, transitions = self._get_elements()
        self._add_nodes(states, self.fsm_graph)
        self._add_edges(transitions, self.fsm_graph)
        setattr(self.fsm_graph, 'style_attributes', self.machine.style_attributes)

        return self.fsm_graph 
Example #5
Source File: util.py    From D-VAE with MIT License 6 votes vote down vote up
def draw_network(g, path, backbone=False):
    graph = pgv.AGraph(directed=True, strict=True, fontname='Helvetica', arrowtype='open')
    if g is None:
        add_node(graph, 0, 0)
        graph.layout(prog='dot')
        graph.draw(path)
        return
    for idx in range(g.vcount()):
        add_node(graph, idx, g.vs[idx]['type'])
    for idx in range(g.vcount()):
        for node in g.get_adjlist(igraph.IN)[idx]:
            if node == idx-1 and backbone:
                graph.add_edge(node, idx, weight=1)
            else:
                graph.add_edge(node, idx, weight=0)
    graph.layout(prog='dot')
    graph.draw(path) 
Example #6
Source File: overlap.py    From cc-crawl-statistics with Apache License 2.0 6 votes vote down vote up
def plot_similarity_graph(self, show_edges=False):
        '''(trial) visualize similarity using GraphViz'''
        g = pygraphviz.AGraph(directed=False, overlap='scale', splines=True)
        g.node_attr['shape'] = 'plaintext'
        g.node_attr['fontsize'] = '12'
        if show_edges:
            g.edge_attr['color'] = 'lightgrey'
            g.edge_attr['fontcolor'] = 'grey'
            g.edge_attr['fontsize'] = '8'
        else:
            g.edge_attr['style'] = 'invis'
        for crawl1 in sorted(self.similarity['url']):
            for crawl2 in sorted(self.similarity['url'][crawl1]):
                similarity = self.similarity['url'][crawl1][crawl2]
                distance = 1.0 - similarity
                g.add_edge(MonthlyCrawl.short_name(crawl1),
                           MonthlyCrawl.short_name(crawl2),
                           len=(distance),
                           label='{0:.2f}'.format(distance))
        g.write(os.path.join(PLOTDIR, 'crawlsimilarity_url.dot'))
        g.draw(os.path.join(PLOTDIR, 'crawlsimilarity_url.svg'), prog='fdp') 
Example #7
Source File: visualize_tree.py    From nix-visualize with Apache License 2.0 6 votes vote down vote up
def _get_edges_and_nodes(self, raw_lines):
        """Transform a raw GraphViz file into Node and Edge objects.  Note
        that at this point the nodes and edges are not linked into a graph
        they are simply two lists of items."""

        tempf = tempfile.NamedTemporaryFile(delete=False)
        tempf.write(raw_lines)
        tempf.close()
        G = pgv.AGraph(tempf.name)

        all_edges = []
        all_nodes = []

        for node in G.nodes():
            if (util.remove_nix_hash(node.name) not
                in [n.name for n in all_nodes]):
                all_nodes.append(Node(node.name))

        for edge in G.edges():
            all_edges.append(Edge(edge[0], edge[1]))

        return all_nodes, all_edges 
Example #8
Source File: graphviz.py    From panflute with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def graphviz(elem, doc):
    if type(elem) == CodeBlock and 'graphviz' in elem.classes:
        code = elem.text
        caption = "caption"
        G = pygraphviz.AGraph(string=code)
        G.layout()
        filename = sha1(code)
        filetype = {'html': 'png', 'latex': 'pdf'}.get(doc.format, 'png')
        alt = Str(caption)
        src = imagedir + '/' + filename + '.' + filetype
        if not os.path.isfile(src):
            try:
                os.mkdir(imagedir)
                sys.stderr.write('Created directory ' + imagedir + '\n')
            except OSError:
                pass
            G.draw(src)
            sys.stderr.write('Created image ' + src + '\n')
        return Para(Image(alt, url=source, title='')) 
Example #9
Source File: diagrams.py    From jarvis with GNU General Public License v2.0 6 votes vote down vote up
def get_graph(self, title=None):
        """ Generate a DOT graph with pygraphviz, returns an AGraph object
        Args:
            title (string): Optional title for the graph.
        """
        if not pgv:  # pragma: no cover
            raise Exception('AGraph diagram requires pygraphviz')

        if title is False:
            title = ''

        fsm_graph = pgv.AGraph(label=title, compound=True, **self.machine_attributes)
        fsm_graph.node_attr.update(self.style_attributes['node']['default'])
        fsm_graph.edge_attr.update(self.style_attributes['edge']['default'])

        # For each state, draw a circle
        self._add_nodes(self.machine.states, fsm_graph)
        self._add_edges(self.machine.events.copy(), fsm_graph)

        setattr(fsm_graph, 'style_attributes', self.style_attributes)

        return fsm_graph 
Example #10
Source File: test_intermediary_to_dot.py    From eralchemy with Apache License 2.0 6 votes vote down vote up
def assert_is_dot_format(dot):
    """ Checks that the dot is usable by graphviz. """

    # We launch a process calling graphviz to render the dot. If the exit code is not 0 we assume that the syntax
    # wasn't good
    def run_graph(dot):
        """ Runs graphviz to see if the syntax is good. """
        graph = AGraph()
        graph = graph.from_string(dot)
        extension = 'png'
        graph.draw(path='output.png', prog='dot', format=extension)
        sys.exit(0)

    p = Process(target=run_graph, args=(dot,))
    p.start()
    p.join()
    assert p.exitcode == 0 
Example #11
Source File: assembler.py    From indra with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def __init__(self, stmts=None, graph_properties=None,
                 node_properties=None, edge_properties=None):
        if stmts is None:
            self.statements = []
        else:
            self.statements = stmts
        self.graph_properties = default_graph_properties
        self.node_properties = default_node_properties
        self.edge_properties = default_edge_properties
        if graph_properties:
            for k, v in graph_properties.items():
                self.graph_properties[k] = v
        if node_properties:
            for k, v in node_properties.items():
                self.node_properties[k] = v
        if edge_properties:
            for k, v in edge_properties.items():
                self.edge_properties[k] = v
        self.graph = pygraphviz.AGraph(**self.graph_properties)
        self.existing_nodes = []
        self.existing_edges = []
        self._complex_nodes = [] 
Example #12
Source File: traversals.py    From code-for-blog with The Unlicense 6 votes vote down vote up
def render(self, filename='graph.png'):
        """Render the graph to a PNG file using pygraphviz.

        filename: name of the output file.

        To use this method, pygraphviz has to be installed.
        """
        try:
            import pygraphviz as pgv
            agv = pgv.AGraph(directed=True, strict=False)
            for u in self.edges:
                for v in self.edges[u]:
                    agv.add_edge(u, v)
            agv.layout('dot')
            agv.draw(filename)
            print('Rendered graph to "{0}"'.format(filename))
        except ImportError as e:
            print('Unable to import pygraphviz - not rendering')
            print(e) 
Example #13
Source File: diagrams.py    From jarvis with GNU General Public License v2.0 5 votes vote down vote up
def set_edge_style(graph, edge, style='default'):
        """ Sets the style of an edge.
        Args:
            graph (AGraph): Graph containing the relevant styling attributes.
            edge (Edge): Edge to be altered.
            style (str): Style name (Should be part of the edge style_attributes in Graph).
        """
        style_attr = graph.style_attributes.get('edge', {}).get(style)
        edge.attr.update(style_attr) 
Example #14
Source File: render_spec_with_graphviz.py    From object_detection_with_tensorflow with MIT License 5 votes vote down vote up
def master_spec_graph(master_spec):
  """Constructs a master spec graph.

  Args:
    master_spec: MasterSpec proto.

  Raises:
    TypeError, if master_spec is not the right type. N.B. that this may be
    raised if you import proto classes in non-standard ways (e.g. dynamically).

  Returns:
    SVG graph contents as a string.
  """
  if not isinstance(master_spec, spec_pb2.MasterSpec):
    raise TypeError("master_spec_graph() expects a MasterSpec input.")

  graph = pygraphviz.AGraph(directed=True)

  graph.node_attr.update(
      shape="box",
      style="filled",
      fillcolor="white",
      fontname="roboto, helvetica, arial",
      fontsize=11)
  graph.edge_attr.update(fontname="roboto, helvetica, arial", fontsize=11)

  for component in master_spec.component:
    graph.add_node(component.name, label=_component_contents(component))

  for component in master_spec.component:
    for linked_feature in component.linked_feature:
      graph.add_edge(
          linked_feature.source_component,
          component.name,
          label=_linked_feature_label(linked_feature))

  with warnings.catch_warnings():
    # Fontconfig spews some warnings, suppress them for now. (Especially because
    # they can clutter IPython notebooks).
    warnings.simplefilter("ignore")
    return graph.draw(format="svg", prog="dot") 
Example #15
Source File: diagrams.py    From jarvis with GNU General Public License v2.0 5 votes vote down vote up
def set_edge_state(self, graph, edge_from, edge_to, state='default', label=None):
        """ Retrieves/creates an edge between two states and changes the style/label.
        Args:
            graph (AGraph): The graph to be changed.
            edge_from (str): Source state of the edge.
            edge_to (str): Destination state of the edge.
            state (str): Style name (Should be part of the node style_attributes in Graph)
            label (str): Label of the edge.
        """
        # If show_auto_transitions is True, there will be an edge from 'edge_from' to 'edge_to'.
        # This test is considered faster than always calling 'has_edge'.
        if not self.show_auto_transitions and not graph.has_edge(edge_from, edge_to):
            graph.add_edge(edge_from, edge_to, label)
        edge = graph.get_edge(edge_from, edge_to)
        self.set_edge_style(graph, edge, state) 
Example #16
Source File: diagrams.py    From jarvis with GNU General Public License v2.0 5 votes vote down vote up
def get_combined_graph(self, title=None, force_new=False, show_roi=False):
        """ This method is currently equivalent to 'get_graph' of the first machine's model.
        In future releases of transitions, this function will return a combined graph with active states
        of all models.
        Args:
            title (str): Title of the resulting graph.
            force_new (bool): If set to True, (re-)generate the model's graph.
            show_roi (bool): If set to True, only render states that are active and/or can be reached from
                the current state.
        Returns: AGraph of the first machine's model.
        """
        _LOGGER.info('Returning graph of the first model. In future releases, this ' +
                     'method will return a combined graph of all models.')
        return self._get_graph(self.models[0], title, force_new, show_roi) 
Example #17
Source File: diagrams.py    From jarvis with GNU General Public License v2.0 5 votes vote down vote up
def set_graph_style(graph, item, style='default'):
        """ Sets the style of a (sub)graph/cluster.
        Args:
            graph (AGraph): Graph containing the relevant styling attributes.
            item (AGraph): Item to be altered.
            style (str): Style name (Should be part of the graph style_attributes in Graph).
        """
        style_attr = graph.style_attributes.get('graph', {}).get(style)
        item.graph_attr.update(style_attr) 
Example #18
Source File: diagrams.py    From jarvis with GNU General Public License v2.0 5 votes vote down vote up
def reset_graph_style(self, graph):
        """ This method resets the style of edges, nodes, and subgraphs to the 'default' parameters.
        Args:
            graph (AGraph): The graph to be reset.
        """
        # Reset all the edges
        for edge in graph.edges_iter():
            self.set_edge_style(graph, edge, 'default')
        for node in graph.nodes_iter():
            if 'point' not in node.attr['shape']:
                self.set_node_style(graph, node, 'default')
        for sub_graph in graph.subgraphs_iter():
            self.set_graph_style(graph, sub_graph, 'default') 
Example #19
Source File: diagrams.py    From jarvis with GNU General Public License v2.0 5 votes vote down vote up
def _get_subgraph(graph, name):
    """ Searches for subgraphs in a graph.
    Args:
        g (AGraph): Container to be searched.
        name (str): Name of the cluster.
    Returns: AGraph if a cluster called 'name' exists else None
    """
    sub_graph = graph.get_subgraph(name)
    if sub_graph:
        return sub_graph
    for sub in graph.subgraphs_iter():
        sub_graph = _get_subgraph(sub, name)
        if sub_graph:
            return sub_graph
    return None 
Example #20
Source File: pysdf.py    From director with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def plot_to_file(self, plot_filename):
    import pygraphviz as pgv
    graph = pgv.AGraph(directed=True)
    self.plot(graph)
    graph.draw(plot_filename, prog='dot') 
Example #21
Source File: render_spec_with_graphviz.py    From hands-detection with MIT License 5 votes vote down vote up
def master_spec_graph(master_spec):
  """Constructs a master spec graph.

  Args:
    master_spec: MasterSpec proto.

  Raises:
    TypeError, if master_spec is not the right type. N.B. that this may be
    raised if you import proto classes in non-standard ways (e.g. dynamically).

  Returns:
    SVG graph contents as a string.
  """
  if not isinstance(master_spec, spec_pb2.MasterSpec):
    raise TypeError("master_spec_graph() expects a MasterSpec input.")

  graph = pygraphviz.AGraph(directed=True)

  graph.node_attr.update(
      shape="box",
      style="filled",
      fillcolor="white",
      fontname="roboto, helvetica, arial",
      fontsize=11)
  graph.edge_attr.update(fontname="roboto, helvetica, arial", fontsize=11)

  for component in master_spec.component:
    graph.add_node(component.name, label=_component_contents(component))

  for component in master_spec.component:
    for linked_feature in component.linked_feature:
      graph.add_edge(
          linked_feature.source_component,
          component.name,
          label=_linked_feature_label(linked_feature))

  with warnings.catch_warnings():
    # Fontconfig spews some warnings, suppress them for now. (Especially because
    # they can clutter IPython notebooks).
    warnings.simplefilter("ignore")
    return graph.draw(format="svg", prog="dot") 
Example #22
Source File: module_graphbuilder.py    From ICSREF with MIT License 5 votes vote down vote up
def graphbuilder(self, args):
    """Create visualization of program callgraph using graphviz
        
    No args

    :Example:
    
        reversing\@icsref:$ graphbuilder
    
    """
    self.do_cleanup(None)
    try:
        prg = self.prg
    except AttributeError:
        print('Error: You need to first load or analyze a program')
        return 0

    name = prg.name
    functions = prg.Functions
    for fun in functions:
        fun_f = os.path.join('results', prg.name, fun.name + '.disasm')
        with open(fun_f, 'w') as f:
            f.write('\n'.join(fun.disasm))
    G=pgv.AGraph(strict = True, directed = True, ranksep='2')
    G.node_attr['shape']='box'
    for fun in functions:
        G.add_node(fun.name, URL='{}.disasm'.format(fun.name))
    for fun in functions:
        for lib in fun.calls.keys():
            if lib in prg.statlibs_dict.values():
                G.add_edge(fun.name, lib, color='blue', label=fun.calls[lib])
            else:
                G.add_edge(fun.name, lib, color='red', label=fun.calls[lib])
    G.layout(prog='dot')
    graph_f = 'graph_{}.svg'.format(name)
    G.draw(graph_f)
    os.rename(graph_f, os.path.join('results', prg.name, graph_f))
    print('Generated graph_{}.svg'.format(name))
    return 0 
Example #23
Source File: nx_agraph.py    From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 5 votes vote down vote up
def read_dot(path):
    """Return a NetworkX graph from a dot file on path.

    Parameters
    ----------
    path : file or string
       File name or file handle to read.
    """
    try:
        import pygraphviz
    except ImportError:
        raise ImportError('read_dot() requires pygraphviz ',
                          'http://pygraphviz.github.io/')
    A=pygraphviz.AGraph(file=path)
    return from_agraph(A) 
Example #24
Source File: _base.py    From sumpy with Apache License 2.0 5 votes vote down vote up
def print_dependency_graph(self, filename=None, to_iPython=True):
        import pygraphviz as pgv
        if not hasattr(self, "_dependency_graph") or \
                self._dependency_graph is None:
            self.build_dependency_graph()

        if filename is None:
            filename = "sumpy.tmp.png"

        G = pgv.AGraph(strict=False, directed=True) 
        for node in self._dependency_graph:
            if node in self._annotators:
                G.add_node(node)
                G.get_node(node).attr["shape"] ="rectangle"
            elif node.startswith("f:"):
                G.add_node(node)
                G.get_node(node).attr["shape"] ="parallelogram"
                for edge in self._dependency_graph.in_edges(node):
                    G.add_edge(edge[0], edge[1], color="green")
            else:
                for in_edge in self._dependency_graph.in_edges(node):
                    for out_edge in self._dependency_graph.out_edges(node):
                        G.add_edge(in_edge[0], out_edge[1], 
                                   label=node, key=node)

        G.layout("dot")
        G.draw(filename)
        if to_iPython is True:
            from IPython.display import Image 
            return Image(filename=filename) 
Example #25
Source File: graphPlotter.py    From fc00.org with GNU General Public License v3.0 5 votes vote down vote up
def position_nodes(nodes, edges):
	G = pgv.AGraph(strict=True, directed=False, size='10!')

	for n in nodes.values():
		G.add_node(n.ip, label=n.label, version=n.version)

	for e in edges:
		G.add_edge(e.a.ip, e.b.ip, len=1.0)

	G.layout(prog='neato', args='-Gepsilon=0.0001 -Gmaxiter=100000')

	return G 
Example #26
Source File: red_black_tree.py    From wangzheng0822-algo with Apache License 2.0 5 votes vote down vote up
def draw_img(self, img_name='Red_Black_Tree.png'):
        """
        画图
        用pygraphviz画出节点和箭头
        箭头的红色和黑色分别代表左和右
        :param img_name:
        :return:
        """
        if self.root is None:
            return

        tree = pgv.AGraph(directed=True, strict=True)

        q = Queue()
        q.put(self.root)

        while not q.empty():
            n = q.get()
            if n != self.black_leaf:  # 黑色叶子的连线由各个节点自己画
                tree.add_node(n.val, color=n.color)
                #  画父节点箭头
                # if n.parent is not None:
                #     tree.add_edge(n.val, n.parent.val)

                for c in [n.left, n.right]:
                    q.put(c)
                    color = 'red' if c == n.left else 'black'
                    if c != self.black_leaf:
                        tree.add_edge(n.val, c.val, color=color)
                    else:
                        tree.add_edge(n.val, 'None', color=color)

        tree.graph_attr['epsilon'] = '0.01'
        tree.layout('dot')
        tree.draw(OUTPUT_PATH + img_name)
        return True 
Example #27
Source File: trie_.py    From wangzheng0822-algo with Apache License 2.0 5 votes vote down vote up
def draw_img(self, img_name='Trie.png'):
        """
        画出trie树
        :param img_name:
        :return:
        """
        if self.root is None:
            return

        tree = pgv.AGraph('graph foo {}', strict=False, directed=False)

        # root
        nid = 0
        color = 'black'
        tree.add_node(nid, color=color, label='None')

        q = Queue()
        q.put((self.root, nid))
        while not q.empty():
            n, pid = q.get()
            for c in n.children:
                nid += 1
                q.put((c, nid))
                color = 'red' if c.is_ending_char is True else 'black'
                tree.add_node(nid, color=color, label=c.data)
                tree.add_edge(pid, nid)

        tree.graph_attr['epsilon'] = '0.01'
        tree.layout('dot')
        tree.draw(OUTPUT_PATH + img_name)
        return True 
Example #28
Source File: nx_agraph.py    From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 5 votes vote down vote up
def display_pygraphviz(graph, path, format=None, prog=None, args=''):
    """Internal function to display a graph in OS dependent manner.

    Parameters
    ----------
    graph : PyGraphviz graph
        A PyGraphviz AGraph instance.
    path :  file object
        An already opened file object that will be closed.
    format : str, None
        An attempt is made to guess the output format based on the extension
        of the filename. If that fails, the value of `format` is used.
    prog : string
        Name of Graphviz layout program.
    args : str
        Additional arguments to pass to the Graphviz layout program.

    Notes
    -----
    If this function is called in succession too quickly, sometimes the
    image is not displayed. So you might consider time.sleep(.5) between
    calls if you experience problems.

    """
    if format is None:
        filename = path.name
        format = os.path.splitext(filename)[1].lower()[1:]
    if not format:
        # Let the draw() function use its default
        format = None

    # Save to a file and display in the default viewer.
    # We must close the file before viewing it.
    graph.draw(path, format, prog, args)
    path.close()
    nx.utils.default_opener(filename)

# fixture for nose tests 
Example #29
Source File: draw.py    From TrustTrees with Apache License 2.0 5 votes vote down vote up
def _draw_graph_from_cache(target_hostname):
    """
    Iterates through MASTER_DNS_CACHE, and calls _get_graph_data_for_ns_result()

    :returns: string
    For pygraphviz.AGraph()
    """
    graph_data = (
        f"""
        digraph G {{
        graph [
            label=\"{target_hostname} DNS Trust Graph\",
            labelloc="t",
            pad="3",
            nodesep="1",
            ranksep="5",
            fontsize=50
        ];
        edge[arrowhead=vee, arrowtail=inv, arrowsize=.7]
        concentrate=true;
        """
    )

    for cache_key, ns_result in global_state.MASTER_DNS_CACHE.items():
        print(f"[ STATUS ] Building '{cache_key}'...")
        for section_of_NS_answer in (
            'additional_ns',
            'authority_ns',
            'answer_ns',
        ):
            graph_data += _get_graph_data_for_ns_result(
                ns_list=ns_result[section_of_NS_answer],
                ns_result=ns_result,
            )

    graph_data += '\n}'
    return graph_data 
Example #30
Source File: tuto_1_4.py    From doit with MIT License 5 votes vote down vote up
def module_to_dot(imports, targets):
    graph = pygraphviz.AGraph(strict=False, directed=True)
    graph.node_attr['color'] = 'lightblue2'
    graph.node_attr['style'] = 'filled'
    for source, sinks in imports.items():
        for sink in sinks:
            graph.add_edge(source, sink)
    graph.write(targets[0])