UI Overview
Relevant source files
The following files were used as context for generating this wiki page:The Network Science project includes a C# Windows Forms application titled "Network Analyzer". This tool serves as the primary user interface for loading network graph data from files, performing a series of statistical analyses, and visualizing the results. The application is designed to compute and display key network properties such as degree distribution, clustering coefficients, and degree correlation, which are fundamental concepts in network science. It allows users to interactively load a dataset and immediately see its structural properties visualized in charts.
The application is a single-form project that encapsulates all logic for file parsing, network metric calculation, and data visualization. It relies on the System.Windows.Forms.DataVisualization.Charting library for plotting and MathNet.Numerics for regression analysis. The overall project also contains separate command-line tools for network generation and analysis, but this document focuses specifically on the "Network Analyzer" GUI.
Sources: Form1.Designer.cs:338, README.md:3-5, Form1.cs:15
Application Architecture
The application is a standard Windows Forms project. The entry point is the Main method in Program.cs, which initializes and runs Form1. Form1 is the main and only window of the application, containing all UI elements and the event-handling logic for data processing and visualization.
Sources: Program.cs:13-19
Core Classes
The application's logic is built around a set of classes that model the network structure. These classes are defined within the Form1.cs file.
This diagram shows the relationship between the main form and the data model classes. Form1 orchestrates the creation of a NodeList from a list of Edge objects.
Sources: Form1.cs:52-192
UI Components
The user interface is defined in Form1.Designer.cs and consists of a menu, informational labels, two charts, and a few input controls.
| Component ID | Type | Description |
|---|---|---|
menuStrip1 | MenuStrip | Main menu bar containing the "File" menu. |
openToolStripMenuItem | ToolStripMenuItem | Menu item under "File" to open a network data file. |
lblDataset, lblNodes, lblLinks, etc. | Label | Display various calculated network statistics like node/link counts, degrees, and clustering. |
textBox1 | TextBox | A multi-line text box used to display the status of ongoing calculations. |
txtCutoff | TextBox | Input for setting the minimum degree cutoff for the power-law fit on the degree distribution chart. |
chkClustering | CheckBox | A checkbox to enable or disable the calculation of the average clustering coefficient, which can be time-consuming. |
chart1 | Chart | Displays the "Degree Correlation" plot. |
chart2 | Chart | Displays the "Cumulative Degree Distribution" plot. |
Sources: Form1.Designer.cs
Data Processing Workflow
The entire analysis process is triggered by the user selecting a file via the "File" -> "Open" menu item. The openToolStripMenuItem_Click event handler orchestrates the reading of the file, calculation of metrics, and updating of the UI.
The following flowchart illustrates the sequence of operations:
This diagram shows the step-by-step process from file selection to the final rendering of the charts and metrics.
Sources: Form1.cs:200-353
Analysis and Visualization
The application focuses on two primary visualizations to characterize the network.
Degree Correlation (chart1)
This chart visualizes the correlation between the degree of a node and the average degree of its neighbors.
- Data Generation: For each degree value
kpresent in the network, the code calculates the average ofneighbors_degreefor all nodes with degreek. Theneighbors_degreefor a single node is the mean degree of its direct neighbors. - Visualization: The chart is a log-log plot showing the calculated average neighbor degree (
accum/count) versus the degree (deg). It is rendered as a point chart. - Regression: A power-law function is fitted to these points using
MathNet.Numerics.Fit.Power. The resulting regression line is overlaid on the chart in red to show the trend. The calculated exponent is displayed in thelblCorrelationlabel.
Sources: Form1.cs:150-157, 252-290
Cumulative Degree Distribution (chart2)
This chart shows the cumulative probability distribution of node degrees, which is a key indicator of whether a network is scale-free.
- Data Generation: The code iterates from degree 1 to the maximum degree. For each degree
k, it calculatesP(degree >= k), which is the fraction of nodes with a degree ofkor higher. - Visualization: The chart is a log-log plot of the cumulative probability versus the degree
k. It is rendered as a point chart. - Regression and Gamma Exponent: A power-law fit is applied to the tail of this distribution. The start of the tail is determined by the
txtCutoffvalue. The exponent of this fit (exp2) is used to calculate the network's degree exponent, gamma, using the formulagamma = 1 - exp2. The regression line is plotted in red, and the gamma value is displayed in thelblGammalabel.
Sources: Form1.cs:313-353
Network Metrics Calculation
Upon loading a file, several fundamental network metrics are calculated and displayed.
| Metric | UI Label | Calculation Logic | Source |
|---|---|---|---|
| Dataset | lblDataset | The name of the loaded file. | Form1.cs:241-242 |
| Nodes | lblNodes | Total count of unique nodes in the NodeList. | Form1.cs:244 |
| Links | lblLinks | Total count of edges in the edgelist. | Form1.cs:243 |
| Average Degree | lblMean | (2 * links) / nodes | Form1.cs:245 |
| Self Links | lblSelf | Count of edges where a == b. | Form1.cs:111, 246 |
| Duplicate Links | lblDupe | Count of edges that are identical to another edge. | Form1.cs:112-113, 247 |
| Max Degree | lblMax | The highest degree found across all nodes. | Form1.cs:128, 248 |
| Min Degree | lblMin | The lowest degree found across all nodes. | Form1.cs:129, 249 |
| Avg. Clustering | lblCluster | The average of the local clustering coefficient for all nodes. | Form1.cs:170-188, 250 |
Conclusion
The "Network Analyzer" is a focused GUI tool for empirical analysis of network structures. It provides a user-friendly way to load an edgelist, compute a standard set of network metrics, and, most importantly, visualize the degree correlation and cumulative degree distribution. The inclusion of power-law regression fitting directly on the charts allows for a quick assessment of scale-free properties and the calculation of critical exponents like gamma, aligning with the project's goal of providing tools for studying concepts from the Barabasi Network Science textbook.
Sources: README.md