diff --git a/CMakeLists.txt b/CMakeLists.txt index 2061569..96f32cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,10 +9,9 @@ include(GoogleTest) add_library(graphs INTERFACE) target_include_directories(graphs INTERFACE include) -target_link_libraries(graphs INTERFACE boost::boost) add_executable(graphs_main src/main.cc) -target_link_libraries(graphs_main PRIVATE graphs) +target_link_libraries(graphs_main PRIVATE graphs boost::boost) option(ENABLE_TESTING "Enable testing" ON) if (ENABLE_TESTING) diff --git a/README.md b/README.md index e69de29..7ecd856 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,80 @@ +# Graphs + +A simple utility for graphs analysis. +[![CI](https://github.com/victorbaldin56/Graphs/actions/workflows/main.yml/badge.svg)](https://github.com/victorbaldin56/Graphs/actions/workflows/main.yml) + +## Overview + +A graph builder and dominators and postdominators detector. + +## Features + +![alt text](img/graph.png) +![alt text](img/dom.png) +![alt text](img/pdom.png) + +## Building + +It is highly recommended to use pre-built Docker image. + +### With Docker + +1. Pull the pre-built Docker image and start the Docker container using it. Recommended command: + + ```sh + docker run --restart unless-stopped -it -v [YOUR_BACKUP_VOLUME_PATH]:/home/dev --name linux_dev victorbaldin56/linux_dev:a51a343886c34b73ddf5344e72ce095c416af046 + ``` + +1. Clone the repo. + + ```sh + git clone https://github.com/victorbaldin56/Graphs.git + ``` + +1. Install additional project dependencies with Conan + + ```sh + python3 -m venv .venv + source .venv/bin/activate + pip install conan==2.23.0 + conan profile detect --force + conan install . --build=missing --output-folder=build -pr:a=conan_profiles/release + ``` + +1. Configure the build + + ```sh + cmake --preset conan-release + ``` + +1. Build + + ```sh + cmake --build build -j + ``` + +### Have no Docker yet? + +> [!TIP] +> It will be probably easier for you to install Docker because some tool +> requirements are specific. + +You can check my [Dockerfile](https://github.com/victorbaldin56/DockerLinuxDev/blob/a51a343886c34b73ddf5344e72ce095c416af046/Dockerfile) +and build the same environment yourself. + +## Usage + +To get quick help on available commands, run: + +```sh +./build/graphs_main --help +``` + +## License + +This project is licensed after APACHE 2.0 license. + +## Contribution + +This project is currently in active development. If you wish to contribute +you are welcome to submit pull requests and issues. Thank you! diff --git a/img/dom.png b/img/dom.png new file mode 100644 index 0000000..f7db66d Binary files /dev/null and b/img/dom.png differ diff --git a/img/graph.png b/img/graph.png new file mode 100644 index 0000000..fe15fa0 Binary files /dev/null and b/img/graph.png differ diff --git a/img/pdom.png b/img/pdom.png new file mode 100644 index 0000000..a9cd0da Binary files /dev/null and b/img/pdom.png differ diff --git a/include/graphs/graph.hh b/include/graphs/graph.hh index 3f430c3..0f6d1b6 100644 --- a/include/graphs/graph.hh +++ b/include/graphs/graph.hh @@ -1,9 +1,13 @@ #pragma once -#include -#include +#include +#include +#include #include +#include +#include #include +#include #include namespace graph { @@ -76,47 +80,178 @@ class Graph final { return order; } - void dump(std::ostream& os) const { - using namespace boost; + void dump(std::ostream& os, std::string graph_name = "", + bool add_sentinel = true) const { + os << "digraph {\n" + << "label=\"" << graph_name << "\"\n"; - using OutGraph = adjacency_list, - property>; + if (add_sentinel) { + os << "Start[label=\"Start\"];\n" + << "End[label=\"End\"];\n"; - OutGraph g; + for (const auto& [u, cnt] : in_deg_) { + if (cnt == 0) { + os << "\"Start\" -> " << u << ";\n"; + } + } + + for (const auto& [u, cnt] : out_deg_) { + if (cnt == 0) { + os << u << " -> \"End\";\n"; + } + } + } - auto start = add_vertex(g); - auto end = add_vertex(g); - put(vertex_name, g, start, "Start"); - put(vertex_name, g, end, "End"); + for (auto& [u, vs] : adj_list_) { + for (const auto& v : vs) { + os << u << " -> " << v << ";\n"; + } + } - std::unordered_map vd; - vd.reserve(in_deg_.size()); + os << "}\n"; + os.flush(); + } + + // compute dominator sets using a virtual entry (internal only). Returned map + // contains only real nodes. + std::unordered_map> computeDominatorsVirtualEntry() + const { + // build augmented adjacency keyed by Opt + std::unordered_map, OptHash> adj_opt; + adj_opt.reserve(in_deg_.size() + 1); + + // insert all real nodes (even those with empty outgoing) for (const auto& [v, _] : in_deg_) { - auto d = add_vertex(g); - put(vertex_name, g, d, std::to_string(v)); - vd.emplace(v, d); + Opt key = Opt(v); + auto it = adj_list_.find(v); + if (it != adj_list_.end()) { + std::vector outs; + outs.reserve(it->second.size()); + for (auto const& w : it->second) outs.push_back(Opt(w)); + adj_opt.emplace(key, std::move(outs)); + } else + adj_opt.emplace(key, std::vector{}); } - for (const auto& [v, cnt] : in_deg_) { - if (cnt == 0) { - add_edge(start, vd[v], g); - } + // virtual entry connects to all zero-in-degree nodes + std::vector starts; + for (const auto& [v, cnt] : in_deg_) + if (cnt == 0) starts.push_back(Opt(v)); + adj_opt.emplace(std::nullopt, std::move(starts)); + + // compute dominators on augmented graph + auto dom_opt = computeDominatorsOnOptAdj(adj_opt, std::nullopt); + + // convert back to real-node dom sets (drop virtual node from sets) + std::unordered_map> dom; + dom.reserve(dom_opt.size()); + for (auto const& [k, set_opt] : dom_opt) { + if (!k) continue; // skip virtual + std::unordered_set s; + s.reserve(set_opt.size()); + for (auto const& x : set_opt) + if (x) s.insert(*x); + dom.emplace(*k, std::move(s)); } + return dom; + } - for (const auto& [v, cnt] : out_deg_) { - if (cnt == 0) { - add_edge(vd[v], end, g); + // immediate dominators from dom-sets (root nodes will map to nullopt) + std::unordered_map> immediateDominatorsFromDomSets( + const std::unordered_map>& dom) const { + std::unordered_map> idom; + idom.reserve(dom.size()); + for (auto const& [n, dset] : dom) { + if (dset.size() <= 1) { + idom[n] = std::nullopt; + continue; + } + // candidates = dset - {n} + std::vector cand; + cand.reserve(dset.size()); + for (auto const& x : dset) + if (!(x == n)) cand.push_back(x); + if (cand.empty()) { + idom[n] = std::nullopt; + continue; } + // choose deepest: largest dominator set + auto size_of = [&](const T& v) { return dom.at(v).size(); }; + T best = cand[0]; + for (size_t i = 1; i < cand.size(); ++i) + if (size_of(cand[i]) > size_of(best)) best = cand[i]; + idom[n] = best; } + return idom; + } - for (const auto& [v, adj] : adj_list_) { - for (const auto& a : adj) { - add_edge(vd[v], vd[a], g); - } + Graph dominatorTree() const { + auto dom = computeDominatorsVirtualEntry(); + auto idom = immediateDominatorsFromDomSets(dom); + + std::unordered_map> children; + for (auto const& [n, _] : dom) children.emplace(n, std::vector{}); + for (auto const& [n, p] : idom) { + if (!p.has_value()) + continue; // parent was virtual => root in returned forest + children[*p].push_back(n); } - write_graphviz(os, g, make_label_writer(get(vertex_name, g))); + Graph tree; + for (auto const& [v, ch] : children) tree.insert(v, ch); + return tree; + } + + Graph postDominatorTree() const { + AdjMap real = fullAdjacency(); + + // reversed adjacency as Opt + std::unordered_map, OptHash> rev_opt; + rev_opt.reserve(real.size() + 1); + for (auto const& [v, _] : real) rev_opt.emplace(Opt(v), std::vector{}); + for (auto const& [u, outs] : real) + for (auto const& v : outs) rev_opt[Opt(v)].push_back(Opt(u)); + + // virtual entry in reversed graph connects to original exits (nodes with + // zero outgoing). + std::vector exits; + for (auto const& [v, outs] : real) + if (outs.empty()) exits.push_back(Opt(v)); + rev_opt.emplace(std::nullopt, std::move(exits)); + + auto dom_opt = computeDominatorsOnOptAdj(rev_opt, std::nullopt); + + std::unordered_map> pdom; + pdom.reserve(dom_opt.size()); + for (auto const& [k, set_opt] : dom_opt) { + if (!k) continue; + std::unordered_set s; + s.reserve(set_opt.size()); + for (auto const& x : set_opt) + if (x) s.insert(*x); + pdom.emplace(*k, std::move(s)); + } + + auto idom = immediateDominatorsFromDomSets(pdom); + + // build tree + std::unordered_map> children; + for (auto const& [n, _] : pdom) children.emplace(n, std::vector{}); + for (auto const& [n, p] : idom) { + if (!p.has_value()) continue; + children[*p].push_back(n); + } + + Graph tree; + for (auto const& [v, ch] : children) tree.insert(v, ch); + return tree; + } + + std::vector nodes() const { + std::vector ns; + ns.reserve(in_deg_.size()); + for (const auto& [v, _] : in_deg_) ns.push_back(v); + return ns; } private: @@ -125,6 +260,119 @@ class Graph final { using DegreeMap = std::unordered_map; DegreeMap in_deg_; DegreeMap out_deg_; + + // small alias for optional key used only internally + using Opt = std::optional; + + struct OptHash { + size_t operator()(const Opt& o) const noexcept { + if (!o) { + return 0x9e3779b97f4a7c15ULL; + } + return std::hash()(*o); + } + }; + + // compute dominators on an adjacency map keyed by Opt (virtual node = + // nullopt) + static std::unordered_map, OptHash> + computeDominatorsOnOptAdj( + const std::unordered_map, OptHash>& adj, + const Opt& entry) { + // reachable + std::unordered_set seen; + std::deque dq; + dq.push_back(entry); + seen.insert(entry); + while (!dq.empty()) { + auto u = dq.front(); + dq.pop_front(); + auto it = adj.find(u); + if (it == adj.end()) continue; + for (const auto& v : it->second) { + if (seen.insert(v).second) { + dq.push_back(v); + } + } + } + + std::unordered_map, OptHash> preds; + for (auto const& n : seen) { + preds.emplace(n, std::vector{}); + } + + for (auto const& [u, outs] : adj) { + if (!seen.count(u)) { + continue; + } + for (auto const& v : outs) { + if (seen.count(v)) preds[v].push_back(u); + } + } + + // init dom sets + std::unordered_map, OptHash> dom; + dom.reserve(seen.size()); + for (auto const& n : seen) { + if (n == entry) { + dom[n] = {entry}; + } else { + dom[n] = std::unordered_set(seen.begin(), seen.end()); + } + } + + // iterate until fixed point + bool changed = true; + while (changed) { + changed = false; + for (auto const& n : seen) { + if (n == entry) { + continue; + } + // intersect predecessors' dom sets + std::unordered_set newdom; + bool first = true; + for (auto const& p : preds[n]) { + if (first) { + newdom = dom[p]; + first = false; + } else { + // intersection + for (auto it = newdom.begin(); it != newdom.end();) { + if (!dom[p].count(*it)) { + it = newdom.erase(it); + } else { + ++it; + } + } + } + } + if (first) { + newdom.clear(); + } // no preds + newdom.insert(n); // rule: dom(n) = {n} U intersect(preds) + if (newdom != dom[n]) { + dom[n] = std::move(newdom); + changed = true; + } + } + } + return dom; + } + + AdjMap fullAdjacency() const { + AdjMap adj; + adj.reserve(in_deg_.size()); + for (const auto& [v, _] : in_deg_) { + auto it = adj_list_.find(v); + if (it != adj_list_.end()) { + adj.emplace(v, it->second); + } else { + adj.emplace(v, std::vector{}); + } + } + return adj; + } }; template diff --git a/src/main.cc b/src/main.cc index a6d0a52..7040c19 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,4 +1,6 @@ #include +#include +#include #include #include @@ -17,7 +19,10 @@ int main(int argc, char** argv) try { po::options_description desc("Options"); // clang-format off desc.add_options() - ("help,h", "Print help message and exit"); + ("help,h", "Print help message and exit") + ("o,output-file", po::value(), "Specify output file for graph") + ("domtree", po::value(), "Specify output file for dominators tree") + ("pdomtree", po::value(), "Specify output file for postdominators tree"); // clang-format on po::variables_map vm; @@ -36,7 +41,36 @@ int main(int argc, char** argv) try { } auto g = graph::readGraph(std::cin); - g.dump(std::cout); + + if (vm.count("o")) { + auto out = vm["o"].as(); + std::ofstream os(out); + if (!os.is_open()) { + throw std::runtime_error(std::format("Couldnt open file {}", out)); + } + g.dump(os, "Graph"); + } else { + g.dump(std::cout, "Graph"); + } + + if (vm.count("domtree")) { + auto domtree = vm["domtree"].as(); + std::ofstream os(domtree); + if (!os.is_open()) { + throw std::runtime_error(std::format("Couldnt open file {}", domtree)); + } + g.dominatorTree().dump(os, "Dominator Tree", false); + } + + if (vm.count("pdomtree")) { + auto pdomtree = vm["pdomtree"].as(); + std::ofstream os(pdomtree); + if (!os.is_open()) { + throw std::runtime_error(std::format("Couldnt open file {}", pdomtree)); + } + g.postDominatorTree().dump(os, "Post Dominator Tree", false); + } + return 0; } catch (std::exception& e) { std::cerr << e.what() << std::endl; diff --git a/tests/dom/1.dot b/tests/dom/1.dot new file mode 100644 index 0000000..6caa053 --- /dev/null +++ b/tests/dom/1.dot @@ -0,0 +1,7 @@ +digraph { +label="Dominator Tree" +3 -> 5; +3 -> 7; +3 -> 2; +3 -> 9; +} diff --git a/tests/dom/2.dot b/tests/dom/2.dot new file mode 100644 index 0000000..9cd28a9 --- /dev/null +++ b/tests/dom/2.dot @@ -0,0 +1,27 @@ +digraph { +label="Dominator Tree" +4 -> 5; +11 -> 16; +16 -> 21; +3 -> 4; +6 -> 11; +2 -> 3; +1 -> 9; +1 -> 8; +1 -> 7; +1 -> 6; +1 -> 2; +1 -> 12; +1 -> 13; +1 -> 17; +1 -> 10; +1 -> 14; +1 -> 18; +1 -> 22; +1 -> 15; +1 -> 19; +1 -> 23; +1 -> 20; +1 -> 24; +1 -> 25; +} diff --git a/tests/dom/3.dot b/tests/dom/3.dot new file mode 100644 index 0000000..162ef28 --- /dev/null +++ b/tests/dom/3.dot @@ -0,0 +1,17 @@ +digraph { +label="Dominator Tree" +2 -> 5; +2 -> 4; +1 -> 3; +1 -> 2; +3 -> 7; +3 -> 6; +4 -> 9; +4 -> 8; +5 -> 11; +5 -> 10; +6 -> 12; +6 -> 13; +7 -> 14; +7 -> 15; +} diff --git a/tests/dom/4.dot b/tests/dom/4.dot new file mode 100644 index 0000000..11d9f68 --- /dev/null +++ b/tests/dom/4.dot @@ -0,0 +1,22 @@ +digraph { +label="Dominator Tree" +2 -> 3; +1 -> 13; +1 -> 11; +1 -> 15; +1 -> 2; +1 -> 14; +1 -> 12; +1 -> 16; +1 -> 17; +1 -> 18; +1 -> 19; +1 -> 20; +8 -> 9; +7 -> 8; +6 -> 7; +5 -> 6; +4 -> 5; +3 -> 4; +9 -> 10; +} diff --git a/tests/dom/5.dot b/tests/dom/5.dot new file mode 100644 index 0000000..9b01206 --- /dev/null +++ b/tests/dom/5.dot @@ -0,0 +1,139 @@ +digraph { +label="Dominator Tree" +10 -> 23; +1 -> 126; +1 -> 125; +1 -> 124; +1 -> 123; +1 -> 122; +1 -> 121; +1 -> 120; +1 -> 119; +1 -> 118; +1 -> 117; +1 -> 116; +1 -> 115; +1 -> 114; +1 -> 113; +1 -> 112; +1 -> 111; +1 -> 110; +1 -> 109; +1 -> 108; +1 -> 107; +1 -> 106; +1 -> 105; +1 -> 104; +1 -> 103; +1 -> 102; +1 -> 101; +1 -> 100; +1 -> 99; +1 -> 98; +1 -> 97; +1 -> 96; +1 -> 95; +1 -> 94; +1 -> 93; +1 -> 92; +1 -> 91; +1 -> 90; +1 -> 88; +1 -> 87; +1 -> 86; +1 -> 85; +1 -> 84; +1 -> 83; +1 -> 82; +1 -> 81; +1 -> 80; +1 -> 79; +1 -> 78; +1 -> 77; +1 -> 76; +1 -> 75; +1 -> 74; +1 -> 73; +1 -> 72; +1 -> 68; +1 -> 67; +1 -> 66; +1 -> 65; +1 -> 63; +1 -> 62; +1 -> 61; +1 -> 60; +1 -> 59; +1 -> 24; +1 -> 19; +1 -> 2; +1 -> 3; +1 -> 4; +1 -> 36; +1 -> 37; +1 -> 38; +1 -> 41; +1 -> 42; +1 -> 43; +1 -> 47; +1 -> 48; +1 -> 54; +1 -> 55; +1 -> 56; +1 -> 57; +1 -> 58; +1 -> 127; +1 -> 128; +1 -> 129; +1 -> 130; +1 -> 131; +1 -> 132; +1 -> 133; +1 -> 134; +1 -> 135; +1 -> 136; +1 -> 137; +2 -> 89; +2 -> 71; +2 -> 70; +2 -> 69; +2 -> 17; +2 -> 16; +2 -> 15; +2 -> 5; +2 -> 6; +2 -> 7; +2 -> 30; +2 -> 31; +2 -> 32; +2 -> 33; +2 -> 34; +2 -> 35; +2 -> 49; +2 -> 50; +2 -> 51; +2 -> 52; +2 -> 53; +3 -> 22; +3 -> 21; +3 -> 20; +3 -> 8; +3 -> 9; +3 -> 10; +3 -> 39; +3 -> 40; +4 -> 64; +4 -> 27; +4 -> 25; +4 -> 26; +4 -> 13; +4 -> 12; +4 -> 11; +4 -> 44; +4 -> 45; +4 -> 46; +5 -> 14; +7 -> 18; +13 -> 28; +14 -> 29; +} diff --git a/tests/dom/6.dot b/tests/dom/6.dot new file mode 100644 index 0000000..7e5b4fc --- /dev/null +++ b/tests/dom/6.dot @@ -0,0 +1,133 @@ +digraph { +label="Dominator Tree" +233 -> 236; +14 -> 29; +4 -> 41; +4 -> 10; +4 -> 11; +9 -> 21; +5 -> 13; +7 -> 17; +3 -> 9; +6 -> 15; +2 -> 7; +1 -> 82; +1 -> 81; +1 -> 64; +1 -> 63; +1 -> 62; +1 -> 61; +1 -> 46; +1 -> 45; +1 -> 44; +1 -> 43; +1 -> 42; +1 -> 25; +1 -> 4; +1 -> 5; +1 -> 12; +1 -> 26; +1 -> 27; +8 -> 19; +10 -> 23; +10 -> 22; +138 -> 143; +138 -> 152; +138 -> 142; +138 -> 151; +138 -> 150; +138 -> 139; +138 -> 140; +138 -> 144; +138 -> 153; +138 -> 145; +138 -> 154; +138 -> 146; +138 -> 155; +138 -> 156; +138 -> 147; +138 -> 157; +138 -> 148; +138 -> 158; +138 -> 149; +138 -> 159; +138 -> 160; +138 -> 161; +138 -> 162; +138 -> 163; +138 -> 164; +138 -> 165; +138 -> 166; +138 -> 167; +138 -> 168; +138 -> 169; +138 -> 170; +138 -> 171; +138 -> 172; +138 -> 173; +138 -> 174; +138 -> 175; +138 -> 176; +138 -> 177; +138 -> 178; +138 -> 179; +138 -> 180; +138 -> 181; +138 -> 182; +138 -> 183; +138 -> 184; +138 -> 185; +138 -> 186; +138 -> 187; +138 -> 188; +138 -> 189; +138 -> 190; +138 -> 191; +138 -> 192; +138 -> 193; +138 -> 194; +138 -> 195; +138 -> 196; +138 -> 197; +138 -> 198; +138 -> 199; +138 -> 200; +138 -> 201; +138 -> 202; +138 -> 203; +138 -> 204; +138 -> 205; +138 -> 206; +138 -> 207; +138 -> 208; +138 -> 209; +138 -> 210; +138 -> 211; +138 -> 212; +138 -> 213; +138 -> 214; +138 -> 215; +138 -> 216; +138 -> 217; +138 -> 218; +138 -> 219; +138 -> 220; +138 -> 221; +138 -> 222; +138 -> 223; +138 -> 224; +138 -> 225; +138 -> 226; +138 -> 227; +138 -> 228; +138 -> 229; +138 -> 230; +138 -> 231; +138 -> 232; +138 -> 233; +138 -> 234; +138 -> 235; +11 -> 24; +139 -> 141; +13 -> 28; +} diff --git a/tests/dom/7.dot b/tests/dom/7.dot new file mode 100644 index 0000000..fde8a60 --- /dev/null +++ b/tests/dom/7.dot @@ -0,0 +1,6 @@ +digraph { +label="Dominator Tree" +3 -> 4; +2 -> 3; +1 -> 2; +} diff --git a/tests/dom/8.dot b/tests/dom/8.dot new file mode 100644 index 0000000..bede957 --- /dev/null +++ b/tests/dom/8.dot @@ -0,0 +1,9 @@ +digraph { +label="Dominator Tree" +9 -> 14; +1 -> 5; +14 -> 19; +4 -> 9; +19 -> 24; +24 -> 29; +} diff --git a/tests/out/1.dot b/tests/out/1.dot index de9caed..da99441 100644 --- a/tests/out/1.dot +++ b/tests/out/1.dot @@ -1,17 +1,13 @@ -digraph G { -0[label=Start]; -1[label=End]; -2[label=9]; -3[label=3]; -4[label=2]; -5[label=7]; -6[label=5]; -0->3 ; -2->1 ; -3->6 ; -3->5 ; -3->4 ; -4->1 ; -5->2 ; -6->2 ; +digraph { +label="Graph" +Start[label="Start"]; +End[label="End"]; +"Start" -> 3; +9 -> "End"; +2 -> "End"; +7 -> 9; +5 -> 9; +3 -> 5; +3 -> 7; +3 -> 2; } diff --git a/tests/out/2.dot b/tests/out/2.dot index 0c15d86..125b0bf 100644 --- a/tests/out/2.dot +++ b/tests/out/2.dot @@ -1,71 +1,47 @@ -digraph G { -0[label=Start]; -1[label=End]; -2[label=25]; -3[label=24]; -4[label=23]; -5[label=22]; -6[label=21]; -7[label=20]; -8[label=19]; -9[label=18]; -10[label=17]; -11[label=16]; -12[label=15]; -13[label=14]; -14[label=2]; -15[label=6]; -16[label=1]; -17[label=3]; -18[label=7]; -19[label=4]; -20[label=8]; -21[label=5]; -22[label=9]; -23[label=10]; -24[label=11]; -25[label=12]; -26[label=13]; -0->16 ; -2->1 ; -3->2 ; -4->3 ; -5->4 ; -6->5 ; -7->2 ; -8->7 ; -8->3 ; -9->8 ; -9->4 ; -10->9 ; -10->5 ; -11->10 ; -11->6 ; -12->7 ; -13->12 ; -13->8 ; -14->17 ; -14->18 ; -15->18 ; -15->24 ; -16->14 ; -16->15 ; -17->19 ; -17->20 ; -18->20 ; -18->25 ; -19->21 ; -19->22 ; -20->22 ; -20->26 ; -21->23 ; -22->23 ; -22->13 ; -23->12 ; -24->25 ; -24->11 ; -25->26 ; -25->10 ; -26->13 ; -26->9 ; +digraph { +label="Graph" +Start[label="Start"]; +End[label="End"]; +"Start" -> 1; +25 -> "End"; +24 -> 25; +23 -> 24; +22 -> 23; +21 -> 22; +20 -> 25; +19 -> 20; +19 -> 24; +18 -> 19; +18 -> 23; +17 -> 18; +17 -> 22; +16 -> 17; +16 -> 21; +15 -> 20; +14 -> 15; +14 -> 19; +1 -> 2; +1 -> 6; +2 -> 3; +2 -> 7; +3 -> 4; +3 -> 8; +4 -> 5; +4 -> 9; +5 -> 10; +6 -> 7; +6 -> 11; +7 -> 8; +7 -> 12; +8 -> 9; +8 -> 13; +9 -> 10; +9 -> 14; +10 -> 15; +11 -> 12; +11 -> 16; +12 -> 13; +12 -> 17; +13 -> 14; +13 -> 18; } diff --git a/tests/out/3.dot b/tests/out/3.dot index c3e7df7..0ddaad0 100644 --- a/tests/out/3.dot +++ b/tests/out/3.dot @@ -1,42 +1,28 @@ -digraph G { -0[label=Start]; -1[label=End]; -2[label=15]; -3[label=14]; -4[label=2]; -5[label=3]; -6[label=1]; -7[label=4]; -8[label=5]; -9[label=6]; -10[label=7]; -11[label=8]; -12[label=9]; -13[label=10]; -14[label=11]; -15[label=12]; -16[label=13]; -0->6 ; -2->1 ; -3->1 ; -4->7 ; -4->8 ; -5->9 ; -5->10 ; -6->4 ; -6->5 ; -7->11 ; -7->12 ; -8->13 ; -8->14 ; -9->15 ; -9->16 ; -10->3 ; -10->2 ; -11->1 ; -12->1 ; -13->1 ; -14->1 ; -15->1 ; -16->1 ; +digraph { +label="Graph" +Start[label="Start"]; +End[label="End"]; +"Start" -> 1; +15 -> "End"; +14 -> "End"; +8 -> "End"; +9 -> "End"; +10 -> "End"; +11 -> "End"; +12 -> "End"; +13 -> "End"; +7 -> 14; +7 -> 15; +6 -> 12; +6 -> 13; +5 -> 10; +5 -> 11; +4 -> 8; +4 -> 9; +3 -> 6; +3 -> 7; +2 -> 4; +2 -> 5; +1 -> 2; +1 -> 3; } diff --git a/tests/out/4.dot b/tests/out/4.dot index b8bab33..396cc50 100644 --- a/tests/out/4.dot +++ b/tests/out/4.dot @@ -1,54 +1,35 @@ -digraph G { -0[label=Start]; -1[label=End]; -2[label=20]; -3[label=19]; -4[label=10]; -5[label=18]; -6[label=9]; -7[label=17]; -8[label=8]; -9[label=2]; -10[label=15]; -11[label=11]; -12[label=1]; -13[label=14]; -14[label=3]; -15[label=16]; -16[label=12]; -17[label=4]; -18[label=13]; -19[label=5]; -20[label=6]; -21[label=7]; -0->12 ; -2->1 ; -3->2 ; -4->2 ; -5->3 ; -6->4 ; -6->3 ; -7->5 ; -8->6 ; -8->5 ; -9->14 ; -9->16 ; -10->15 ; -11->16 ; -12->9 ; -12->11 ; -13->10 ; -14->17 ; -14->18 ; -15->7 ; -16->18 ; -17->19 ; -17->13 ; -18->13 ; -19->20 ; -19->10 ; -20->21 ; -20->15 ; -21->8 ; -21->7 ; +digraph { +label="Graph" +Start[label="Start"]; +End[label="End"]; +"Start" -> 1; +20 -> "End"; +19 -> 20; +18 -> 19; +17 -> 18; +16 -> 17; +15 -> 16; +14 -> 15; +1 -> 2; +1 -> 11; +2 -> 3; +2 -> 12; +3 -> 4; +3 -> 13; +4 -> 5; +4 -> 14; +5 -> 6; +5 -> 15; +6 -> 7; +6 -> 16; +7 -> 8; +7 -> 17; +8 -> 9; +8 -> 18; +9 -> 10; +9 -> 19; +10 -> 20; +11 -> 12; +12 -> 13; +13 -> 14; } diff --git a/tests/out/5.dot b/tests/out/5.dot index 1850c7d..088449b 100644 --- a/tests/out/5.dot +++ b/tests/out/5.dot @@ -1,527 +1,391 @@ -digraph G { -0[label=Start]; -1[label=End]; -2[label=137]; -3[label=136]; -4[label=135]; -5[label=134]; -6[label=133]; -7[label=132]; -8[label=131]; -9[label=130]; -10[label=129]; -11[label=128]; -12[label=59]; -13[label=58]; -14[label=57]; -15[label=56]; -16[label=55]; -17[label=54]; -18[label=53]; -19[label=52]; -20[label=51]; -21[label=50]; -22[label=49]; -23[label=48]; -24[label=47]; -25[label=46]; -26[label=45]; -27[label=44]; -28[label=43]; -29[label=42]; -30[label=41]; -31[label=40]; -32[label=39]; -33[label=38]; -34[label=37]; -35[label=36]; -36[label=35]; -37[label=34]; -38[label=33]; -39[label=32]; -40[label=31]; -41[label=30]; -42[label=13]; -43[label=12]; -44[label=11]; -45[label=10]; -46[label=9]; -47[label=8]; -48[label=7]; -49[label=6]; -50[label=5]; -51[label=1]; -52[label=4]; -53[label=3]; -54[label=2]; -55[label=14]; -56[label=15]; -57[label=16]; -58[label=17]; -59[label=18]; -60[label=19]; -61[label=20]; -62[label=21]; -63[label=22]; -64[label=23]; -65[label=24]; -66[label=25]; -67[label=26]; -68[label=27]; -69[label=28]; -70[label=29]; -71[label=60]; -72[label=61]; -73[label=62]; -74[label=63]; -75[label=64]; -76[label=65]; -77[label=66]; -78[label=67]; -79[label=68]; -80[label=69]; -81[label=70]; -82[label=71]; -83[label=72]; -84[label=73]; -85[label=74]; -86[label=75]; -87[label=76]; -88[label=77]; -89[label=78]; -90[label=79]; -91[label=80]; -92[label=81]; -93[label=82]; -94[label=83]; -95[label=84]; -96[label=85]; -97[label=86]; -98[label=87]; -99[label=88]; -100[label=89]; -101[label=90]; -102[label=91]; -103[label=92]; -104[label=93]; -105[label=94]; -106[label=95]; -107[label=96]; -108[label=97]; -109[label=98]; -110[label=99]; -111[label=100]; -112[label=101]; -113[label=102]; -114[label=103]; -115[label=104]; -116[label=105]; -117[label=106]; -118[label=107]; -119[label=108]; -120[label=109]; -121[label=110]; -122[label=111]; -123[label=112]; -124[label=113]; -125[label=114]; -126[label=115]; -127[label=116]; -128[label=117]; -129[label=118]; -130[label=119]; -131[label=120]; -132[label=121]; -133[label=122]; -134[label=123]; -135[label=124]; -136[label=125]; -137[label=126]; -138[label=127]; -0->51 ; -2->1 ; -3->1 ; -4->1 ; -5->1 ; -6->2 ; -7->3 ; -7->2 ; -8->3 ; -8->2 ; -9->3 ; -9->2 ; -10->3 ; -10->2 ; -11->3 ; -11->2 ; -12->88 ; -12->89 ; -12->90 ; -13->87 ; -13->88 ; -13->89 ; -14->86 ; -14->87 ; -14->88 ; -15->85 ; -15->86 ; -15->87 ; -16->84 ; -16->85 ; -16->86 ; -17->83 ; -17->84 ; -17->85 ; -18->82 ; -18->83 ; -18->84 ; -19->81 ; -19->82 ; -19->83 ; -20->80 ; -20->81 ; -20->82 ; -21->79 ; -21->80 ; -21->81 ; -22->78 ; -22->79 ; -22->80 ; -23->77 ; -23->78 ; -23->79 ; -24->76 ; -24->77 ; -24->78 ; -25->75 ; -25->76 ; -25->77 ; -26->74 ; -26->75 ; -26->76 ; -27->73 ; -27->74 ; -27->75 ; -28->72 ; -28->73 ; -28->74 ; -29->71 ; -29->72 ; -29->73 ; -30->12 ; -30->71 ; -30->72 ; -31->13 ; -31->12 ; -31->71 ; -32->14 ; -32->13 ; -32->12 ; -33->15 ; -33->14 ; -33->13 ; -34->16 ; -34->15 ; -34->14 ; -35->17 ; -35->16 ; -35->15 ; -36->18 ; -36->17 ; -36->16 ; -37->19 ; -37->18 ; -37->17 ; -38->20 ; -38->19 ; -38->18 ; -39->21 ; -39->20 ; -39->19 ; -40->22 ; -40->21 ; -40->20 ; -41->23 ; -41->22 ; -41->21 ; -42->68 ; -42->69 ; -43->66 ; -43->67 ; -43->68 ; -44->65 ; -44->66 ; -44->67 ; -45->63 ; -45->64 ; -45->65 ; -46->61 ; -46->62 ; -46->63 ; -47->60 ; -47->61 ; -47->62 ; -48->58 ; -48->59 ; -48->60 ; -49->56 ; -49->57 ; -49->58 ; -50->55 ; -50->56 ; -50->57 ; -51->54 ; -51->53 ; -51->52 ; -52->44 ; -52->43 ; -52->42 ; -53->47 ; -53->46 ; -53->45 ; -54->50 ; -54->49 ; -54->48 ; -55->70 ; -55->41 ; -55->40 ; -56->41 ; -56->40 ; -56->39 ; -57->39 ; -57->38 ; -57->37 ; -58->38 ; -58->37 ; -58->36 ; -59->36 ; -59->35 ; -59->34 ; -60->35 ; -60->34 ; -60->33 ; -61->34 ; -61->33 ; -61->32 ; -62->33 ; -62->32 ; -62->31 ; -63->32 ; -63->31 ; -63->30 ; -64->31 ; -64->30 ; -64->29 ; -65->30 ; -65->29 ; -65->28 ; -66->29 ; -66->28 ; -66->27 ; -67->28 ; -67->27 ; -67->26 ; -68->27 ; -68->26 ; -68->25 ; -69->25 ; -69->24 ; -69->23 ; -70->24 ; -70->23 ; -70->22 ; -71->89 ; -71->90 ; -71->91 ; -72->90 ; -72->91 ; -72->92 ; -73->91 ; -73->92 ; -73->93 ; -74->92 ; -74->93 ; -74->94 ; -75->93 ; -75->94 ; -75->95 ; -76->94 ; -76->95 ; -76->96 ; -77->95 ; -77->96 ; -77->97 ; -78->96 ; -78->97 ; -78->98 ; -79->97 ; -79->98 ; -79->99 ; -80->98 ; -80->99 ; -80->100 ; -81->99 ; -81->100 ; -81->101 ; -82->100 ; -82->101 ; -82->102 ; -83->101 ; -83->102 ; -83->103 ; -84->102 ; -84->103 ; -84->104 ; -85->103 ; -85->104 ; -85->105 ; -86->104 ; -86->105 ; -86->106 ; -87->105 ; -87->106 ; -87->107 ; -88->106 ; -88->107 ; -88->108 ; -89->107 ; -89->108 ; -89->109 ; -90->108 ; -90->109 ; -90->110 ; -91->109 ; -91->110 ; -91->111 ; -92->110 ; -92->111 ; -92->112 ; -93->111 ; -93->112 ; -93->113 ; -94->112 ; -94->113 ; -94->114 ; -95->113 ; -95->114 ; -95->115 ; -96->114 ; -96->115 ; -96->116 ; -97->115 ; -97->116 ; -97->117 ; -98->116 ; -98->117 ; -98->118 ; -99->117 ; -99->118 ; -99->119 ; -100->118 ; -100->119 ; -100->120 ; -101->119 ; -101->120 ; -101->121 ; -102->120 ; -102->121 ; -102->122 ; -103->121 ; -103->122 ; -103->123 ; -104->122 ; -104->123 ; -104->124 ; -105->123 ; -105->124 ; -105->125 ; -106->124 ; -106->125 ; -106->126 ; -107->125 ; -107->126 ; -107->127 ; -108->126 ; -108->127 ; -108->128 ; -109->127 ; -109->128 ; -109->129 ; -110->128 ; -110->129 ; -110->130 ; -111->129 ; -111->130 ; -111->131 ; -112->130 ; -112->131 ; -112->132 ; -113->131 ; -113->132 ; -113->133 ; -114->132 ; -114->133 ; -114->134 ; -115->133 ; -115->134 ; -115->135 ; -116->134 ; -116->135 ; -116->136 ; -117->135 ; -117->136 ; -117->137 ; -118->136 ; -118->137 ; -118->138 ; -119->137 ; -119->138 ; -119->11 ; -120->138 ; -120->11 ; -120->10 ; -121->11 ; -121->10 ; -121->9 ; -122->10 ; -122->9 ; -122->8 ; -123->9 ; -123->8 ; -123->7 ; -124->8 ; -124->7 ; -124->6 ; -125->7 ; -125->6 ; -125->5 ; -126->6 ; -126->5 ; -126->4 ; -127->5 ; -127->4 ; -127->3 ; -128->4 ; -128->3 ; -128->2 ; -129->3 ; -129->2 ; -130->3 ; -130->2 ; -131->3 ; -131->2 ; -132->3 ; -132->2 ; -133->3 ; -133->2 ; -134->3 ; -134->2 ; -135->3 ; -135->2 ; -136->3 ; -136->2 ; -137->3 ; -137->2 ; -138->3 ; -138->2 ; +digraph { +label="Graph" +Start[label="Start"]; +End[label="End"]; +"Start" -> 1; +137 -> "End"; +136 -> "End"; +135 -> "End"; +134 -> "End"; +133 -> 137; +132 -> 136; +132 -> 137; +131 -> 136; +131 -> 137; +130 -> 136; +130 -> 137; +129 -> 136; +129 -> 137; +128 -> 136; +128 -> 137; +59 -> 77; +59 -> 78; +59 -> 79; +58 -> 76; +58 -> 77; +58 -> 78; +57 -> 75; +57 -> 76; +57 -> 77; +56 -> 74; +56 -> 75; +56 -> 76; +55 -> 73; +55 -> 74; +55 -> 75; +54 -> 72; +54 -> 73; +54 -> 74; +53 -> 71; +53 -> 72; +53 -> 73; +52 -> 70; +52 -> 71; +52 -> 72; +51 -> 69; +51 -> 70; +51 -> 71; +50 -> 68; +50 -> 69; +50 -> 70; +49 -> 67; +49 -> 68; +49 -> 69; +48 -> 66; +48 -> 67; +48 -> 68; +47 -> 65; +47 -> 66; +47 -> 67; +46 -> 64; +46 -> 65; +46 -> 66; +45 -> 63; +45 -> 64; +45 -> 65; +44 -> 62; +44 -> 63; +44 -> 64; +43 -> 61; +43 -> 62; +43 -> 63; +42 -> 60; +42 -> 61; +42 -> 62; +41 -> 59; +41 -> 60; +41 -> 61; +40 -> 58; +40 -> 59; +40 -> 60; +39 -> 57; +39 -> 58; +39 -> 59; +38 -> 56; +38 -> 57; +38 -> 58; +37 -> 55; +37 -> 56; +37 -> 57; +36 -> 54; +36 -> 55; +36 -> 56; +35 -> 53; +35 -> 54; +35 -> 55; +34 -> 52; +34 -> 53; +34 -> 54; +33 -> 51; +33 -> 52; +33 -> 53; +32 -> 50; +32 -> 51; +32 -> 52; +31 -> 49; +31 -> 50; +31 -> 51; +30 -> 48; +30 -> 49; +30 -> 50; +13 -> 27; +13 -> 28; +12 -> 25; +12 -> 26; +12 -> 27; +11 -> 24; +11 -> 25; +11 -> 26; +10 -> 22; +10 -> 23; +10 -> 24; +9 -> 20; +9 -> 21; +9 -> 22; +8 -> 19; +8 -> 20; +8 -> 21; +7 -> 17; +7 -> 18; +7 -> 19; +6 -> 15; +6 -> 16; +6 -> 17; +5 -> 14; +5 -> 15; +5 -> 16; +4 -> 11; +4 -> 12; +4 -> 13; +3 -> 8; +3 -> 9; +3 -> 10; +2 -> 5; +2 -> 6; +2 -> 7; +1 -> 2; +1 -> 3; +1 -> 4; +14 -> 29; +14 -> 30; +14 -> 31; +15 -> 30; +15 -> 31; +15 -> 32; +16 -> 32; +16 -> 33; +16 -> 34; +17 -> 33; +17 -> 34; +17 -> 35; +18 -> 35; +18 -> 36; +18 -> 37; +19 -> 36; +19 -> 37; +19 -> 38; +20 -> 37; +20 -> 38; +20 -> 39; +21 -> 38; +21 -> 39; +21 -> 40; +22 -> 39; +22 -> 40; +22 -> 41; +23 -> 40; +23 -> 41; +23 -> 42; +24 -> 41; +24 -> 42; +24 -> 43; +25 -> 42; +25 -> 43; +25 -> 44; +26 -> 43; +26 -> 44; +26 -> 45; +27 -> 44; +27 -> 45; +27 -> 46; +28 -> 46; +28 -> 47; +28 -> 48; +29 -> 47; +29 -> 48; +29 -> 49; +60 -> 78; +60 -> 79; +60 -> 80; +61 -> 79; +61 -> 80; +61 -> 81; +62 -> 80; +62 -> 81; +62 -> 82; +63 -> 81; +63 -> 82; +63 -> 83; +64 -> 82; +64 -> 83; +64 -> 84; +65 -> 83; +65 -> 84; +65 -> 85; +66 -> 84; +66 -> 85; +66 -> 86; +67 -> 85; +67 -> 86; +67 -> 87; +68 -> 86; +68 -> 87; +68 -> 88; +69 -> 87; +69 -> 88; +69 -> 89; +70 -> 88; +70 -> 89; +70 -> 90; +71 -> 89; +71 -> 90; +71 -> 91; +72 -> 90; +72 -> 91; +72 -> 92; +73 -> 91; +73 -> 92; +73 -> 93; +74 -> 92; +74 -> 93; +74 -> 94; +75 -> 93; +75 -> 94; +75 -> 95; +76 -> 94; +76 -> 95; +76 -> 96; +77 -> 95; +77 -> 96; +77 -> 97; +78 -> 96; +78 -> 97; +78 -> 98; +79 -> 97; +79 -> 98; +79 -> 99; +80 -> 98; +80 -> 99; +80 -> 100; +81 -> 99; +81 -> 100; +81 -> 101; +82 -> 100; +82 -> 101; +82 -> 102; +83 -> 101; +83 -> 102; +83 -> 103; +84 -> 102; +84 -> 103; +84 -> 104; +85 -> 103; +85 -> 104; +85 -> 105; +86 -> 104; +86 -> 105; +86 -> 106; +87 -> 105; +87 -> 106; +87 -> 107; +88 -> 106; +88 -> 107; +88 -> 108; +89 -> 107; +89 -> 108; +89 -> 109; +90 -> 108; +90 -> 109; +90 -> 110; +91 -> 109; +91 -> 110; +91 -> 111; +92 -> 110; +92 -> 111; +92 -> 112; +93 -> 111; +93 -> 112; +93 -> 113; +94 -> 112; +94 -> 113; +94 -> 114; +95 -> 113; +95 -> 114; +95 -> 115; +96 -> 114; +96 -> 115; +96 -> 116; +97 -> 115; +97 -> 116; +97 -> 117; +98 -> 116; +98 -> 117; +98 -> 118; +99 -> 117; +99 -> 118; +99 -> 119; +100 -> 118; +100 -> 119; +100 -> 120; +101 -> 119; +101 -> 120; +101 -> 121; +102 -> 120; +102 -> 121; +102 -> 122; +103 -> 121; +103 -> 122; +103 -> 123; +104 -> 122; +104 -> 123; +104 -> 124; +105 -> 123; +105 -> 124; +105 -> 125; +106 -> 124; +106 -> 125; +106 -> 126; +107 -> 125; +107 -> 126; +107 -> 127; +108 -> 126; +108 -> 127; +108 -> 128; +109 -> 127; +109 -> 128; +109 -> 129; +110 -> 128; +110 -> 129; +110 -> 130; +111 -> 129; +111 -> 130; +111 -> 131; +112 -> 130; +112 -> 131; +112 -> 132; +113 -> 131; +113 -> 132; +113 -> 133; +114 -> 132; +114 -> 133; +114 -> 134; +115 -> 133; +115 -> 134; +115 -> 135; +116 -> 134; +116 -> 135; +116 -> 136; +117 -> 135; +117 -> 136; +117 -> 137; +118 -> 136; +118 -> 137; +119 -> 136; +119 -> 137; +120 -> 136; +120 -> 137; +121 -> 136; +121 -> 137; +122 -> 136; +122 -> 137; +123 -> 136; +123 -> 137; +124 -> 136; +124 -> 137; +125 -> 136; +125 -> 137; +126 -> 136; +126 -> 137; +127 -> 136; +127 -> 137; } diff --git a/tests/out/6.dot b/tests/out/6.dot index 28324a6..8dc2b60 100644 --- a/tests/out/6.dot +++ b/tests/out/6.dot @@ -1,836 +1,596 @@ -digraph G { -0[label=Start]; -1[label=End]; -2[label=241]; -3[label=240]; -4[label=239]; -5[label=238]; -6[label=237]; -7[label=236]; -8[label=235]; -9[label=234]; -10[label=233]; -11[label=232]; -12[label=231]; -13[label=230]; -14[label=229]; -15[label=228]; -16[label=227]; -17[label=226]; -18[label=225]; -19[label=224]; -20[label=223]; -21[label=222]; -22[label=221]; -23[label=220]; -24[label=219]; -25[label=218]; -26[label=217]; -27[label=216]; -28[label=215]; -29[label=214]; -30[label=213]; -31[label=212]; -32[label=211]; -33[label=210]; -34[label=209]; -35[label=208]; -36[label=207]; -37[label=206]; -38[label=205]; -39[label=204]; -40[label=203]; -41[label=202]; -42[label=201]; -43[label=200]; -44[label=199]; -45[label=198]; -46[label=197]; -47[label=196]; -48[label=195]; -49[label=194]; -50[label=193]; -51[label=192]; -52[label=191]; -53[label=190]; -54[label=189]; -55[label=188]; -56[label=187]; -57[label=186]; -58[label=185]; -59[label=184]; -60[label=183]; -61[label=182]; -62[label=181]; -63[label=180]; -64[label=179]; -65[label=178]; -66[label=177]; -67[label=176]; -68[label=175]; -69[label=174]; -70[label=173]; -71[label=172]; -72[label=171]; -73[label=170]; -74[label=169]; -75[label=168]; -76[label=167]; -77[label=166]; -78[label=165]; -79[label=164]; -80[label=163]; -81[label=162]; -82[label=161]; -83[label=160]; -84[label=159]; -85[label=158]; -86[label=157]; -87[label=156]; -88[label=155]; -89[label=154]; -90[label=153]; -91[label=152]; -92[label=151]; -93[label=150]; -94[label=149]; -95[label=148]; -96[label=147]; -97[label=146]; -98[label=145]; -99[label=144]; -100[label=143]; -101[label=142]; -102[label=141]; -103[label=138]; -104[label=140]; -105[label=139]; -106[label=137]; -107[label=136]; -108[label=135]; -109[label=134]; -110[label=133]; -111[label=132]; -112[label=131]; -113[label=130]; -114[label=129]; -115[label=128]; -116[label=59]; -117[label=58]; -118[label=57]; -119[label=56]; -120[label=55]; -121[label=54]; -122[label=53]; -123[label=52]; -124[label=51]; -125[label=50]; -126[label=49]; -127[label=48]; -128[label=47]; -129[label=46]; -130[label=45]; -131[label=44]; -132[label=43]; -133[label=42]; -134[label=41]; -135[label=40]; -136[label=39]; -137[label=38]; -138[label=37]; -139[label=36]; -140[label=35]; -141[label=34]; -142[label=33]; -143[label=32]; -144[label=31]; -145[label=30]; -146[label=13]; -147[label=12]; -148[label=11]; -149[label=10]; -150[label=3]; -151[label=9]; -152[label=2]; -153[label=8]; -154[label=7]; -155[label=1]; -156[label=6]; -157[label=5]; -158[label=4]; -159[label=14]; -160[label=15]; -161[label=16]; -162[label=17]; -163[label=18]; -164[label=19]; -165[label=20]; -166[label=21]; -167[label=22]; -168[label=23]; -169[label=24]; -170[label=25]; -171[label=26]; -172[label=27]; -173[label=28]; -174[label=29]; -175[label=60]; -176[label=61]; -177[label=62]; -178[label=63]; -179[label=64]; -180[label=65]; -181[label=66]; -182[label=67]; -183[label=68]; -184[label=69]; -185[label=70]; -186[label=71]; -187[label=72]; -188[label=73]; -189[label=74]; -190[label=75]; -191[label=76]; -192[label=77]; -193[label=78]; -194[label=79]; -195[label=80]; -196[label=81]; -197[label=82]; -198[label=83]; -199[label=84]; -200[label=85]; -201[label=86]; -202[label=87]; -203[label=88]; -204[label=89]; -205[label=90]; -206[label=91]; -207[label=92]; -208[label=93]; -209[label=94]; -210[label=95]; -211[label=96]; -212[label=97]; -213[label=98]; -214[label=99]; -215[label=100]; -216[label=101]; -217[label=102]; -218[label=103]; -219[label=104]; -220[label=105]; -221[label=106]; -222[label=107]; -223[label=108]; -224[label=109]; -225[label=110]; -226[label=111]; -227[label=112]; -228[label=113]; -229[label=114]; -230[label=115]; -231[label=116]; -232[label=117]; -233[label=118]; -234[label=119]; -235[label=120]; -236[label=121]; -237[label=122]; -238[label=123]; -239[label=124]; -240[label=125]; -241[label=126]; -242[label=127]; -0->2 ; -0->3 ; -0->4 ; -0->5 ; -0->6 ; -0->103 ; -0->150 ; -0->152 ; -0->155 ; -2->1 ; -3->1 ; -4->1 ; -5->1 ; -6->1 ; -7->1 ; -8->1 ; -9->1 ; -10->8 ; -10->7 ; -11->9 ; -11->8 ; -12->10 ; -12->9 ; -13->11 ; -13->10 ; -14->12 ; -14->11 ; -15->13 ; -15->12 ; -16->14 ; -16->13 ; -17->15 ; -17->14 ; -18->16 ; -18->15 ; -19->17 ; -19->16 ; -20->18 ; -20->17 ; -21->19 ; -21->18 ; -22->20 ; -22->19 ; -23->21 ; -23->20 ; -24->22 ; -24->21 ; -25->23 ; -25->22 ; -26->24 ; -26->23 ; -27->25 ; -27->24 ; -28->26 ; -28->25 ; -29->27 ; -29->26 ; -30->28 ; -30->27 ; -31->29 ; -31->28 ; -32->30 ; -32->29 ; -33->31 ; -33->30 ; -34->32 ; -34->31 ; -35->33 ; -35->32 ; -36->34 ; -36->33 ; -37->35 ; -37->34 ; -38->36 ; -38->35 ; -39->37 ; -39->36 ; -40->38 ; -40->37 ; -41->39 ; -41->38 ; -42->40 ; -42->39 ; -43->41 ; -43->40 ; -44->42 ; -44->41 ; -45->43 ; -45->42 ; -46->44 ; -46->43 ; -47->45 ; -47->44 ; -48->46 ; -48->45 ; -49->47 ; -49->46 ; -50->48 ; -50->47 ; -51->49 ; -51->48 ; -52->50 ; -52->49 ; -53->51 ; -53->50 ; -54->52 ; -54->51 ; -55->53 ; -55->52 ; -56->54 ; -56->53 ; -57->55 ; -57->54 ; -58->56 ; -58->55 ; -59->57 ; -59->56 ; -60->58 ; -60->57 ; -61->59 ; -61->58 ; -62->60 ; -62->59 ; -63->61 ; -63->60 ; -64->62 ; -64->61 ; -65->63 ; -65->62 ; -66->64 ; -66->63 ; -67->65 ; -67->64 ; -68->66 ; -68->65 ; -69->67 ; -69->66 ; -70->68 ; -70->67 ; -71->69 ; -71->68 ; -72->70 ; -72->69 ; -73->71 ; -73->70 ; -74->72 ; -74->71 ; -75->73 ; -75->72 ; -76->74 ; -76->73 ; -77->75 ; -77->74 ; -78->76 ; -78->75 ; -79->77 ; -79->76 ; -80->78 ; -80->77 ; -81->79 ; -81->78 ; -82->80 ; -82->79 ; -83->81 ; -83->80 ; -84->82 ; -84->81 ; -85->83 ; -85->82 ; -86->84 ; -86->83 ; -87->85 ; -87->84 ; -88->86 ; -88->85 ; -89->87 ; -89->86 ; -90->88 ; -90->87 ; -91->89 ; -91->88 ; -92->90 ; -92->89 ; -93->91 ; -93->90 ; -94->92 ; -94->91 ; -95->93 ; -95->92 ; -96->94 ; -96->93 ; -97->95 ; -97->94 ; -98->96 ; -98->95 ; -99->97 ; -99->96 ; -100->98 ; -100->97 ; -101->99 ; -101->98 ; -102->100 ; -102->99 ; -103->105 ; -103->104 ; -104->101 ; -104->100 ; -105->102 ; -105->101 ; -106->1 ; -107->1 ; -108->1 ; -109->1 ; -110->106 ; -111->107 ; -111->106 ; -112->107 ; -112->106 ; -113->107 ; -113->106 ; -114->107 ; -114->106 ; -115->107 ; -115->106 ; -116->192 ; -116->193 ; -116->194 ; -117->191 ; -117->192 ; -117->193 ; -118->190 ; -118->191 ; -118->192 ; -119->189 ; -119->190 ; -119->191 ; -120->188 ; -120->189 ; -120->190 ; -121->187 ; -121->188 ; -121->189 ; -122->186 ; -122->187 ; -122->188 ; -123->185 ; -123->186 ; -123->187 ; -124->184 ; -124->185 ; -124->186 ; -125->183 ; -125->184 ; -125->185 ; -126->182 ; -126->183 ; -126->184 ; -127->181 ; -127->182 ; -127->183 ; -128->180 ; -128->181 ; -128->182 ; -129->179 ; -129->180 ; -129->181 ; -130->178 ; -130->179 ; -130->180 ; -131->177 ; -131->178 ; -131->179 ; -132->176 ; -132->177 ; -132->178 ; -133->175 ; -133->176 ; -133->177 ; -134->116 ; -134->175 ; -134->176 ; -135->117 ; -135->116 ; -135->175 ; -136->118 ; -136->117 ; -136->116 ; -137->119 ; -137->118 ; -137->117 ; -138->120 ; -138->119 ; -138->118 ; -139->121 ; -139->120 ; -139->119 ; -140->122 ; -140->121 ; -140->120 ; -141->123 ; -141->122 ; -141->121 ; -142->124 ; -142->123 ; -142->122 ; -143->125 ; -143->124 ; -143->123 ; -144->126 ; -144->125 ; -144->124 ; -145->127 ; -145->126 ; -145->125 ; -146->172 ; -146->173 ; -147->170 ; -147->171 ; -147->172 ; -148->169 ; -148->170 ; -148->171 ; -149->167 ; -149->168 ; -150->153 ; -150->151 ; -151->165 ; -151->166 ; -152->156 ; -152->154 ; -152->153 ; -153->163 ; -153->164 ; -153->165 ; -154->161 ; -154->162 ; -154->163 ; -155->158 ; -155->157 ; -155->156 ; -156->159 ; -156->160 ; -156->161 ; -157->147 ; -157->146 ; -157->159 ; -158->149 ; -158->148 ; -158->147 ; -159->174 ; -159->145 ; -159->144 ; -160->145 ; -160->144 ; -160->143 ; -161->143 ; -161->142 ; -161->141 ; -162->142 ; -162->141 ; -162->140 ; -163->140 ; -163->139 ; -163->138 ; -164->139 ; -164->138 ; -164->137 ; -165->138 ; -165->137 ; -165->136 ; -166->137 ; -166->136 ; -166->135 ; -167->136 ; -167->135 ; -167->134 ; -168->135 ; -168->134 ; -168->133 ; -169->134 ; -169->133 ; -169->132 ; -170->133 ; -170->132 ; -170->131 ; -171->132 ; -171->131 ; -171->130 ; -172->131 ; -172->130 ; -172->129 ; -173->129 ; -173->128 ; -173->127 ; -174->128 ; -174->127 ; -174->126 ; -175->193 ; -175->194 ; -175->195 ; -176->194 ; -176->195 ; -176->196 ; -177->195 ; -177->196 ; -177->197 ; -178->196 ; -178->197 ; -178->198 ; -179->197 ; -179->198 ; -179->199 ; -180->198 ; -180->199 ; -180->200 ; -181->199 ; -181->200 ; -181->201 ; -182->200 ; -182->201 ; -182->202 ; -183->201 ; -183->202 ; -183->203 ; -184->202 ; -184->203 ; -184->204 ; -185->203 ; -185->204 ; -185->205 ; -186->204 ; -186->205 ; -186->206 ; -187->205 ; -187->206 ; -187->207 ; -188->206 ; -188->207 ; -188->208 ; -189->207 ; -189->208 ; -189->209 ; -190->208 ; -190->209 ; -190->210 ; -191->209 ; -191->210 ; -191->211 ; -192->210 ; -192->211 ; -192->212 ; -193->211 ; -193->212 ; -193->213 ; -194->212 ; -194->213 ; -194->214 ; -195->213 ; -195->214 ; -195->215 ; -196->214 ; -196->215 ; -196->216 ; -197->215 ; -197->216 ; -197->217 ; -198->216 ; -198->217 ; -198->218 ; -199->217 ; -199->218 ; -199->219 ; -200->218 ; -200->219 ; -200->220 ; -201->219 ; -201->220 ; -201->221 ; -202->220 ; -202->221 ; -202->222 ; -203->221 ; -203->222 ; -203->223 ; -204->222 ; -204->223 ; -204->224 ; -205->223 ; -205->224 ; -205->225 ; -206->224 ; -206->225 ; -206->226 ; -207->225 ; -207->226 ; -207->227 ; -208->226 ; -208->227 ; -208->228 ; -209->227 ; -209->228 ; -209->229 ; -210->228 ; -210->229 ; -210->230 ; -211->229 ; -211->230 ; -211->231 ; -212->230 ; -212->231 ; -212->232 ; -213->231 ; -213->232 ; -213->233 ; -214->232 ; -214->233 ; -214->234 ; -215->233 ; -215->234 ; -215->235 ; -216->234 ; -216->235 ; -216->236 ; -217->235 ; -217->236 ; -217->237 ; -218->236 ; -218->237 ; -218->238 ; -219->237 ; -219->238 ; -219->239 ; -220->238 ; -220->239 ; -220->240 ; -221->239 ; -221->240 ; -221->241 ; -222->240 ; -222->241 ; -222->242 ; -223->241 ; -223->242 ; -223->115 ; -224->242 ; -224->115 ; -224->114 ; -225->115 ; -225->114 ; -225->113 ; -226->114 ; -226->113 ; -226->112 ; -227->113 ; -227->112 ; -227->111 ; -228->112 ; -228->111 ; -228->110 ; -229->111 ; -229->110 ; -229->109 ; -230->110 ; -230->109 ; -230->108 ; -231->109 ; -231->108 ; -231->107 ; -232->108 ; -232->107 ; -232->106 ; -233->107 ; -233->106 ; -234->107 ; -234->106 ; -235->107 ; -235->106 ; -236->107 ; -236->106 ; -237->107 ; -237->106 ; -238->107 ; -238->106 ; -239->107 ; -239->106 ; -240->107 ; -240->106 ; -241->107 ; -241->106 ; -242->107 ; -242->106 ; +digraph { +label="Graph" +Start[label="Start"]; +End[label="End"]; +"Start" -> 241; +"Start" -> 240; +"Start" -> 239; +"Start" -> 238; +"Start" -> 237; +"Start" -> 138; +"Start" -> 3; +"Start" -> 2; +"Start" -> 1; +241 -> "End"; +240 -> "End"; +239 -> "End"; +238 -> "End"; +237 -> "End"; +236 -> "End"; +235 -> "End"; +234 -> "End"; +137 -> "End"; +136 -> "End"; +135 -> "End"; +134 -> "End"; +233 -> 235; +233 -> 236; +232 -> 234; +232 -> 235; +231 -> 233; +231 -> 234; +230 -> 232; +230 -> 233; +229 -> 231; +229 -> 232; +228 -> 230; +228 -> 231; +227 -> 229; +227 -> 230; +226 -> 228; +226 -> 229; +225 -> 227; +225 -> 228; +224 -> 226; +224 -> 227; +223 -> 225; +223 -> 226; +222 -> 224; +222 -> 225; +221 -> 223; +221 -> 224; +220 -> 222; +220 -> 223; +219 -> 221; +219 -> 222; +218 -> 220; +218 -> 221; +217 -> 219; +217 -> 220; +216 -> 218; +216 -> 219; +215 -> 217; +215 -> 218; +214 -> 216; +214 -> 217; +213 -> 215; +213 -> 216; +212 -> 214; +212 -> 215; +211 -> 213; +211 -> 214; +210 -> 212; +210 -> 213; +209 -> 211; +209 -> 212; +208 -> 210; +208 -> 211; +207 -> 209; +207 -> 210; +206 -> 208; +206 -> 209; +205 -> 207; +205 -> 208; +204 -> 206; +204 -> 207; +203 -> 205; +203 -> 206; +202 -> 204; +202 -> 205; +201 -> 203; +201 -> 204; +200 -> 202; +200 -> 203; +199 -> 201; +199 -> 202; +198 -> 200; +198 -> 201; +197 -> 199; +197 -> 200; +196 -> 198; +196 -> 199; +195 -> 197; +195 -> 198; +194 -> 196; +194 -> 197; +193 -> 195; +193 -> 196; +192 -> 194; +192 -> 195; +191 -> 193; +191 -> 194; +190 -> 192; +190 -> 193; +189 -> 191; +189 -> 192; +188 -> 190; +188 -> 191; +187 -> 189; +187 -> 190; +186 -> 188; +186 -> 189; +185 -> 187; +185 -> 188; +184 -> 186; +184 -> 187; +183 -> 185; +183 -> 186; +182 -> 184; +182 -> 185; +181 -> 183; +181 -> 184; +180 -> 182; +180 -> 183; +179 -> 181; +179 -> 182; +178 -> 180; +178 -> 181; +177 -> 179; +177 -> 180; +176 -> 178; +176 -> 179; +175 -> 177; +175 -> 178; +174 -> 176; +174 -> 177; +173 -> 175; +173 -> 176; +172 -> 174; +172 -> 175; +171 -> 173; +171 -> 174; +170 -> 172; +170 -> 173; +169 -> 171; +169 -> 172; +168 -> 170; +168 -> 171; +167 -> 169; +167 -> 170; +166 -> 168; +166 -> 169; +165 -> 167; +165 -> 168; +164 -> 166; +164 -> 167; +163 -> 165; +163 -> 166; +162 -> 164; +162 -> 165; +161 -> 163; +161 -> 164; +160 -> 162; +160 -> 163; +159 -> 161; +159 -> 162; +158 -> 160; +158 -> 161; +157 -> 159; +157 -> 160; +156 -> 158; +156 -> 159; +155 -> 157; +155 -> 158; +154 -> 156; +154 -> 157; +153 -> 155; +153 -> 156; +152 -> 154; +152 -> 155; +151 -> 153; +151 -> 154; +150 -> 152; +150 -> 153; +149 -> 151; +149 -> 152; +148 -> 150; +148 -> 151; +147 -> 149; +147 -> 150; +146 -> 148; +146 -> 149; +145 -> 147; +145 -> 148; +144 -> 146; +144 -> 147; +143 -> 145; +143 -> 146; +142 -> 144; +142 -> 145; +141 -> 143; +141 -> 144; +140 -> 142; +140 -> 143; +139 -> 141; +139 -> 142; +138 -> 139; +138 -> 140; +133 -> 137; +132 -> 136; +132 -> 137; +131 -> 136; +131 -> 137; +130 -> 136; +130 -> 137; +129 -> 136; +129 -> 137; +128 -> 136; +128 -> 137; +59 -> 77; +59 -> 78; +59 -> 79; +58 -> 76; +58 -> 77; +58 -> 78; +57 -> 75; +57 -> 76; +57 -> 77; +56 -> 74; +56 -> 75; +56 -> 76; +55 -> 73; +55 -> 74; +55 -> 75; +54 -> 72; +54 -> 73; +54 -> 74; +53 -> 71; +53 -> 72; +53 -> 73; +52 -> 70; +52 -> 71; +52 -> 72; +51 -> 69; +51 -> 70; +51 -> 71; +50 -> 68; +50 -> 69; +50 -> 70; +49 -> 67; +49 -> 68; +49 -> 69; +48 -> 66; +48 -> 67; +48 -> 68; +47 -> 65; +47 -> 66; +47 -> 67; +46 -> 64; +46 -> 65; +46 -> 66; +45 -> 63; +45 -> 64; +45 -> 65; +44 -> 62; +44 -> 63; +44 -> 64; +43 -> 61; +43 -> 62; +43 -> 63; +42 -> 60; +42 -> 61; +42 -> 62; +41 -> 59; +41 -> 60; +41 -> 61; +40 -> 58; +40 -> 59; +40 -> 60; +39 -> 57; +39 -> 58; +39 -> 59; +38 -> 56; +38 -> 57; +38 -> 58; +37 -> 55; +37 -> 56; +37 -> 57; +36 -> 54; +36 -> 55; +36 -> 56; +35 -> 53; +35 -> 54; +35 -> 55; +34 -> 52; +34 -> 53; +34 -> 54; +33 -> 51; +33 -> 52; +33 -> 53; +32 -> 50; +32 -> 51; +32 -> 52; +31 -> 49; +31 -> 50; +31 -> 51; +30 -> 48; +30 -> 49; +30 -> 50; +13 -> 27; +13 -> 28; +12 -> 25; +12 -> 26; +12 -> 27; +11 -> 24; +11 -> 25; +11 -> 26; +10 -> 22; +10 -> 23; +9 -> 20; +9 -> 21; +8 -> 18; +8 -> 19; +8 -> 20; +7 -> 16; +7 -> 17; +7 -> 18; +6 -> 14; +6 -> 15; +6 -> 16; +5 -> 12; +5 -> 13; +5 -> 14; +4 -> 10; +4 -> 11; +4 -> 12; +3 -> 8; +3 -> 9; +2 -> 6; +2 -> 7; +2 -> 8; +1 -> 4; +1 -> 5; +1 -> 6; +14 -> 29; +14 -> 30; +14 -> 31; +15 -> 30; +15 -> 31; +15 -> 32; +16 -> 32; +16 -> 33; +16 -> 34; +17 -> 33; +17 -> 34; +17 -> 35; +18 -> 35; +18 -> 36; +18 -> 37; +19 -> 36; +19 -> 37; +19 -> 38; +20 -> 37; +20 -> 38; +20 -> 39; +21 -> 38; +21 -> 39; +21 -> 40; +22 -> 39; +22 -> 40; +22 -> 41; +23 -> 40; +23 -> 41; +23 -> 42; +24 -> 41; +24 -> 42; +24 -> 43; +25 -> 42; +25 -> 43; +25 -> 44; +26 -> 43; +26 -> 44; +26 -> 45; +27 -> 44; +27 -> 45; +27 -> 46; +28 -> 46; +28 -> 47; +28 -> 48; +29 -> 47; +29 -> 48; +29 -> 49; +60 -> 78; +60 -> 79; +60 -> 80; +61 -> 79; +61 -> 80; +61 -> 81; +62 -> 80; +62 -> 81; +62 -> 82; +63 -> 81; +63 -> 82; +63 -> 83; +64 -> 82; +64 -> 83; +64 -> 84; +65 -> 83; +65 -> 84; +65 -> 85; +66 -> 84; +66 -> 85; +66 -> 86; +67 -> 85; +67 -> 86; +67 -> 87; +68 -> 86; +68 -> 87; +68 -> 88; +69 -> 87; +69 -> 88; +69 -> 89; +70 -> 88; +70 -> 89; +70 -> 90; +71 -> 89; +71 -> 90; +71 -> 91; +72 -> 90; +72 -> 91; +72 -> 92; +73 -> 91; +73 -> 92; +73 -> 93; +74 -> 92; +74 -> 93; +74 -> 94; +75 -> 93; +75 -> 94; +75 -> 95; +76 -> 94; +76 -> 95; +76 -> 96; +77 -> 95; +77 -> 96; +77 -> 97; +78 -> 96; +78 -> 97; +78 -> 98; +79 -> 97; +79 -> 98; +79 -> 99; +80 -> 98; +80 -> 99; +80 -> 100; +81 -> 99; +81 -> 100; +81 -> 101; +82 -> 100; +82 -> 101; +82 -> 102; +83 -> 101; +83 -> 102; +83 -> 103; +84 -> 102; +84 -> 103; +84 -> 104; +85 -> 103; +85 -> 104; +85 -> 105; +86 -> 104; +86 -> 105; +86 -> 106; +87 -> 105; +87 -> 106; +87 -> 107; +88 -> 106; +88 -> 107; +88 -> 108; +89 -> 107; +89 -> 108; +89 -> 109; +90 -> 108; +90 -> 109; +90 -> 110; +91 -> 109; +91 -> 110; +91 -> 111; +92 -> 110; +92 -> 111; +92 -> 112; +93 -> 111; +93 -> 112; +93 -> 113; +94 -> 112; +94 -> 113; +94 -> 114; +95 -> 113; +95 -> 114; +95 -> 115; +96 -> 114; +96 -> 115; +96 -> 116; +97 -> 115; +97 -> 116; +97 -> 117; +98 -> 116; +98 -> 117; +98 -> 118; +99 -> 117; +99 -> 118; +99 -> 119; +100 -> 118; +100 -> 119; +100 -> 120; +101 -> 119; +101 -> 120; +101 -> 121; +102 -> 120; +102 -> 121; +102 -> 122; +103 -> 121; +103 -> 122; +103 -> 123; +104 -> 122; +104 -> 123; +104 -> 124; +105 -> 123; +105 -> 124; +105 -> 125; +106 -> 124; +106 -> 125; +106 -> 126; +107 -> 125; +107 -> 126; +107 -> 127; +108 -> 126; +108 -> 127; +108 -> 128; +109 -> 127; +109 -> 128; +109 -> 129; +110 -> 128; +110 -> 129; +110 -> 130; +111 -> 129; +111 -> 130; +111 -> 131; +112 -> 130; +112 -> 131; +112 -> 132; +113 -> 131; +113 -> 132; +113 -> 133; +114 -> 132; +114 -> 133; +114 -> 134; +115 -> 133; +115 -> 134; +115 -> 135; +116 -> 134; +116 -> 135; +116 -> 136; +117 -> 135; +117 -> 136; +117 -> 137; +118 -> 136; +118 -> 137; +119 -> 136; +119 -> 137; +120 -> 136; +120 -> 137; +121 -> 136; +121 -> 137; +122 -> 136; +122 -> 137; +123 -> 136; +123 -> 137; +124 -> 136; +124 -> 137; +125 -> 136; +125 -> 137; +126 -> 136; +126 -> 137; +127 -> 136; +127 -> 137; } diff --git a/tests/out/7.dot b/tests/out/7.dot index ff9c5a8..7b4d64f 100644 --- a/tests/out/7.dot +++ b/tests/out/7.dot @@ -1,13 +1,10 @@ -digraph G { -0[label=Start]; -1[label=End]; -2[label=4]; -3[label=3]; -4[label=1]; -5[label=2]; -0->4 ; -2->1 ; -3->2 ; -4->5 ; -5->3 ; +digraph { +label="Graph" +Start[label="Start"]; +End[label="End"]; +"Start" -> 1; +4 -> "End"; +3 -> 4; +2 -> 3; +1 -> 2; } diff --git a/tests/out/8.dot b/tests/out/8.dot index 6511071..ded8f2d 100644 --- a/tests/out/8.dot +++ b/tests/out/8.dot @@ -1,88 +1,59 @@ -digraph G { -0[label=Start]; -1[label=End]; -2[label=30]; -3[label=13]; -4[label=12]; -5[label=11]; -6[label=10]; -7[label=4]; -8[label=9]; -9[label=3]; -10[label=8]; -11[label=2]; -12[label=7]; -13[label=1]; -14[label=6]; -15[label=5]; -16[label=14]; -17[label=15]; -18[label=16]; -19[label=17]; -20[label=18]; -21[label=19]; -22[label=20]; -23[label=21]; -24[label=22]; -25[label=23]; -26[label=24]; -27[label=25]; -28[label=26]; -29[label=27]; -30[label=28]; -31[label=29]; -0->7 ; -0->9 ; -0->11 ; -0->13 ; -2->1 ; -3->19 ; -3->20 ; -4->18 ; -4->19 ; -5->17 ; -5->18 ; -6->17 ; -7->10 ; -7->8 ; -8->3 ; -8->16 ; -9->12 ; -9->10 ; -10->4 ; -10->3 ; -11->14 ; -11->12 ; -12->5 ; -12->4 ; -13->15 ; -13->14 ; -14->6 ; -14->5 ; -15->6 ; -16->20 ; -16->21 ; -17->22 ; -18->22 ; -18->23 ; -19->23 ; -19->24 ; -20->24 ; -20->25 ; -21->25 ; -21->26 ; -22->27 ; -23->27 ; -23->28 ; -24->28 ; -24->29 ; -25->29 ; -25->30 ; -26->30 ; -26->31 ; -27->2 ; -28->2 ; -29->2 ; -30->2 ; -31->2 ; +digraph { +label="Graph" +Start[label="Start"]; +End[label="End"]; +"Start" -> 4; +"Start" -> 3; +"Start" -> 2; +"Start" -> 1; +30 -> "End"; +13 -> 17; +13 -> 18; +12 -> 16; +12 -> 17; +11 -> 15; +11 -> 16; +10 -> 15; +9 -> 13; +9 -> 14; +8 -> 12; +8 -> 13; +7 -> 11; +7 -> 12; +6 -> 10; +6 -> 11; +5 -> 10; +4 -> 8; +4 -> 9; +3 -> 7; +3 -> 8; +2 -> 6; +2 -> 7; +1 -> 5; +1 -> 6; +14 -> 18; +14 -> 19; +15 -> 20; +16 -> 20; +16 -> 21; +17 -> 21; +17 -> 22; +18 -> 22; +18 -> 23; +19 -> 23; +19 -> 24; +20 -> 25; +21 -> 25; +21 -> 26; +22 -> 26; +22 -> 27; +23 -> 27; +23 -> 28; +24 -> 28; +24 -> 29; +25 -> 30; +26 -> 30; +27 -> 30; +28 -> 30; +29 -> 30; } diff --git a/tests/pdom/1.dot b/tests/pdom/1.dot new file mode 100644 index 0000000..21b9d09 --- /dev/null +++ b/tests/pdom/1.dot @@ -0,0 +1,5 @@ +digraph { +label="Post Dominator Tree" +9 -> 5; +9 -> 7; +} diff --git a/tests/pdom/2.dot b/tests/pdom/2.dot new file mode 100644 index 0000000..1ac05a2 --- /dev/null +++ b/tests/pdom/2.dot @@ -0,0 +1,27 @@ +digraph { +label="Post Dominator Tree" +22 -> 21; +10 -> 5; +23 -> 22; +15 -> 10; +24 -> 23; +20 -> 15; +25 -> 9; +25 -> 18; +25 -> 14; +25 -> 19; +25 -> 24; +25 -> 20; +25 -> 2; +25 -> 13; +25 -> 17; +25 -> 8; +25 -> 4; +25 -> 12; +25 -> 16; +25 -> 7; +25 -> 3; +25 -> 11; +25 -> 6; +25 -> 1; +} diff --git a/tests/pdom/3.dot b/tests/pdom/3.dot new file mode 100644 index 0000000..8b67f45 --- /dev/null +++ b/tests/pdom/3.dot @@ -0,0 +1,3 @@ +digraph { +label="Post Dominator Tree" +} diff --git a/tests/pdom/4.dot b/tests/pdom/4.dot new file mode 100644 index 0000000..97b63b6 --- /dev/null +++ b/tests/pdom/4.dot @@ -0,0 +1,22 @@ +digraph { +label="Post Dominator Tree" +19 -> 18; +20 -> 8; +20 -> 5; +20 -> 9; +20 -> 6; +20 -> 19; +20 -> 10; +20 -> 7; +20 -> 2; +20 -> 4; +20 -> 3; +20 -> 1; +15 -> 14; +16 -> 15; +17 -> 16; +18 -> 17; +14 -> 13; +12 -> 11; +13 -> 12; +} diff --git a/tests/pdom/5.dot b/tests/pdom/5.dot new file mode 100644 index 0000000..d05f558 --- /dev/null +++ b/tests/pdom/5.dot @@ -0,0 +1,4 @@ +digraph { +label="Post Dominator Tree" +137 -> 133; +} diff --git a/tests/pdom/6.dot b/tests/pdom/6.dot new file mode 100644 index 0000000..d05f558 --- /dev/null +++ b/tests/pdom/6.dot @@ -0,0 +1,4 @@ +digraph { +label="Post Dominator Tree" +137 -> 133; +} diff --git a/tests/pdom/7.dot b/tests/pdom/7.dot new file mode 100644 index 0000000..295a511 --- /dev/null +++ b/tests/pdom/7.dot @@ -0,0 +1,6 @@ +digraph { +label="Post Dominator Tree" +2 -> 1; +3 -> 2; +4 -> 3; +} diff --git a/tests/pdom/8.dot b/tests/pdom/8.dot new file mode 100644 index 0000000..b92ba3f --- /dev/null +++ b/tests/pdom/8.dot @@ -0,0 +1,32 @@ +digraph { +label="Post Dominator Tree" +20 -> 15; +30 -> 3; +30 -> 4; +30 -> 6; +30 -> 7; +30 -> 8; +30 -> 9; +30 -> 11; +30 -> 12; +30 -> 13; +30 -> 14; +30 -> 16; +30 -> 17; +30 -> 18; +30 -> 19; +30 -> 25; +30 -> 29; +30 -> 28; +30 -> 27; +30 -> 26; +30 -> 24; +30 -> 23; +30 -> 22; +30 -> 21; +30 -> 2; +30 -> 1; +25 -> 20; +15 -> 10; +10 -> 5; +} diff --git a/tests/run_tests.py b/tests/run_tests.py index cea1921..3e186f6 100644 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -1,19 +1,19 @@ import argparse import os import subprocess +import tempfile import glob CURRENT_PATH = os.path.abspath(os.path.dirname(__file__)) PATH_TO_INPUT = os.path.join(CURRENT_PATH, "in") -def get_dot_file_path(input_path): - return os.path.join( - (os.path.dirname(input_path)), os.path.pardir) + "/out/" + ( - os.path.basename(input_path).replace('.in', '.dot')) +def get_dot_file_path(input_path, output_path): + return os.path.join(os.path.dirname(input_path), os.path.pardir, output_path, + os.path.basename(input_path).replace('.in', '.dot')) -def get_reference_dot(ans_file): +def read_file(ans_file): with open(ans_file, 'r') as af: return af.read() @@ -22,27 +22,43 @@ def test(executable): fail = False for input_path in glob.glob(os.path.join(PATH_TO_INPUT, '*')): - ans_path = get_dot_file_path(input_path) + ans_path = get_dot_file_path(input_path, "out") + dom_path = get_dot_file_path(input_path, "dom") + pdom_path = get_dot_file_path(input_path, "pdom") + with open(input_path, 'r') as input_file: - process = subprocess.run([executable], - stdin=input_file, - text=True, - capture_output=True) - if process.returncode != 0: - raise RuntimeError( - f'Driver failed on test {input_path}: {process.stderr}') - output = process.stdout - ref_output = get_reference_dot(ans_path) - if (output != ref_output): - print(f"Test {input_path} failed\n" - f"Expected: {ref_output}\n" - f"Actual: {output}\n") - fail = True - else: - print(f"Test {ans_path} passed") + with tempfile.NamedTemporaryFile() as dom, tempfile.NamedTemporaryFile( + ) as pdom: + process = subprocess.run( + [executable, f"--domtree={dom.name}", f"--pdomtree={pdom.name}"], + stdin=input_file, + text=True, + capture_output=True) + if process.returncode != 0: + raise RuntimeError( + f'Driver failed on test {input_path}: {process.stderr}') + + output = process.stdout + odom = read_file(dom.name) + opdom = read_file(pdom.name) + ref_output = read_file(ans_path) + ref_dom = read_file(dom_path) + ref_pdom = read_file(pdom_path) + + if (output != ref_output): + print(f"Test {input_path} failed: graph") + fail = True + if (odom != ref_dom): + print(f"Test {input_path} failed: dominators") + fail = True + if (opdom != ref_pdom): + print(f"Test {input_path} failed: postdominators") + fail = True + else: + print(f"Test {ans_path} passed") if fail: - raise RuntimeError("End-to-end test failed\n") + raise RuntimeError("End-to-end test failed") if __name__ == "__main__": diff --git a/tests/unit_tests.cc b/tests/unit_tests.cc index eaf7c03..73259d6 100644 --- a/tests/unit_tests.cc +++ b/tests/unit_tests.cc @@ -1,7 +1,6 @@ #include #include -#include #include #include "graphs/graph.hh"