Skip to content

Commit c7306ec

Browse files
committed
improving scaling
1 parent 6245f83 commit c7306ec

File tree

8 files changed

+206
-13
lines changed

8 files changed

+206
-13
lines changed

.github/workflows/ccpp.yml

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,52 @@
1+
12
name: C/C++ CI
23

3-
on: [push]
4+
on: [push, pull_request]
45

56
jobs:
67
build:
7-
88
runs-on: ubuntu-latest
99

1010
steps:
11-
- uses: actions/checkout@v1
12-
- name: ghaction-cmake
13-
uses: lpenz/ghaction-cmake@v0.1
14-
with:
15-
dependencies: libwxgtk3.0-dev libwxbase3.0-dev
16-
11+
- uses: actions/checkout@v3
12+
13+
- name: Install dependencies
14+
run: |
15+
sudo apt-get update
16+
sudo apt-get install -y libwxgtk3.0-gtk3-dev libwxbase3.0-dev
17+
sudo apt-get install -y libboost-all-dev
18+
sudo apt-get install -y build-essential
19+
sudo apt-get install -y cmake
20+
21+
- name: Create build directory
22+
run: mkdir build
23+
24+
- name: Configure CMake
25+
run: |
26+
cd build
27+
cmake ..
28+
29+
- name: Build
30+
run: |
31+
cd build
32+
cmake --build .
33+
34+
- name: Run tests
35+
run: |
36+
cd build
37+
ctest --output-on-failure
38+
39+
- name: Install gcovr
40+
run: sudo apt-get install -y gcovr
41+
42+
- name: Generate coverage report
43+
run: |
44+
cd build
45+
gcovr -r .. --html --html-details -o coverage.html
46+
47+
- name: Upload coverage report
48+
uses: actions/upload-artifact@v3
49+
with:
50+
name: coverage-report
51+
path: build/coverage.html
52+

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build/
2+
cmake-build-debug/
3+
cmake-build-release/

CGTeaApp.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626

2727
bool CGTeaApp::OnInit()
2828
{
29-
auto *sizer = new wxBoxSizer(wxHORIZONTAL);
30-
auto *frame = new CGTeaFrame("CGTea", wxPoint(100, 100), wxSize(1200, 600) );
31-
auto *cgTeaSidebar = new CGTeaSidebar(frame, wxID_ANY);
29+
auto sizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
30+
auto frame = new CGTeaFrame("CGTea", wxPoint(100, 100), wxSize(1200, 600) );
31+
auto cgTeaSidebar = new CGTeaSidebar(frame, wxID_ANY);
3232
drawPane = new BasicDrawPane( frame );
3333
sizer->Add(cgTeaSidebar, 1, wxEXPAND | wxALL);
3434
sizer->Add(drawPane, 4, wxEXPAND | wxALL);
35-
frame->SetSizer(sizer);
35+
frame->SetSizer(sizer.release());
3636
frame->SetAutoLayout(true);
3737
frame->SetIcon(wxIcon(wxT("gtea.xpm")));
3838
frame->Show( true );

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
cmake_minimum_required(VERSION 3.10)
22
project(CGTea)
33
set(CMAKE_CXX_STANDARD 17)
4+
enable_testing()
45
find_package(wxWidgets REQUIRED COMPONENTS net core base)
56
include(${wxWidgets_USE_FILE})
67
include_directories(${Boost_INCLUDE_DIRS})
@@ -9,8 +10,12 @@ file(GLOB Reports "reports/*.cpp")
910
file(GLOB Generators "generators/*.cpp")
1011
file(GLOB Actions "actions/*.cpp")
1112
file(GLOB ConjectureCheck "ConjectureCheck/*.cpp")
13+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
1214
#set( CMAKE_CXX_FLAGS "`wx-config --cxxflags --libs`")
1315
add_executable(CGTea CGTeaApp.cpp BasicDrawPane.cpp CGTeaFrame.cpp CGTeaSidebar.cpp ${Reports} ${Generators} ${Actions})
14-
add_executable(BoostTest ${Reports} ${Generators} ${BoostTestSrc} ${ConjectureCheck} ${Actions})
16+
add_executable(BoostTest ${Reports} ${Generators} ${BoostTestSrc} ${ConjectureCheck} ${Actions}
17+
tests/test_generator.cpp
18+
tests/test_index.cpp
19+
tests/test_g6format.cpp)
1520
target_link_libraries(CGTea ${wxWidgets_LIBRARIES} ${Boost_LIBRARIES})
1621
target_link_libraries(BoostTest ${Boost_LIBRARIES})

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ There are three main dependencies for this project:
1616
```
1717
1818
Please note that the project is in active development, and contributions are welcome. For more information, please refer to the source code and comments therein.
19+
20+
### Tests
21+
![C/C++ CI](https://github.com/{username}/{repository}/workflows/C/C++%20CI/badge.svg)

tests/test_g6format.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//
2+
// Created by rostam on 15.05.25.
3+
//
4+
5+
#define BOOST_TEST_DYN_LINK
6+
#include <boost/test/unit_test.hpp>
7+
#include "../G6Format.h"
8+
9+
BOOST_AUTO_TEST_SUITE(G6FormatTests)
10+
11+
BOOST_AUTO_TEST_CASE(test_graph_size_detection)
12+
{
13+
G6Format g6;
14+
// Test small graph (n ≤ 62)
15+
BOOST_CHECK_EQUAL(g6.graphsize("A_"), 1);
16+
BOOST_CHECK_EQUAL(g6.graphsize("B?"), 2);
17+
18+
// Test larger graph
19+
BOOST_CHECK_EQUAL(g6.graphsize(":?@"), 63);
20+
}
21+
22+
BOOST_AUTO_TEST_CASE(test_empty_graph_conversion)
23+
{
24+
G6Format g6;
25+
Graph g;
26+
boost::add_vertex(g);
27+
boost::add_vertex(g);
28+
29+
std::string g6str = g6.graphToG6(g);
30+
Graph decoded = g6.stringToGraph(g6str);
31+
32+
BOOST_CHECK_EQUAL(boost::num_vertices(decoded), 2);
33+
BOOST_CHECK_EQUAL(boost::num_edges(decoded), 0);
34+
}
35+
36+
BOOST_AUTO_TEST_CASE(test_simple_graph_conversion)
37+
{
38+
G6Format g6;
39+
Graph g;
40+
boost::add_vertex(g);
41+
boost::add_vertex(g);
42+
boost::add_vertex(g);
43+
boost::add_edge(0, 1, g);
44+
boost::add_edge(1, 2, g);
45+
46+
std::string g6str = g6.graphToG6(g);
47+
Graph decoded = g6.stringToGraph(g6str);
48+
49+
BOOST_CHECK_EQUAL(boost::num_vertices(decoded), 3);
50+
BOOST_CHECK_EQUAL(boost::num_edges(decoded), 2);
51+
52+
// Check that specific edges exist
53+
BOOST_CHECK(boost::edge(0, 1, decoded).second);
54+
BOOST_CHECK(boost::edge(1, 2, decoded).second);
55+
BOOST_CHECK(!boost::edge(0, 2, decoded).second);
56+
}
57+
58+
BOOST_AUTO_TEST_SUITE_END()

tests/test_generator.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#define BOOST_TEST_DYN_LINK
2+
#include <boost/test/unit_test.hpp>
3+
#include "../generators/CocktailParty.h"
4+
5+
BOOST_AUTO_TEST_SUITE(CocktailPartyTests)
6+
7+
BOOST_AUTO_TEST_CASE(test_cocktail_party_basic_properties)
8+
{
9+
CocktailParty generator;
10+
// Test with 2 pairs (4 vertices)
11+
Graph g = generator.generate_with_positions(2, 0, 100, 100);
12+
13+
// Check number of vertices
14+
BOOST_CHECK_EQUAL(boost::num_vertices(g), 4);
15+
16+
// Check number of edges
17+
// In a cocktail party graph with n pairs:
18+
// Each vertex connects to everyone except its pair
19+
// So each vertex has 2n-2 edges
20+
// Total edges = n * (2n-2) / 2 = n(n-1)
21+
BOOST_CHECK_EQUAL(boost::num_edges(g), 4);
22+
23+
// Check that pairs are not connected
24+
BOOST_CHECK(!boost::edge(0, 2, g).second);
25+
BOOST_CHECK(!boost::edge(1, 3, g).second);
26+
}
27+
28+
BOOST_AUTO_TEST_CASE(test_cocktail_party_connectivity)
29+
{
30+
CocktailParty generator;
31+
Graph g = generator.generate_with_positions(3, 0, 100, 100);
32+
33+
// For 3 pairs (6 vertices), each vertex should have 4 connections
34+
// (connects to all except its pair)
35+
for(unsigned int i = 0; i < 3; ++i) {
36+
int degree_i = boost::out_degree(i, g);
37+
BOOST_CHECK_EQUAL(degree_i, 4);
38+
39+
int degree_i_pair = boost::out_degree(i + 3, g);
40+
BOOST_CHECK_EQUAL(degree_i_pair, 4);
41+
}
42+
}
43+
44+
BOOST_AUTO_TEST_SUITE_END()

tests/test_index.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//
2+
// Created by rostam on 15.05.25.
3+
//
4+
5+
#define BOOST_TEST_DYN_LINK
6+
#include <boost/test/unit_test.hpp>
7+
#include "../reports/AdditiveHarary.h"
8+
#include <boost/graph/adjacency_list.hpp>
9+
10+
BOOST_AUTO_TEST_SUITE(AdditiveHararyTests)
11+
12+
BOOST_AUTO_TEST_CASE(test_empty_graph)
13+
{
14+
Graph g;
15+
AdditiveHararyIndex harary;
16+
BOOST_CHECK_EQUAL(harary.report(g), "0");
17+
}
18+
19+
BOOST_AUTO_TEST_CASE(test_single_edge)
20+
{
21+
Graph g;
22+
boost::add_vertex(g);
23+
boost::add_vertex(g);
24+
boost::add_edge(0, 1, g);
25+
26+
AdditiveHararyIndex harary;
27+
BOOST_CHECK_EQUAL(harary.report(g), "1");
28+
}
29+
30+
BOOST_AUTO_TEST_CASE(test_triangle)
31+
{
32+
Graph g;
33+
boost::add_vertex(g);
34+
boost::add_vertex(g);
35+
boost::add_vertex(g);
36+
boost::add_edge(0, 1, g);
37+
boost::add_edge(1, 2, g);
38+
boost::add_edge(2, 0, g);
39+
40+
AdditiveHararyIndex harary;
41+
BOOST_CHECK_EQUAL(harary.report(g), "3");
42+
}
43+
44+
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)