Action Buttons and Controls
Relevant source files
The following files were used as context for generating this wiki page:The "Network Analyzer" is a C# Windows Forms application designed for analyzing network graph properties. Its user interface provides controls for loading network data, triggering complex calculations, and visualizing the results. The primary user action is loading an edgelist file, which initiates a sequence of data processing and analysis steps, including calculating degree distribution, clustering coefficients, and degree correlation.
The main application logic is encapsulated within the Form1 class, which serves as both the UI container and the orchestrator for the analysis pipeline. The application starts by initializing the main form, Form1, which contains all the interactive controls and chart displays.
Sources: Program.cs:17-19, Form1.cs, Form1.Designer.cs, README.md:5
UI Components Overview
The main window of the "Network Analyzer" is composed of several key controls defined in Form1.Designer.cs. These components allow the user to load data, configure analysis parameters, and view results.
| Control Name | Type | Description | Source File |
|---|---|---|---|
menuStrip1 | MenuStrip | The main menu bar at the top of the window. | Form1.Designer.cs:186 |
openToolStripMenuItem | ToolStripMenuItem | A menu item under "File" that opens a dialog to select a network data file. Triggers the main analysis. | Form1.Designer.cs:205 |
chkClustering | CheckBox | A checkbox to enable or disable the calculation of the average clustering coefficient. | Form1.Designer.cs:238 |
txtCutoff | TextBox | An input field to set the minimum degree cutoff for the cumulative degree distribution power-law fit. | Form1.Designer.cs:266 |
chart1 | Chart | Displays the "Degree Correlation" plot. | Form1.Designer.cs:81 |
chart2 | Chart | Displays the "Cumulative Degree Distribution" plot. | Form1.Designer.cs:246 |
textBox1 | TextBox | A multi-line text box used to display the status of ongoing calculations. | Form1.Designer.cs:95 |
lbl* | Label | A series of labels used to display calculated network metrics (e.g., Nodes, Links, Mean Degree). | Form1.Designer.cs |
Sources: Form1.Designer.cs
Core Action: File Loading and Analysis
The central workflow of the application is initiated when the user clicks the File -> Open menu item. This action is handled by the openToolStripMenuItem_Click event handler.
Sources: Form1.cs:211-344, Form1.Designer.cs:208-209
Event Handling and Data Flow
The following sequence diagram illustrates the process from user interaction to the final display of results.
This diagram shows the sequence initiated by the openToolStripMenuItem_Click event.
Sources: Form1.cs:211-344
Data Processing Pipeline
Once a file is loaded, the data undergoes several transformations before being visualized.
- Edge List Creation: The file, assumed to be a tab-separated edgelist, is read line by line. Each line is parsed into an
Edgeobject and stored in aList<Edge>. - Node List Construction: The
edgelistis passed to theNodeListconstructor. This class builds a unique list ofNodeobjects, calculates the degree for each node, and identifies neighbors. It also computes properties like self-links and duplicate links. - Metrics Calculation: Basic network metrics are calculated and displayed. The average degree is computed as
2 * links / nodes. - Analysis and Visualization: More complex analyses for degree correlation and distribution are performed. The results are used to populate
chart1andchart2.
The following diagram illustrates this data pipeline.
Sources: Form1.cs:213-342
Analysis Controls
Clustering Coefficient Checkbox (chkClustering)
The chkClustering checkbox controls whether the computationally intensive average clustering coefficient is calculated.
- If checked: The
nodelist.Clustering()method is called. This method iterates through each node's neighbors to find connections between them, calculating the local clustering coefficient for each node and then averaging them. - If unchecked: This calculation is skipped, saving processing time.
// Form1.cs:248
if (chkClustering.Checked) lblCluster.Text = "Average clustering coefficient: " + String.Format("{0:n3}", nodelist.Clustering(edgelist, textBox1));
Sources: Form1.cs:175-193, 248, Form1.Designer.cs:238-244
Cutoff Textbox (txtCutoff)
The txtCutoff textbox allows the user to specify a minimum degree (k_min) for the power-law fit on the cumulative degree distribution plot (chart2). This is useful for excluding the lower-degree regime, which often deviates from a pure power law in real-world networks.
- The value is read from
txtCutoff.Textand converted to an integer. - A "shadow" series is created containing only data points with a degree greater than the cutoff.
- The power-law regression (
MathNet.Numerics.Fit.Power) is performed only on this shadow series.
// Form1.cs:302
int cutoff = Convert.ToInt32(txtCutoff.Text);
Series shadow = new Series();
double prev = 1;
for (int deg = 1; deg <= max; deg++)
{
// ...
distro.Points.Add(new DataPoint(deg, prev));
if (deg > cutoff) shadow.Points.Add(new DataPoint(deg, prev)); // Add to shadow series if degree > cutoff
prev = prev - count / nodes;
}
// ...
Tuple<double, double> r2 = MathNet.Numerics.Fit.Power(X2Values, Y2Values); // Fit is performed on shadow series data
Sources: Form1.cs:302-323, Form1.Designer.cs:266-273
Internal Data Structures
The analysis logic relies on a set of nested classes within Form1.cs to model the network.
This diagram shows the relationship between the main data-holding classes used during analysis.
Sources: Form1.cs:54-194
Conclusion
The action buttons and controls of the Network Analyzer provide a user-friendly interface for a powerful set of network analysis functions. The core functionality is triggered by a single user action—opening a file—which sets off a well-defined pipeline of data parsing, metric calculation, and statistical analysis. The inclusion of controls like chkClustering and txtCutoff gives the user flexibility to manage performance and refine the analysis, demonstrating a thoughtful design that balances automation with user control. The application effectively leverages the System.Windows.Forms framework for the UI and the MathNet.Numerics library for complex calculations.
Sources: Form1.cs, Form1.Designer.cs