Convert the dependency graph (DepGraph class) to dot source code.
967228
def depgraph_to_dotsrc(dep_graph, show_cycles, nodot, reverse):
    
    if show_cycles:
        dotsrc = cycles2dot(dep_graph, reverse=reverse)
    elif not nodot:
        dotsrc = dep2dot(dep_graph, reverse=reverse)
    else:
        dotsrc = None
    return dotsrc
183751
def slithir_cfg_to_dot(self, filename):
        
        from slither.core.cfg.node import NodeType
        with open(filename, 'w', encoding='utf8') as f:
            f.write('digraph{\n')
            for node in self.nodes:
                label = 'Node Type: {} {}\n'.format(NodeType.str(node.type), node.node_id)
                if node.expression:
                    label += '\nEXPRESSION:\n{}\n'.format(node.expression)
                if node.irs:
                    label += '\nIRs:\n' + '\n'.join([str(ir) for ir in node.irs])
                f.write('{}[label="{}"];\n'.format(node.node_id, label))
                for son in node.sons:
                    f.write('{}->{};\n'.format(node.node_id, son.node_id))

            f.write("}\n")
281342
def intermediary_to_dot(tables, relationships, output):
    
    dot_file = _intermediary_to_dot(tables, relationships)
    with open(output, "w") as file_out:
        file_out.write(dot_file)
969256
public function getDotGraph() : string {
		$escapeClassName = function(string $class) : string {
			return '"' . \str_replace('\\', '\\\\', $class) . '"';
		};

		$dotData = 'digraph modules {' . PHP_EOL;
		foreach ($this->modules as $moduleSpec) {
			$module = $moduleSpec['object'];
			if ($module instanceof OrderAwareModule) {
				foreach ($module->getModulesBefore() as $moduleBeforeClass) {
					$dotData .= '    ' . $escapeClassName($moduleBeforeClass) . ' -> ' .
						$escapeClassName($moduleSpec['class']) . ';' . PHP_EOL;
				}
				foreach ($module->getModulesAfter() as $moduleAfterClass) {
					$dotData .= '    ' . $escapeClassName($moduleSpec['class']) . ' -> ' .
						$escapeClassName($moduleAfterClass) . ';' . PHP_EOL;
				}
			} else {
				$dotData .= '    ' . $escapeClassName($moduleSpec['class']) . ';' . PHP_EOL;
			}
		}
		$dotData .= '}';

		return $dotData;
	}
26908
function preprocessSourceMap(sourceMap) {
      if (typeof sourceMap === 'string') {
        sourceMap = JSON.parse(sourceMap);
      }
      if (sourceMap && Array.isArray(sourceMap.sources)) {
        sourceMap.sources = sourceMap.sources.map(sourceUrl =>
          urlTools.resolveUrl(assetGraph.root, sourceUrl.replace(/^\//, ''))
        );
      }
      return sourceMap;
    }
1104435
def get_pydot_graph(self):
        """"""
        rel = "is_a"
        # Initialize empty dag
        dag = pydot.Dot(graph_type='digraph', **self.kws['dag'])
        # Initialize nodes
        go2node = self._get_go2pydotnode()
        # Add nodes to graph
        for node in go2node.values():
            dag.add_node(node)
        # Add edges to graph
        rel2edgekws = self.rel2edgekws
        self.edgesobj.chk_edges()
        edgekws = rel2edgekws.get(rel)
        self._add_edges(self.edgesobj.edges, go2node, dag, **edgekws)
        for reltype, edges_list in self.edgesobj.edges_rel.items():
            edgekws = rel2edgekws.get(reltype)
            self._add_edges(edges_list, go2node, dag, **edgekws)
        return dag
172517
def dot_format(out, graph, name="digraph"):
    """"""

    out.write("digraph %s {\n" % name)
    for step, deps in each_step(graph):
        for dep in deps:
            out.write("  \"%s\" -> \"%s\";\n" % (step, dep))

    out.write("}\n")
1058936
def _maintain_dep_graph(self, p_todo):
        
        dep_id = p_todo.tag_value('id')
        # maintain dependency graph
        if dep_id:
            self._parentdict[dep_id] = p_todo
            self._depgraph.add_node(hash(p_todo))

            # connect all tasks we have in memory so far that refer to this
            # task
            for dep in \
                    [dep for dep in self._todos if dep.has_tag('p', dep_id)]:

                self._add_edge(p_todo, dep, dep_id)

        for dep_id in p_todo.tag_values('p'):
            try:
                parent = self._parentdict[dep_id]
                self._add_edge(parent, p_todo, dep_id)
            except KeyError:
                pass
714572
def nx_graph_from_dotfile(filename: str) -> nx.DiGraph:
    
    return nx.DiGraph(read_dot(filename).reverse())
114530
def _resolve_deps(self, depmap):
    """"""
    deps = defaultdict(lambda: OrderedSet())
    for category, depspecs in depmap.items():
      dependencies = deps[category]
      for depspec in depspecs:
        dep_address = Address.parse(depspec)
        try:
          self.context.build_graph.maybe_inject_address_closure(dep_address)
          dependencies.add(self.context.build_graph.get_target(dep_address))
        except AddressLookupError as e:
          raise AddressLookupError('{}\n  referenced from {} scope'.format(e, self.options_scope))
    return deps
468166
function graphvizualize(data, cb) {
  var cp = exec('dot -Tsvg');

  // buffer stdout
  var buf = '';
  cp.stdout.on('data', function (data) {
    buf += data;
  });
  cp.on('error', function () {});
  cp.on('close', function (code) {
    cb(null, code > 0 ? '' : buf);
  });

  // set dot to stdin
  cp.stdin.end(data);
}
735893
def printDot(self):
        """"""
        print("digraph ModuleDependencies {")
        print("  node[shape=box];")
        allNames = set()
        nameDict = {}
        for n, module in enumerate(self.listModules()):
            module._dot_name = "mod%d" % n
            nameDict[module.modname] = module._dot_name
            print("  %s[label=\"%s\"];" % (module._dot_name,
                                           quote(module.label)))
            allNames |= module.imports
        print("  node[style=dotted];")
        if self.external_dependencies:
            myNames = set(self.modules)
            extNames = list(allNames - myNames)
            extNames.sort()
            for n, name in enumerate(extNames):
                nameDict[name] = id = "extmod%d" % n
                print("  %s[label=\"%s\"];" % (id, name))
        for modname, module in sorted(self.modules.items()):
            for other in sorted(module.imports):
                if other in nameDict:
                    print("  %s -> %s;" % (nameDict[module.modname],
                                           nameDict[other]))
        print("}")
704610
def _get_dep_to_dot_name_mapping(dependencies):
        
        dot_name_to_deps = {}
        for dep in dependencies:
            dot_name = dep.name

            if dot_name not in dot_name_to_deps:
                dot_name_to_deps[dot_name] = [dep]
            else:
                dot_name_to_deps[dot_name].append(dep)

        dep_to_dot_name = {}
        for dot_name, deps in dot_name_to_deps.items():
            if len(deps) == 1:
                dep_to_dot_name[deps[0]] = dot_name
                continue

            for idx, dep in enumerate(deps):
                dep_to_dot_name[dep] = dot_name + str(idx)

        return dep_to_dot_name
52871
private Collection<Key<?>> getRequiredSourcesTargeting(
      DependencyGraph graph, Iterable<Key<?>> targets) {
    Collection<Key<?>> requiredSources = new LinkedHashSet<Key<?>>();
    for (Key<?> target : targets) {
      for (Dependency edge : graph.getDependenciesTargeting(target)) {
        if (!edge.isOptional()) {
          PrettyPrinter.log(logger, TreeLogger.DEBUG, "Removing the key %s because of %s",
              edge.getSource(), edge);
          requiredSources.add(edge.getSource());
        }
      }
    }
    return requiredSources;
  }
357798
def py2dep(target, **kw):
    "
    log.info("py2dep(%r)", target)
    dummy = DummyModule(target, **kw)

    kw['dummyname'] = dummy.fname
    syspath = sys.path[:]
    syspath.insert(0, target.syspath_dir)

    # remove exclude so we don't pass it twice to modulefinder
    exclude = ['migrations'] + kw.pop('exclude', [])
    log.debug("Exclude: %r", exclude)
    log.debug("KW: %r", kw)
    if 'fname' in kw:
        del kw['fname']

    mf = MyModuleFinder(
        syspath,                # module search path for this module finder
        excludes=exclude,       # folders to exclude
        **kw
    )
    mf.debug = max(mf.debug, kw.get('debug_mf', 0))
    log.debug("CURDIR: %s", os.getcwd())
    log.debug("FNAME: %r, CONTENT:\n%s\n", dummy.fname, dummy.text())
    mf.run_script(dummy.fname)

    log.info("mf._depgraph:\n%s", json.dumps(dict(mf._depgraph), indent=4))
    log.info("mf.badmodules:\n%s", json.dumps(mf.badmodules, indent=4))

    if kw.get('include_missing'):
        for k, vdict in list(mf.badmodules.items()):
            if k not in mf._depgraph:
                mf._depgraph[k] = {}
            for v in vdict:
                if v not in mf._depgraph['__main__']:
                    mf._depgraph['__main__'][v] = None
                if v in mf._depgraph:
                    mf._depgraph[v][k] = None
                else:
                    mf._depgraph[v] = {k:None}

    log.info("mf._depgraph:\n%s", json.dumps(dict(mf._depgraph), indent=4))

    kw['exclude'] = exclude

    if kw.get('pylib'):
        mf_depgraph = mf._depgraph
        for k, v in list(mf._depgraph.items()):
            log.debug('depgraph item: %r %r', k, v)
        # mf_modules = {k: os.syspath.abspath(v.__file__)
        #               for k, v in mf.modules.items()}
    else:
        pylib = pystdlib()
        mf_depgraph = {}
        for k, v in list(mf._depgraph.items()):
            log.debug('depgraph item: %r %r', k, v)
            if k in pylib:
                continue
            vals = {vk: vv for vk, vv in list(v.items()) if vk not in pylib}
            mf_depgraph[k] = vals

        # mf_modules = {k: os.syspath.abspath(v.__file__)
        #               for k, v in mf.modules.items()
        #               if k not in pylib}

    try:
        import yaml
        log.info("mf_depgraph:\n%s",
                 yaml.dump(dict(mf_depgraph), default_flow_style=False))
        # log.error("mf._types:\n%s", yaml.dump(mf._types, default_flow_style=False))
        # log.debug("mf_modules:\n%s", yaml.dump(mf_modules, default_flow_style=False))
    except ImportError:
        log.info("mf_depgraph:\n%s", json.dumps(dict(mf_depgraph), indent=4))

    return depgraph.DepGraph(mf_depgraph, mf._types, **kw)
437104
def method2format(output, _format="png", mx=None, raw=None):
    
    # pydot is optional!
    import pydot

    buff = "digraph {\n"
    buff += "graph [rankdir=TB]\n"
    buff += "node [shape=plaintext]\n"

    if raw:
        data = raw
    else:
        data = method2dot(mx)

    # subgraphs cluster
    buff += "subgraph cluster_{} ".format(hashlib.md5(bytearray(output, "UTF-8")).hexdigest())
    buff += "{\n"
    buff += "label=\"{}\"\n".format(data['name'])
    buff += data['nodes']
    buff += "}\n"

    # subgraphs edges
    buff += data['edges']
    buff += "}\n"

    d = pydot.graph_from_dot_data(buff)
    if d:
        for g in d:
            getattr(g, "write_" + _format.lower())(output)
1085686
def to_dot(self):
        
        from graphviz import Digraph
        dot = Digraph(format='png')
        for state in self.states:
            if isinstance(state, TransientState):
                dot.node(state.state_id, style='dashed')
            else:
                dot.node(state.state_id)
            for transition in state.transition_set:
                dot.edge(state.state_id, transition.output.state_id, transition.label())
        return dot