Debug: Dump plain text representation of the graph hierarchy
761980
public function dumpNodeTree(NestedGraph $graph, $indent = "", $withEdges = true)
	{
		if ($withEdges) {
			foreach ($graph->getEdges() as $edge) {
				echo $indent, "- ", $edge->getId(), ' (', $edge->getStart()->getId(), ' -> ', $edge->getEnd()->getId(), ")\n";
			}
		}

		foreach ($graph->getNodes() as $node) {
			echo $indent, "* ", $node->getId(), "\n";
			if ($node->hasNestedGraph()) {
				$this->dumpNodeTree($node->getNestedGraph(), $indent . "\t");
			}
		}
	}
1173617
def edges_dump(self):
        """"""
        self._flush_edges()
        for (
                graph, orig, dest, idx, branch, turn, tick, extant
        ) in self.sql('edges_dump'):
            yield (
                self.unpack(graph),
                self.unpack(orig),
                self.unpack(dest),
                idx,
                branch,
                turn,
                tick,
                bool(extant)
            )
385550
def packageGraph(self, packagelevel=None):
        """"""
        packages = {}
        for module in self.listModules():
            package_name = self.packageOf(module.modname, packagelevel)
            if package_name not in packages:
                dirname = os.path.dirname(module.filename)
                packages[package_name] = Module(package_name, dirname)
            package = packages[package_name]
            for name in module.imports:
                package_name = self.packageOf(name, packagelevel)
                if package_name != package.modname: # no loops
                    package.imports.add(package_name)
        graph = ModuleGraph()
        graph.modules = packages
        return graph
698909
def _draw_ascii_graph(self, field):
        ''''''
        row_strings = []
        for y in range(len(field[0])):
            row = ''
            for x in range(len(field)):
                row += field[x][y]
            row_strings.insert(0, row)
        graph_string = '\n'.join(row_strings)
        return graph_string
857035
def graph_child(output:)
      output << graph_mynode
      if has_child?
        @child.graph_child(output: output)
        output << "#{__id__} -> #{@child.__id__}"
      end
      if has_awaited?
        awaited.each do |awaitable|
          if awaitable.is_a?(Delayer::Deferred::Deferredable::Chainable)
            awaitable.ancestor.graph_child(output: output)
          else
            label = "#{awaitable.class}"
            output << "#{awaitable.__id__} [shape=oval,label=#{label.inspect}]"
          end
          output << "#{awaitable.__id__} -> #{__id__} [label = \"await\", style = \"dotted\"]"
        end
      end
      nil
    end
1237963
def node_val_dump(self):
        """"""
        self._flush_node_val()
        for (
                graph, node, key, branch, turn, tick, value
        ) in self.sql('node_val_dump'):
            yield (
                self.unpack(graph),
                self.unpack(node),
                self.unpack(key),
                branch,
                turn,
                tick,
                self.unpack(value)
            )
1277246
private void dumpNode(Node node, int level, int idx, java.io.PrintStream out) {

        // if node null, then return
        if (node == null) {
            return;
        }

        // print out required spaces
        printSpaces(level, out);

        if (idx == -2) {
            out.print("ROOT -> ");
        } else {
            out.print(idx + " -> ");
        }

        // print out the values
        out.print("S: ");
        if (node.getSpecificValue() != null) {
            out.print(node.getSpecificValue().toString());
        } else {
            out.print("(null)");
        }
        out.print(", W: ");
        if (node.getPrefixValue() != null) {
            out.println(node.getPrefixValue().toString());
        } else {
            out.println("(null)");
        }

        // loop through each child node
        for (int index = 0; index < 10; index++) {
            // dump out this node...
            dumpNode(node.getNode(index), level + 1, index, out);
        }
    }
1341054
function generateLiteralStringChunksFromNode(node, sourceCode) {
  return node.expressions.reduce((chunks, expression, index) => {
    const start = index ? node.expressions[index - 1].end : node.start

    chunks.push(sourceCode.substring(start, expression.start))

    // add the tail to the string
    if (index === node.expressions.length - 1)
      chunks.push(sourceCode.substring(expression.end, node.end))

    return chunks
  }, []).map(str => node.unescape ? unescapeChar(str, node.unescape) : str)
}
1242785
def serialize(graph: BELGraph, csv, sif, gsea, graphml, json, bel):
    """"""
    if csv:
        log.info('Outputting CSV to %s', csv)
        to_csv(graph, csv)

    if sif:
        log.info('Outputting SIF to %s', sif)
        to_sif(graph, sif)

    if graphml:
        log.info('Outputting GraphML to %s', graphml)
        to_graphml(graph, graphml)

    if gsea:
        log.info('Outputting GRP to %s', gsea)
        to_gsea(graph, gsea)

    if json:
        log.info('Outputting JSON to %s', json)
        to_json_file(graph, json)

    if bel:
        log.info('Outputting BEL to %s', bel)
        to_bel(graph, bel)
387439
function dump($show_attr = true, $deep = 0)
    {
        $lead = str_repeat('	', $deep);

        echo $lead . $this->tag;
        if ($show_attr && count($this->attr) > 0) {
            echo '(';
            foreach ($this->attr as $k => $v) {
                echo "[$k]=>\"" . $this->$k . '", ';
            }
            echo ')';
        }
        echo "\n";

        if ($this->nodes) {
            foreach ($this->nodes as $c) {
                $c->dump($show_attr, $deep + 1);
            }
        }
    }
116740
def _debugGraph(self):
        """"""
        print("Len of graph: ", len(self.rdflib_graph))
        for x, y, z in self.rdflib_graph:
            print(x, y, z)
125503
def render_graph(result, cfg, **kwargs):
    
    # Mapping from MIME types to formats accepted by RDFlib
    rdflib_formats = {'text/rdf+n3': 'n3',
                      'text/turtle': 'turtle',
                      'application/x-turtle': 'turtle',
                      'text/turtle': 'turtle',
                      'application/rdf+xml': 'xml',
                      'text/rdf': 'xml',
                      'application/rdf+xml': 'xml'}


    try:
        got = kwargs.get('format', 'text/rdf+n3')
        fmt = rdflib_formats[got]
    except KeyError:
        raise KrnlException('Unsupported format for graph processing: {!s}', got)

    g = ConjunctiveGraph()
    g.load(StringInputSource(result), format=fmt)

    display = cfg.dis[0] if is_collection(cfg.dis) else cfg.dis
    if display in ('png', 'svg'):
        try:
            literal = len(cfg.dis) > 1 and cfg.dis[1].startswith('withlit')
            opt = {'lang': cfg.lan, 'literal': literal, 'graphviz': []}
            data, metadata = draw_graph(g, fmt=display, options=opt)
            return {'data': data,
                    'metadata': metadata}
        except Exception as e:
            raise KrnlException('Exception while drawing graph: {!r}', e)
    elif display == 'table':
        it = rdf_iterator(g, set(cfg.lan), add_vtype=cfg.typ)
        n, data = html_table(it, limit=cfg.lmt, withtype=cfg.typ)
        data += div('Shown: {}, Total rows: {}', n if cfg.lmt else 'all',
                    len(g), css="tinfo")
        data = {'text/html': div(data)}
    elif len(g) == 0:
        data = {'text/html': div(div('empty graph', css='krn-warn'))}
    else:
        data = {'text/plain': g.serialize(format='nt').decode('utf-8')}

    return {'data': data,
            'metadata': {}}
215302
def output_to_trivialgraph(file, namer=_trivialgraph_default_namer, block=None):
    
    graph = net_graph(block)
    node_index_map = {}  # map node -> index

    # print the list of nodes
    for index, node in enumerate(graph):
        print('%d %s' % (index, namer(node, is_edge=False)), file=file)
        node_index_map[node] = index

    print('#', file=file)

    # print the list of edges
    for _from in graph:
        for _to in graph[_from]:
            from_index = node_index_map[_from]
            to_index = node_index_map[_to]
            edge = graph[_from][_to]
            print('%d %d %s' % (from_index, to_index, namer(edge)), file=file)
1118970
def _flush_graph_val(self):
        """"""
        if not self._graphvals2set:
            return
        delafter = {}
        for graph, key, branch, turn, tick, value in self._graphvals2set:
            if (graph, key, branch) in delafter:
                delafter[graph, key, branch] = min((
                    (turn, tick),
                    delafter[graph, key, branch]
                ))
            else:
                delafter[graph, key, branch] = (turn, tick)
        self.sqlmany(
            'del_graph_val_after',
            *((graph, key, branch, turn, turn, tick)
              for ((graph, key, branch), (turn, tick)) in delafter.items())
        )
        self.sqlmany('graph_val_insert', *self._graphvals2set)
        self._graphvals2set = []
1065812
def dump_ast(ast, indent=' ', newline='\n'):
    '''
    
    
    
    '''
    
    visitor = ASTPrinter(indent=indent, level=0, newline=newline)
    visitor.visit(ast)
    return visitor.dumps()
734041
function debugOrdering(g) {
  var layerMatrix = util.buildLayerMatrix(g);

  var h = new Graph({ compound: true, multigraph: true }).setGraph({});

  _.forEach(g.nodes(), function(v) {
    h.setNode(v, { label: v });
    h.setParent(v, "layer" + g.node(v).rank);
  });

  _.forEach(g.edges(), function(e) {
    h.setEdge(e.v, e.w, {}, e.name);
  });

  _.forEach(layerMatrix, function(layer, i) {
    var layerV = "layer" + i;
    h.setNode(layerV, { rank: "same" });
    _.reduce(layer, function(u, v) {
      h.setEdge(u, v, { style: "invis" });
      return v;
    });
  });

  return h;
}
288201
def debugDumpNodeList(self, output, depth):
        
        libxml2mod.xmlDebugDumpNodeList(output, self._o, depth)