Troubleshooting
Relevant source files
The following files were used as context for generating this wiki page:This document provides guidance for troubleshooting issues within the Network Science project, which includes a C# Network Analyzer, a C# network generator, and several Python analysis scripts. Troubleshooting primarily involves addressing file I/O errors, validating input data formats, and interpreting application feedback.
The main components discussed are the C# WinForms application (Charts), the C# console application for network generation (Barabasi.cs), and the Python scripts for analysis (Network.py, Selection.py). Common problems stem from hardcoded file paths, missing dependencies, and unexpected data in input files.
C# Network Analyzer (Charts)
The primary tool for network analysis is a C# WinForms application. Troubleshooting this component involves monitoring UI feedback and understanding its error handling mechanisms.
Sources: Form1.cs, Form1.Designer.cs, Program.cs
UI Feedback and Status Monitoring
During lengthy operations like file parsing and metric calculation, the application provides real-time status updates in a text box. This is the first place to look if the application appears to hang.
- Status Display: The text box, named
textBox1, is updated with the current operation, such as "Building Edge List", "Calculating clustering coefficient", or "Building Degree Distribution". - Identifying Bottlenecks: If the application becomes unresponsive, the last message displayed in
textBox1indicates which part of the process is running. This can help diagnose performance issues, especially with large datasets.
Sources: Form1.cs:214, Form1.cs:111, Form1.cs:161, Form1.cs:256, Form1.Designer.cs:100-107
File Loading Error Handling
The application has a specific error handling mechanism for security-related issues during file loading. However, it does not explicitly handle data format errors, which can lead to unhandled exceptions.
The diagram below shows the sequence of events when a user opens a file.
Sources: Form1.cs:198-223
A try-catch block specifically handles SecurityException, which typically occurs due to file permission issues.
// From Form1.cs
try
{
using (StreamReader file = new StreamReader(openFileDialog1.FileName))
{
// ... file reading logic ...
}
}
catch (SecurityException ex)
{
MessageBox.Show($"Security error.\n\nError message: {ex.Message}\n\n" +
$"Details:\n\n{ex.StackTrace}");
}
Sources: Form1.cs:207-219
Potential Unhandled Exception: The code parses node IDs from the file using int.Parse. If the file contains non-integer or incorrectly formatted data, a FormatException will be thrown, causing the application to crash as it is not handled.
Sources: Form1.cs:61, Form1.cs:212
C# Network Generator (Barabasi.cs)
This console application generates network edgelists using the Barabási-Albert model. Troubleshooting is mainly related to its file output mechanism.
Sources: Barabasi.cs
Hardcoded Output Path
The application writes the generated network to a hardcoded file path. This is a common point of failure if the directory does not exist or if the application lacks write permissions.
- Path:
F:\\Math\\Network Science\\dissociative.edgelist.txt - Troubleshooting Step: If the output file is not created, verify that the
F:\Math\Network Science\directory exists and that the user running the application has permissions to write to it.
Sources: Barabasi.cs:13
Data Integrity Logic
The generator includes logic to prevent certain types of invalid edges, which is a form of proactive error prevention.
- Self-Links: The
Associatemethod checks to ensure that rewiring edges does not result in a node connecting to itself. - Duplicate Links: When adding new nodes, the generator can be configured to prevent creating a duplicate link to the same target node.
The flowchart below illustrates the logic in the Associate method for rewiring edges.
Sources: Barabasi.cs:91-115
Python Scripts
The repository contains Python scripts for network analysis (Network.py) and population simulation (Selection.py). Common issues include missing dependencies and hardcoded file paths.
Sources: Network.py, Selection.py, README.md
Dependencies and Environment
The Python scripts rely on several external libraries. A ModuleNotFoundError is a clear sign that the environment is not set up correctly.
| Script | Dependencies |
|---|---|
Network.py | pandas, math, numpy, bokeh, scipy |
Selection.py | numpy, pandas, matplotlib, seaborn |
Solution: Install the missing libraries using a package manager like pip. For example: pip install pandas numpy bokeh scipy matplotlib seaborn.
Sources: Network.py:1-7, Selection.py:4-8
Hardcoded Paths
Like the C# generator, Network.py uses a hardcoded base path to locate its input dataset.
- Path:
F:\\Math\\Network Science\\+dataset - Troubleshooting Step: If the script fails with a
FileNotFoundError, ensure the path is correct and the specified dataset file (e.g.,www.edgelist.txt) exists in that directory.
Sources: Network.py:9
Summary of Common Issues
The following table summarizes common problems, their symptoms, and recommended solutions.
| Issue Description | Component / File | Symptom | Recommended Solution |
|---|---|---|---|
| Application crashes when opening a file. | Form1.cs | Unhandled FormatException and application termination. | Ensure the input file is tab-separated and contains valid integer node IDs. |
| "Security error" message appears. | Form1.cs | A message box with "Security error" is displayed. | Check read permissions for the selected file and its parent folders. |
| Application hangs during processing. | Form1.cs | The UI becomes unresponsive and the status in textBox1 does not change. | The operation is likely taking a long time. For very large graphs, consider that clustering calculations can be slow. |
| Network generator produces no output file. | Barabasi.cs | The expected .edgelist.txt file is not created. | Verify the hardcoded path F:\Math\Network Science\ exists and is writable. |
| Python script fails immediately. | Network.py | FileNotFoundError in the console. | Verify the hardcoded path F:\Math\Network Science\ and the dataset file exist. |
| Python script reports missing module. | Network.py, Selection.py | ModuleNotFoundError in the console. | Install the required Python libraries via pip. |
Sources: Form1.cs:207-219, Form1.cs:61, Form1.cs:110, Barabasi.cs:13, Network.py:9, Network.py:1-7, Selection.py:4-8