From fdc498db3af5cb36765cf5f0da6296a4033b91b7 Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Tue, 12 Mar 2019 12:23:10 -0400 Subject: Add documentation --- README.md | 41 +++++++++++++++++++++++++++++++++++++++-- test1.txt | 6 ------ test2.txt | 6 ------ test3.txt | 6 ------ test4.txt | 8 -------- test5.txt | 4 ---- test6.txt | 22 ---------------------- test7.txt | 5 ----- test8.txt | 3 --- test9.txt | 12 ------------ testgraph.sh | 4 ---- tests/test1.png | Bin 0 -> 12253 bytes tests/test1.txt | 6 ++++++ tests/test2.png | Bin 0 -> 10747 bytes tests/test2.txt | 6 ++++++ tests/test3.png | Bin 0 -> 12293 bytes tests/test3.txt | 6 ++++++ tests/test4.png | Bin 0 -> 14208 bytes tests/test4.txt | 8 ++++++++ tests/test5.png | Bin 0 -> 7418 bytes tests/test5.txt | 4 ++++ tests/test6.png | Bin 0 -> 34479 bytes tests/test6.txt | 22 ++++++++++++++++++++++ tests/test7.png | Bin 0 -> 8491 bytes tests/test7.txt | 5 +++++ tests/test8.png | Bin 0 -> 5812 bytes tests/test8.txt | 3 +++ tests/test9.png | Bin 0 -> 14936 bytes tests/test9.txt | 12 ++++++++++++ tests/testgraph.sh | 4 ++++ 30 files changed, 115 insertions(+), 78 deletions(-) delete mode 100644 test1.txt delete mode 100644 test2.txt delete mode 100644 test3.txt delete mode 100644 test4.txt delete mode 100644 test5.txt delete mode 100644 test6.txt delete mode 100644 test7.txt delete mode 100644 test8.txt delete mode 100644 test9.txt delete mode 100755 testgraph.sh create mode 100644 tests/test1.png create mode 100644 tests/test1.txt create mode 100644 tests/test2.png create mode 100644 tests/test2.txt create mode 100644 tests/test3.png create mode 100644 tests/test3.txt create mode 100644 tests/test4.png create mode 100644 tests/test4.txt create mode 100644 tests/test5.png create mode 100644 tests/test5.txt create mode 100644 tests/test6.png create mode 100644 tests/test6.txt create mode 100644 tests/test7.png create mode 100644 tests/test7.txt create mode 100644 tests/test8.png create mode 100644 tests/test8.txt create mode 100644 tests/test9.png create mode 100644 tests/test9.txt create mode 100755 tests/testgraph.sh diff --git a/README.md b/README.md index e8c602d..d4b6524 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,30 @@ you? Compile with: ``` -g++ main.cpp -o circgraph +make ``` +Run as: + +``` +./circgraph +``` + +By default, `circgraph` will read a circuit from stdin (see below) and +output the equivalent resistance between the source and sink. The `-C` +flag will switch the calculation mode to capacitance. + +`circgraph` can output graphs in Graphviz's `dot` format to stdout for +visualization. Pass stdout to `tests/testgraph.sh` to try (requires +graphviz and evince). + +# Circuit Input + +`circgraph` represents circuits as weighted undirected graphs, with +nodes representing electrically common elements (i.e. a wire) and +edges and their weights representing either resistors or capacitors +(depending on command-line options). + `circgraph` takes input from stdin in the following format: ``` @@ -28,4 +49,20 @@ g++ main.cpp -o circgraph ... ``` -See the `testX.txt` files for examples. +The first line specifies the names of the source and sink nodes. All +subsequent lines represent a weighted edge with the names of the two +nodes and the weight of the edge. Node names are created upon use. + +An example input (test5.txt) and its corresponding graph are given +below: + +``` +a c +a b 1 +a c 1 +b c 1 +``` + +![test5](https://github.com/built1n/circgraph/raw/master/tests/test5.png) + +See the `testX.txt` files for further examples. diff --git a/test1.txt b/test1.txt deleted file mode 100644 index c9fdb03..0000000 --- a/test1.txt +++ /dev/null @@ -1,6 +0,0 @@ -1 5 -1 2 1 -2 3 1 -2 4 1 -3 4 1 -4 5 1 diff --git a/test2.txt b/test2.txt deleted file mode 100644 index 2bc0bf7..0000000 --- a/test2.txt +++ /dev/null @@ -1,6 +0,0 @@ -a d -a b 1 -a c 1 -b c 1 -b d 1 -c d 1 diff --git a/test3.txt b/test3.txt deleted file mode 100644 index e6ba9b6..0000000 --- a/test3.txt +++ /dev/null @@ -1,6 +0,0 @@ -a d -a b 4 -a c 3.125 -b c 3 -b d 4 -c d 5 diff --git a/test4.txt b/test4.txt deleted file mode 100644 index 3b57188..0000000 --- a/test4.txt +++ /dev/null @@ -1,8 +0,0 @@ -a e -a b 1 -a e 10 -b c 3 -b d 2 -c d 5 -d e 5 -c e 1.5 diff --git a/test5.txt b/test5.txt deleted file mode 100644 index 1f11f98..0000000 --- a/test5.txt +++ /dev/null @@ -1,4 +0,0 @@ -a c -a b 1 -a c 1 -b c 1 diff --git a/test6.txt b/test6.txt deleted file mode 100644 index 567126c..0000000 --- a/test6.txt +++ /dev/null @@ -1,22 +0,0 @@ -a b -a b 1 -b r 1 -t a 1 -w k 1 -c j 1 -r j 1 -b q 1 -b m 1 -p g 1 -e j 1 -d i 1 -w l 1 -t w 1 -r w 1 -o g 1 -g u 1 -h x 1 -q h 1 -v a 1 -l e 1 -u i 1 diff --git a/test7.txt b/test7.txt deleted file mode 100644 index e787b78..0000000 --- a/test7.txt +++ /dev/null @@ -1,5 +0,0 @@ -a b -a b 1 -b c 1 -a d 1 -d b 1 diff --git a/test8.txt b/test8.txt deleted file mode 100644 index 2586c3d..0000000 --- a/test8.txt +++ /dev/null @@ -1,3 +0,0 @@ -a c -a b 1 -b c 1 diff --git a/test9.txt b/test9.txt deleted file mode 100644 index a8ec4a0..0000000 --- a/test9.txt +++ /dev/null @@ -1,12 +0,0 @@ -1 2 -1 2 1 -2 8 1 -4 8 1 -1 2 1 -6 2 1 -2 6 1 -6 3 1 -1 7 1 -6 1 1 -2 5 1 -8 2 1 diff --git a/testgraph.sh b/testgraph.sh deleted file mode 100755 index c63ab72..0000000 --- a/testgraph.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -cat - | gvpack -u > graph.dot -dot -Goverlap=scale -Tpdf -o out.pdf graph.dot -evince out.pdf diff --git a/tests/test1.png b/tests/test1.png new file mode 100644 index 0000000..11cc3bb Binary files /dev/null and b/tests/test1.png differ diff --git a/tests/test1.txt b/tests/test1.txt new file mode 100644 index 0000000..c9fdb03 --- /dev/null +++ b/tests/test1.txt @@ -0,0 +1,6 @@ +1 5 +1 2 1 +2 3 1 +2 4 1 +3 4 1 +4 5 1 diff --git a/tests/test2.png b/tests/test2.png new file mode 100644 index 0000000..4734e2a Binary files /dev/null and b/tests/test2.png differ diff --git a/tests/test2.txt b/tests/test2.txt new file mode 100644 index 0000000..2bc0bf7 --- /dev/null +++ b/tests/test2.txt @@ -0,0 +1,6 @@ +a d +a b 1 +a c 1 +b c 1 +b d 1 +c d 1 diff --git a/tests/test3.png b/tests/test3.png new file mode 100644 index 0000000..2ee7581 Binary files /dev/null and b/tests/test3.png differ diff --git a/tests/test3.txt b/tests/test3.txt new file mode 100644 index 0000000..e6ba9b6 --- /dev/null +++ b/tests/test3.txt @@ -0,0 +1,6 @@ +a d +a b 4 +a c 3.125 +b c 3 +b d 4 +c d 5 diff --git a/tests/test4.png b/tests/test4.png new file mode 100644 index 0000000..0234671 Binary files /dev/null and b/tests/test4.png differ diff --git a/tests/test4.txt b/tests/test4.txt new file mode 100644 index 0000000..3b57188 --- /dev/null +++ b/tests/test4.txt @@ -0,0 +1,8 @@ +a e +a b 1 +a e 10 +b c 3 +b d 2 +c d 5 +d e 5 +c e 1.5 diff --git a/tests/test5.png b/tests/test5.png new file mode 100644 index 0000000..0110633 Binary files /dev/null and b/tests/test5.png differ diff --git a/tests/test5.txt b/tests/test5.txt new file mode 100644 index 0000000..1f11f98 --- /dev/null +++ b/tests/test5.txt @@ -0,0 +1,4 @@ +a c +a b 1 +a c 1 +b c 1 diff --git a/tests/test6.png b/tests/test6.png new file mode 100644 index 0000000..3049298 Binary files /dev/null and b/tests/test6.png differ diff --git a/tests/test6.txt b/tests/test6.txt new file mode 100644 index 0000000..567126c --- /dev/null +++ b/tests/test6.txt @@ -0,0 +1,22 @@ +a b +a b 1 +b r 1 +t a 1 +w k 1 +c j 1 +r j 1 +b q 1 +b m 1 +p g 1 +e j 1 +d i 1 +w l 1 +t w 1 +r w 1 +o g 1 +g u 1 +h x 1 +q h 1 +v a 1 +l e 1 +u i 1 diff --git a/tests/test7.png b/tests/test7.png new file mode 100644 index 0000000..a896ecd Binary files /dev/null and b/tests/test7.png differ diff --git a/tests/test7.txt b/tests/test7.txt new file mode 100644 index 0000000..e787b78 --- /dev/null +++ b/tests/test7.txt @@ -0,0 +1,5 @@ +a b +a b 1 +b c 1 +a d 1 +d b 1 diff --git a/tests/test8.png b/tests/test8.png new file mode 100644 index 0000000..dd4d265 Binary files /dev/null and b/tests/test8.png differ diff --git a/tests/test8.txt b/tests/test8.txt new file mode 100644 index 0000000..2586c3d --- /dev/null +++ b/tests/test8.txt @@ -0,0 +1,3 @@ +a c +a b 1 +b c 1 diff --git a/tests/test9.png b/tests/test9.png new file mode 100644 index 0000000..253b8d5 Binary files /dev/null and b/tests/test9.png differ diff --git a/tests/test9.txt b/tests/test9.txt new file mode 100644 index 0000000..a8ec4a0 --- /dev/null +++ b/tests/test9.txt @@ -0,0 +1,12 @@ +1 2 +1 2 1 +2 8 1 +4 8 1 +1 2 1 +6 2 1 +2 6 1 +6 3 1 +1 7 1 +6 1 1 +2 5 1 +8 2 1 diff --git a/tests/testgraph.sh b/tests/testgraph.sh new file mode 100755 index 0000000..c63ab72 --- /dev/null +++ b/tests/testgraph.sh @@ -0,0 +1,4 @@ +#!/bin/bash +cat - | gvpack -u > graph.dot +dot -Goverlap=scale -Tpdf -o out.pdf graph.dot +evince out.pdf -- cgit v1.1