- Undirected graph;
- Graph with no loops;
- Graph with no multiple edges for the same pair of nodes;
First, input the number of nodes of the graph. Then, input its edges.
[number-of-nodes]
[source-node] [destination-node] [edge-weight]
[source-node] [destination-node] [edge-weight]
[source-node] [destination-node] [edge-weight]
...
For the algorithm to work, the edges input must be symmetric. For example, if the input has an edge 6 10 2.45
, so there must be another edge input 10 6 2.45
(with the same weight value).
- You can compile with GCC compiler
gcc spectral-moments.c -o spectral-moments
- If you are using linux, grant the execution permission
chmod +x spectral-moments
- Run program. Where
[spectral-moments]
is the number of first spectral moments to calculate, defaulted to 10.
./spectral-moments [spectral-moments] < input-file.txt
You can convert it to symmetric.
- Install Python
- Run the program
python3 symmetric-edges.py < non-symmetric-input.txt | ./spectral-moments [spectral-moments]
There are some Python scripts to generate random sample inputs.
You'll need install Python and the libraries numpy, networkx and scipy.
- Generate Barabasi complex network
python3 simulate-barabasi.py [n] [m]
- Generate Erdos complex network
python3 simulate-erdos.py [n] [p]
- Generate Watts Strogatz complex network
python3 simulate-watts-strogatz.py [n] [m] [k]
You can also pass the generated input directely to the program with pipe command operator. For example:
python3 simulate-barabasi.py 10 5 | ./spectral-moments 15