Compute adjacency matrices for Graphviz graphs
Go to file
filifa d8c1296dec add README 2025-05-10 00:07:48 -04:00
cmd add precision 6 to output strings 2025-05-10 00:04:42 -04:00
.gitignore create .gitignore 2025-05-06 22:24:57 -04:00
COPYING initial commit 2025-05-01 18:30:59 -04:00
README.md add README 2025-05-10 00:07:48 -04:00
go.mod rename to gv2adj 2025-05-06 21:48:17 -04:00
go.sum implement checking if graph is an absorbing markov chain 2025-05-01 21:05:12 -04:00
main.go rename to gv2adj 2025-05-06 21:48:17 -04:00

README.md

gv2adj

gv2adj computes adjacency matrices (either weighted or unweighted) for Graphviz graphs (both directed and undirected).

Usage

To get the adjacency matrix of a graph in graph.gv:

gv2adj -f graph.gv

To get the matrix, but using the values stored in the len attribute as edge weights:

gv2adj -f graph.gv --weight-attr len

Say the nodes in the graph are named foo, bar, and baz. To order the rows and columns of the matrix so they correspond to bar, baz, foo:

gv2adj -f graph.gv --order bar,baz,foo

Quirks

  • If the --weight-attr flag is supplied, but an edge does not have the given attribute, NaN will be output for that edge.
  • If there are multiple edges going from node a to node b, the matrix entry will be the sum of the two.