Parameter Input Panel
Relevant source files
The following files were used as context for generating this wiki page:The Network Analyzer application, a Windows Forms application, features a user interface for controlling network analysis parameters. This panel allows users to modify settings that influence how network metrics are calculated and displayed. Specifically, users can set a cutoff for degree distribution analysis and toggle the calculation of the clustering coefficient. These inputs directly affect the data processing flow after a network file is loaded.
The project also includes separate scripts for network generation and analysis (Barabasi.cs, Network.py) which utilize hardcoded parameters rather than a graphical input panel. These scripts define network characteristics like the number of nodes, degree, and analysis type within the code itself.
Sources: Form1.cs, Form1.Designer.cs, Network.py, Barabasi.cs
GUI Parameter Controls (Form1)
The main application window (Form1) contains several controls for user input. The primary parameter inputs are a textbox for a numerical cutoff and a checkbox to enable a specific calculation. These controls are initialized in Form1.Designer.cs and their logic is handled in Form1.cs.
Sources: Form1.Designer.cs:281-298, Form1.cs:22-43, 355-358
UI Components
The following table details the key UI components for parameter input on Form1.
| Control Name | Type | Description | Location (File) |
|---|---|---|---|
txtCutoff | TextBox | Sets the minimum degree (cutoff) for the power-law fit of the cumulative degree distribution. | Form1.Designer.cs:281-288 |
chkClustering | CheckBox | Toggles the calculation of the average clustering coefficient for the loaded network. | Form1.Designer.cs:231-237 |
label1 | Label | A label with the text "Set Cutoff" associated with txtCutoff. | Form1.Designer.cs:289-295 |
Sources: Form1.Designer.cs:231-237, 281-295
Degree Distribution Cutoff (txtCutoff)
The txtCutoff textbox allows the user to specify a minimum degree value. This value is used to exclude nodes with degrees below the cutoff from the power-law regression analysis performed on the cumulative degree distribution. This helps in finding a more accurate degree exponent (gamma) for the tail of the distribution.
The value is read when the text changes and also when a file is opened and processed.
The diagram below shows the data flow from the user input in txtCutoff to its use in the analysis.
The following code snippet shows how the cutoff value is read and used to create the shadow series for regression.
// File: Form1.cs
// Reading the cutoff value
Series distro = new Series();
int cutoff = Convert.ToInt32(txtCutoff.Text); // line 302
Series shadow = new Series();
double prev = 1;
for (int deg = 1; deg <= max; deg++)
{
// ... (distribution calculation)
distro.Points.Add(new DataPoint(deg, prev));
if (deg > cutoff) shadow.Points.Add(new DataPoint(deg, prev)); // line 309
prev = prev - count / nodes;
}
// ... (Performing power-law fit on 'shadow' series)
Tuple<double, double> r2 = MathNet.Numerics.Fit.Power(X2Values, Y2Values); // line 321
double exp2 = r2.Item2;
lblGamma.Text = "Degree exponent (gamma): " + String.Format("{0:n3}", 1-exp2); // line 325
Sources: Form1.cs:301-311, 321-325
Clustering Coefficient Calculation (chkClustering)
The chkClustering checkbox controls whether the average clustering coefficient of the network is computed. This can be a computationally intensive task, so it is provided as an option. When a file is loaded, the application checks the state of this checkbox. If it is checked, the Nodelist.Clustering() method is called.
The sequence diagram below illustrates this conditional logic.
Sources: Form1.cs:238-239, Form1.Designer.cs:231-237
The check is performed within the file opening event handler:
// File: Form1.cs, line 238
if (chkClustering.Checked) lblCluster.Text = "Average clustering coefficient: " + String.Format("{0:n3}", nodelist.Clustering(edgelist, textBox1));
Sources: Form1.cs:238-239
Hardcoded Parameters in Scripts
In addition to the GUI application, the repository contains scripts that use hardcoded parameters for network generation and analysis.
Network Analysis Script (Network.py)
The Python script Network.py performs degree distribution analysis on a given edgelist file. Key parameters are defined as variables at the beginning of the script.
| Parameter | Type | Default Value | Description | Location (File) |
|---|---|---|---|---|
dataset | string | "www.edgelist.txt" | The name of the edgelist file to be analyzed. | Network.py:6 |
directed | boolean | True | Specifies if the graph is directed. | Network.py:7 |
want_in | boolean | True | If the graph is directed, specifies whether to analyze in-degree or out-degree. | Network.py:8 |
Sources: Network.py:6-8
Network Generation Script (Barabasi.cs)
The C# console application Barabasi.cs generates networks using the Barabasi-Albert preferential attachment model. The parameters for the generation process are set as local variables in the Main method.
| Parameter | Type | Default Value | Description | Location (File) |
|---|---|---|---|---|
nodes | int | 10000 | The total number of nodes in the generated network. | Barabasi.cs:9 |
degree | int | 3 | The number of links each new node adds to the network. | Barabasi.cs:10 |
prob | int | 50 | The percentage of links to be rewired to induce degree correlation (Associate method). | Barabasi.cs:11 |
sociable | boolean | false | If true, rewiring is assortative (positive correlation). If false, it is disassortative (negative). | Barabasi.cs:12 |
Sources: Barabasi.cs:9-12
System Architecture for Parameter Handling
The main application is launched via Program.cs, which instantiates and runs Form1. The Form1 class encapsulates both the UI components (defined in Form1.Designer.cs) and the event-handling logic that uses the parameters from those components.
This class diagram shows the relationship between the main form and its parameter input controls.
Conclusion
The project employs two distinct methods for parameter input. The C# Network Analyzer provides a simple graphical user interface allowing for dynamic control over analysis parameters like the degree distribution cutoff and clustering calculation. In contrast, the supplementary Python and C# scripts for analysis and generation rely on hardcoded variables, suitable for batch processing or specific, predefined tasks. This dual approach provides both interactive exploration and script-based automation for network science experiments.
Sources: Form1.cs, Network.py, Barabasi.cs