abg

Animated background for X11
git clone git://git.laack.co/abg.git
Log | Files | Refs | README | LICENSE

snapshot_shared.cpp (1755B)


      1 #include <catch2/catch_test_macros.hpp>
      2 #include <queue>
      3 #include <unordered_set>
      4 
      5 #include "../include/graph.hpp"
      6 #include "../include/prim.hpp"
      7 
      8 Graph basicGraphSerialization() {
      9     int vertCount = 10;
     10     int edgeCount = 10;
     11     float xMax = 10;
     12     float yMax = 10;
     13     auto g = Graph(edgeCount, vertCount, xMax, yMax, 42);
     14     return g;
     15 }
     16 
     17 Graph fullTraversalSerialization() {
     18     std::size_t edgeCount = 1;
     19     std::size_t vertCount = 2;
     20 
     21     float xMax = 5120;
     22     float yMax = 1440;
     23 
     24     Graph g = Graph(edgeCount, vertCount, xMax, yMax, 52);
     25     std::unordered_set<std::size_t> visitedIndices{};
     26     std::priority_queue<Edge, std::vector<Edge>, std::greater<Edge>> toVisit{};
     27     std::vector<Edge> edges = g.getEdgesOfVertexIdx(0);
     28     std::vector<double> minEdgeToVertex(vertCount, -1);
     29 
     30     for (auto edge : edges) {
     31         toVisit.push(edge);
     32     }
     33 
     34     g.traverseVertexIdx(0);
     35     visitedIndices.insert(0);
     36 
     37     while (toVisit.size() != 0) {
     38         oneStepPrim(toVisit, visitedIndices, g, minEdgeToVertex);
     39     }
     40 
     41     return g;
     42 }
     43 
     44 Graph fullTraversalLargerSerialization() {
     45     std::size_t edgeCount = 25;
     46     std::size_t vertCount = 15;
     47 
     48     float xMax = 5120;
     49     float yMax = 1440;
     50 
     51     Graph g = Graph(edgeCount, vertCount, xMax, yMax, 61);
     52     std::unordered_set<std::size_t> visitedIndices{};
     53     std::priority_queue<Edge, std::vector<Edge>, std::greater<Edge>> toVisit{};
     54     std::vector<Edge> edges = g.getEdgesOfVertexIdx(0);
     55     std::vector<double> minEdgeToVertex(vertCount, -1);
     56 
     57     for (auto edge : edges) {
     58         toVisit.push(edge);
     59     }
     60 
     61     g.traverseVertexIdx(0);
     62     visitedIndices.insert(0);
     63 
     64     while (toVisit.size() != 0) {
     65         oneStepPrim(toVisit, visitedIndices, g, minEdgeToVertex);
     66     }
     67 
     68     return g;
     69 }