digraph

command
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2021 License: BSD-3-Clause Imports: 12 Imported by: 1

Documentation

Overview

The digraph command performs queries over unlabelled directed graphs represented in text form. It is intended to integrate nicely with typical UNIX command pipelines.

Usage:

your-application | digraph [command]

The support commands are:

nodes
	the set of all nodes
degree
	the in-degree and out-degree of each node
transpose
	the reverse of the input edges
preds <node> ...
	the set of immediate predecessors of the specified nodes
succs <node> ...
	the set of immediate successors of the specified nodes
forward <node> ...
	the set of nodes transitively reachable from the specified nodes
reverse <node> ...
	the set of nodes that transitively reach the specified nodes
somepath <node> <node>
	the list of nodes on some arbitrary path from the first node to the second
allpaths <node> <node>
	the set of nodes on all paths from the first node to the second
sccs
	all strongly connected components (one per line)
scc <node>
	the set of nodes nodes strongly connected to the specified one
focus <node>
	the subgraph containing all directed paths that pass through the specified node

Input format:

Each line contains zero or more words. Words are separated by unquoted whitespace; words may contain Go-style double-quoted portions, allowing spaces and other characters to be expressed.

Each word declares a node, and if there are more than one, an edge from the first to each subsequent one. The graph is provided on the standard input.

For instance, the following (acyclic) graph specifies a partial order among the subtasks of getting dressed:

$ cat clothes.txt
socks shoes
"boxer shorts" pants
pants belt shoes
shirt tie sweater
sweater jacket
hat

The line "shirt tie sweater" indicates the two edges shirt -> tie and shirt -> sweater, not shirt -> tie -> sweater.

Example usage:

Using digraph with existing Go tools:

$ go mod graph | digraph nodes # Operate on the Go module graph.
$ go list -m all | digraph nodes # Operate on the Go package graph.

Show the transitive closure of imports of the digraph tool itself:

$ go list -f '{{.ImportPath}} {{join .Imports " "}}' ... | digraph forward golang.org/x/tools/cmd/digraph

Show which clothes (see above) must be donned before a jacket:

$ digraph reverse jacket

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL