Testing Strategy
Relevant source files
The following files were used as context for generating this wiki page:The Network-Science project does not employ a formal, automated testing strategy. Analysis of the source code reveals no use of standard unit testing frameworks (like NUnit, xUnit, or PyTest) or automated test suites. Instead, the project relies on a combination of manual execution, visual verification of generated plots, and standalone scripts for data generation and simulation.
This approach is common in exploratory scientific computing and data analysis projects, where the primary goal is to experiment with algorithms and visualize results. The "correctness" of the implementation is often judged by whether the output aligns with established scientific models and visual inspection, rather than by programmatic assertions.
Manual and Visual Testing (C# Network Analyzer)
The primary C# application is a Windows Forms tool for analyzing network graph data. Its testing is entirely manual, centered on loading a dataset and visually inspecting the calculated metrics and charts displayed in the UI.
Sources: Form1.cs, Form1.Designer.cs, Program.cs
UI-Driven Test Flow
The main testing workflow is initiated by a user through the UI. The user opens a file, the application processes it, and the results are displayed. There are no automated checks to validate the outputs.
- Application Start: The application is launched, running
Form1.
Sources: Program.cs:17-19 - Initial Chart Test: On form load, the
Form1_Loadevent handler populates two charts with simple, hardcoded mathematical functions. This serves as a basic visual test to ensure the charting components are initialized and rendering correctly.
Sources: Form1.cs:21-34 - User Action: The user clicks "File" -> "Open" to select a network edgelist file.
Sources: Form1.Designer.cs:141-145, Form1.cs:192 - Data Processing: The
openToolStripMenuItem_Clickevent handler reads the file, builds an edge list and node list, and calculates various network metrics (degree, clustering, correlation).
Sources: Form1.cs:194-257 - Visual Verification: The calculated metrics are displayed in labels (
lblNodes,lblLinks, etc.), and the degree correlation and distribution are plotted on two charts. The user must visually inspect these values and plots to determine if the analysis is correct.
Sources: Form1.cs:217-226, Form1.cs:280-290, Form1.cs:342-352
The following diagram illustrates this manual testing and verification flow.
Sources: Form1.cs, Form1.Designer.cs
Core Data Structures
The core data structures for network representation are defined within Form1.cs. These classes do not have any associated unit tests to verify their behavior in isolation.
| Class | Properties | Description |
|---|---|---|
Edge | int a, int b | Represents a link between two nodes. |
Node | node_ID, degree, neighbors, clustering, neighbors_degree | Represents a node and its calculated properties. |
NodeList | nodelist, selfies, dupes, max_degree, min_degree | A collection class that manages all nodes and performs network-wide calculations like clustering. |
Sources: Form1.cs:46-187
Script-Based Analysis (Python)
The Python script Network.py provides an alternative method for analyzing a network's degree distribution. Similar to the C# application, its testing relies on running the script and visually inspecting the output.
Sources: Network.py
Execution and Verification Flow
The script executes a linear sequence of steps to produce an HTML file containing a plot.
- Hardcoded Input: The script reads from a hardcoded file path (
F:\\Math\\Network Science\\www.edgelist.txt).
Sources: Network.py:10 - Data Processing: It uses
pandasandnumpyto calculate the degree distribution, perform logarithmic binning, and compute a linear regression on the log-log data to find the degree exponent (gamma).
Sources: Network.py:14-46 - Output Generation: It uses
bokehto generate an interactive plot and saves it aschart.htm.
Sources: Network.py:53-63 - Visual Verification: The user must open
chart.htmin a web browser to view the degree distribution plot and the fitted regression line to verify the results.
This diagram shows the script's execution flow for analysis.
Sources: Network.py
Data Generation and Simulation
The repository includes scripts whose primary purpose is to generate synthetic data or run simulations. These are not tests themselves, but they produce datasets that can be used as inputs for the analysis tools.
Barabasi-Albert Network Generation
Barabasi.cs is a console application that generates a scale-free network using the Barabasi-Albert preferential attachment model. Its Main method contains hardcoded parameters to generate a specific network.
// Barabasi.cs:9-15
static void Main(string[] args)
{
int nodes = 10000;
int degree = 3;
int prob = 50;
bool sociable = false;
System.IO.StreamWriter file = new System.IO.StreamWriter("F:\\Math\\Network Science\\dissociative.edgelist.txt");
Edgelist edgelist = new Edgelist(nodes, degree, true);
// ...
}
This script acts as a "test data generator." The generated dissociative.edgelist.txt can then be loaded into the C# Network Analyzer or Network.py to test their functionality with a known type of network structure.
Sources: Barabasi.cs:7-17
Population Selection Simulation
The Selection.py script simulates population change under selection pressure. At each generation, it generates a plot using matplotlib and displays it. The "test" is to run the simulation and observe the sequence of plots to see if the population's trait mean evolves as expected by the model.
Sources: Selection.py:27-33
Conclusion
The testing strategy for the Network-Science project is informal and heavily reliant on manual processes and visual confirmation. While this is suitable for the project's apparent goal as a collection of study programs for personal learning and exploration, it lacks the rigor of automated testing. There are no safeguards against regressions, and verifying the correctness of complex calculations depends entirely on the user's expertise in interpreting the output data and plots.
Sources: README.md