1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
/*
* $Revision: 3987 $
*
* last checkin:
* $Author: beyer $
* $Date: 2014-03-27 16:53:39 +0100 (Thu, 27 Mar 2014) $
***************************************************************/
/** \file
* \brief Implementation of a command line based tool to run
* tests.
*
* \author Christoph Schulz
*
* \par License:
* This file is part of the Open Graph Drawing Framework (OGDF).
*
* \par
* Copyright (C)<br>
* See README.txt in the root directory of the OGDF installation for details.
*
* \par
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* Version 2 or 3 as published by the Free Software Foundation;
* see the file LICENSE.txt included in the packaging of this file
* for details.
*
* \par
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* \par
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* \see http://www.gnu.org/copyleft/gpl.html
***************************************************************/
#include "gtest/gtest.h"
#include "ogdf/basic/Graph.h"
#include "ogdf/basic/graph_generators.h"
static unsigned int randomSeed = 8609;
//void randomize(unsigned int seed)
//{
// randomSeed = seed + 123456;
//}
double randomNumber()
{
const unsigned int a = 16807;
const unsigned int c = 0;
const unsigned int m = 0x7fffffff;
randomSeed = (a * randomSeed + c) & m;
return static_cast<double>(randomSeed) / m;
}
TEST(GeneratorsTest, RandomGraph)
{
const int n = static_cast<int>(randomNumber() * 10 + 5);
const int m = std::max(n + 1, static_cast<int>((randomNumber() * n * (n - 1) / 2)));
ogdf::Graph G;
ogdf::randomGraph(G, n, m);
}
TEST(GeneratorsTest, RandomSimpleGraph)
{
const int n = static_cast<int>(randomNumber() * 10 + 5);
const int m = std::max(n + 1, static_cast<int>((randomNumber() * n * (n - 1) / 2)));
ogdf::Graph G;
ogdf::randomSimpleGraph(G, n, m);
}
TEST(GeneratorsTest, RandomBiconnectedGraph)
{
const int n = static_cast<int>(randomNumber() * 10 + 5);
const int m = std::max(n + 1, static_cast<int>((randomNumber() * n * (n - 1) / 2)));
ogdf::Graph G;
ogdf::randomBiconnectedGraph(G, n, m);
}
TEST(GeneratorsTest, RandomTriconnectedGraph)
{
const int n = static_cast<int>(randomNumber() * 10 + 5);
double p = 0.618;
ogdf::Graph G;
ogdf::randomTriconnectedGraph(G, n, p, 1.0 - p);
}
TEST(GeneratorsTest, RandomTree1)
{
const int n = static_cast<int>(randomNumber() * 10 + 5);
ogdf::Graph G;
ogdf::randomTree(G, n);
}
TEST(GeneratorsTest, RandomTree2)
{
const int n = static_cast<int>(randomNumber() * 10 + 5);
ogdf::Graph G;
ogdf::randomTree(G, n, n / 2, 1024);
}
TEST(GeneratorsTest, RandomHierarchy)
{
const int n = static_cast<int>(randomNumber() * 10 + 5);
const int m = std::max(n + 1, static_cast<int>((randomNumber() * n * (n - 1) / 2)));
ogdf::Graph G;
ogdf::randomHierarchy(G, n, m, true, false, true);
}
TEST(GeneratorsTest, RandomDiGraph)
{
const int n = static_cast<int>(randomNumber() * 10 + 5);
double p = 0.618;
ogdf::Graph G;
ogdf::randomDiGraph(G, n, p);
}
|