Create graph visualisation for input.

Needed to check if the graph is actually a DAG and whether the degrees
are correct.
This commit is contained in:
Bert Peters
2016-12-13 14:05:03 +01:00
parent 3d53a0ab2b
commit 213ceb6f85
3 changed files with 246 additions and 0 deletions

15
2016/day-10/create-graph.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
echo "digraph bots {"
while IFS=' ' read -r -a data; do
if [[ ${data[0]} == "value" ]]; then
echo "I${data[1]} -> B${data[5]};"
else
[[ ${data[5]} == "bot" ]] && kind1="B" || kind2="O"
[[ ${data[10]} == "bot" ]] && kind2="B" || kind2="O"
echo "B${data[1]} -> $kind1${data[6]} [label=lo];"
echo "B${data[1]} -> $kind2${data[11]} [label=hi];"
fi
done
echo "}"