Download all the programs

All the C programs of the textbook are available in the
NetBunch package, which can be downloaded
here. Binary versions of NetBunch are available
for Windows, Mac OS, and GNU/Linux (both
Debian/Devuan/Ubuntu-based and RedHat/Fedora/CentOS-based
distributions) while source files can be compiled on Windows,
Mac OS, and any unix-like operating system (including
GNU/Linux, and *BSD). All the programs in
NetBunch are written in ANSI C99. To compile
them, you need just a standard C compiler (we have tested and
compiled NetBunch with gcc, llvm, and tcc) and a standard
implementation of the C library. Please refer to the file
'INSTALL' inside each archive for further information.

NetBunch is Free Software, meaning that all the recipients retain the right to:

Use the software as they wish, for any purpose

Study how the software works, and modify it for their needs

Distribute the software to third parties

Distribute modified copies of the software to third parties

License

All the programs included in NetBunch can be used,
distributed, and modified under the terms of the GNU General
Public License, either version 3 of the Licence or (at your
option) any later version.

All the programs included in NetBunch are distributed in the
hope that they will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.

A copy of the GNU General Public License is included in all
the archive files made available for download. You can also
obtain a copy of the GNU General Public License from at
http://www.gnu.org/licenses/gpl.html

Graph measures

betweenness (Betweenness)

betweenness - Compute the betweenness centrality of nodes and edges

SYNOPSIS

betweennessgraph_in [ SEQ node_start [node_end]]

betweennessgraph_in [ RND num]

DESCRIPTION

betweenness computes the betweenness centrality of all the nodes and
edges of an undirected graph provided as input. The program implements
the algorithm by U. Brandes, and computes the betweenness using all
the shortest paths originating from a subset of the nodes of the
graph, either in a sequence (if SEQ is the second parameter) or
sampled unirofmly at random (if RND is the second parameter). If
graph_in is the only parameter, betweenness takes into account all
the shortest paths.

bet_dependency (Betweenness dependency)

bet_dependency - Compute the betweenness dependency of nodes

SYNOPSIS

bet_dependencygraph_in [ node_start [node_end]]

DESCRIPTION

bet_dependency computes the betweenness dependency of all the nodes
of an undirected graph provided as input. The program implements the
algorithm by U. Brandes, and computes the betweenness dependency using
all the shortest paths originating from the subset of the nodes of the
graph whose labels are in the interval [node_start, node_end]. If
node_end is not given, the last label of the graph is assumed. If
node_start is not given, use the shortest paths originating from all
the nodes of the graph.

johnson_cycles (Cycles)

johnson_cycles - Enumerate the simple cycles of a graph

SYNOPSIS

johnson_cyclesgraph_in [max_length [SHOW]]

DESCRIPTION

johnson_cycles enumerates all the simple cycles of the graph given
on input, and prints the total number of cycles of each length. If
max_length is provided, johnson_cycles ignores any cycle whose
length is larger than max_length. If SHOW is given as third
argument, all the found cycles are printed on STDERR as soon as they
are found.

clust (Clustering)

clust - Compute the graph and node clustering coefficients

SYNOPSIS

clustgraph_in [SHOW]

DESCRIPTION

clust computes the clustering coefficient of the undirected graph
given as input in the file graph_in. If SHOW is provided as a
second parameter, the program prints on STDERR the label, degree, and
clustering coefficient of all the nodes in graph_in.

clust_w (Clustering - weighted)

clust_w - Compute the graph and node clustering of weighted graphs

SYNOPSIS

clust_wgraph_in [SHOW]

DESCRIPTION

clust_w computes the clustering coefficient of the undirected and
weighted graph given as input in the file graph_in. The program uses
the definition of weighted clustering proposed by Barrat, Barthelemy,
Pastor-Satorras ans Vespignani. If SHOW is provided as a second
parameter, the program prints on STDERR the label, degree, and
clustering coefficient of all the nodes in graph_in.

gn (Communities - Girvan-Newman)

gn - Find communities using the Girvan-Newman algorithm

SYNOPSIS

gngraph_in

DESCRIPTION

gn finds the communities in graph_in using the Girvan-Newman
algorithm, based on the successive removal of edges with high
betweenness. The program prints on STDOUT the partition corresponding
to the highest value of the modularity function, and reports on STDERR
the number of communities after each edge removal and the
corresponding value of modularity.

N.B.: the program recomputes the edge betweenness of the graph after
the removal of each edge, so it is not feasible to use it on large
graphs.

cnm (Communities - greedy modularity)

cnm - Find communities using greedy modularity optimisation

SYNOPSIS

cnmgraph_in

DESCRIPTION

cnm finds the communities in graph_in using the greedy modularity
optimisation algorithm proposed by Clauset, Newman and Moore. The
program prints on STDOUT the partition corresponding to the highest
value of the modularity function, and reports on STDERR the number of
communities and the corresponding value of modularity at each
step. The algorithm is quite eficient and thus suitable to find
communities in large graphs.

label_prop (Communities - label propagation)

label_prop - Find communities using label propagation

SYNOPSIS

label_prop [SYNC|ASYNC] graph_in [max_epochs]

DESCRIPTION

label_prop finds the communities in graph_in using the label
propagation algorithm proposed by Raghavan, Albert, and Kumara. The
program prints on STDOUT the partition obtained where no more label
flips are possible, and reports on STDERR the number of communities
and the corresponding value of modularity at each epoch. When used in
ASYNC mode, the algorithm is suitable to find communities in large
graphs.

components (Connected components)

components - Find the connected components of a graph

SYNOPSIS

componentsgraph_in [SHOW]

DESCRIPTION

components finds the connected components of the undirected graph
given as input using the Depth-First Search algorithm, and prints the
size of each of them. If the optional second parameter SHOW is
provided, the program dumps on output also the list of nodes belonging
to each component.

deg_seq_w (Degree sequence - weighted)

SYNOPSIS

DESCRIPTION

fitmle (Fit power-law)

fitmle - Fit a set of values with a power-law distribution

SYNOPSIS

fitmledata_in [tol [TEST [num_test]]]

DESCRIPTION

fitmle fits the data points contained in the file data_in with a
power-law function P(k) ~ k-gamma, using the Maximum-Likelihood
Estimator (MLE). In particular, fitmle finds the exponent gamma
and the minimum of the values provided on input for which the
power-law behaviour holds. The second (optional) argument tol sets
the acceptable statistical error on the estimate of the exponent.

If TEST is provided, the program associates a p-value to the
goodness of the fit, based on the Kolmogorov-Smirnov statistics
computed on num_test sampled distributions from the theoretical
power-law function. If num_test is not provided, the test is based
on 100 sampled distributions.

knn (Nearest-neighbour degree)

knn - Compute the average nearest neighbours degree function

SYNOPSIS

knngraph_in [NO|LIN|EXPbin_param]

DESCRIPTION

knn computes the average nearest neighbours degree function knn(k)
of the graph graph_in given as input. The program can (optionally)
average the results over bins of equal or exponentially increasing
width (the latter is also known as logarithmic binning).

knn_w (Nearest-neighbour degree - weighted)

SYNOPSIS

knn_wgraph_in [NO|LIN|EXPbin_param]

DESCRIPTION

knn_w computes the weighted average nearest neighbours degree
function knn_w(k) of the weighted graph graph_in given as input. The
program can (optionally) average the results over bins of equal or
exponentially increasing width (the latter is also known as
logarithmic binning).

node_components (Node components)

node_components - Find the components associated to a specific node

SYNOPSIS

node_componentsgraph_innode [component [SHOW]]

DESCRIPTION

node_components finds the components associated to the node node
of the graph graph_in provided as input, and prints on output the
size of those components. The value of the third parameter component
can be set to IN, OUT, INOUT, SSC, WCC, or ALL. According
to the value of component, the program will compute the IN-component
(IN), the OUT-component (OUT), both the IN- and OUT-component
(INOUT), the strongly connected components (SCC), or the
weakly-connected component (WCC) to which node belongs. If the
third parameter is omitted or equal to ALL, then node_components
computes all the components associated to node. If SHOW is
specified as the fourth parameter, the program also shows the list of
nodes which belong to each of the required components.

pm (Power method)

pm - Compute the leading eigenvalue and eigenvector of a graph

SYNOPSIS

pmgraph_inis_direps

DESCRIPTION

pm computes the leading eigenvalue and the corresponding eigenvector
of the matrix given as input, using the Power Method. In particular,
this implementation uses the Rayleigh iteration, which allows faster
convergence on undirected graphs.

shortest (Shortest paths)

shortest - Compute the distance between one node and all the other nodes of a graph

SYNOPSIS

shortestgraph_innode [SHOW]

DESCRIPTION

shortest computes the distance (and the shortest paths) between a
given node and all the other nodes of an undirected graph provided as
input. The program implements the Breadth-First Search algorithm.

shortest_avg_max_hist (Shortest paths statistics)

shortest_avg_max_hist - Compute the distance between one node and all the other nodes of a graph

SYNOPSIS

shortest_avg_max_histgraph_innode

DESCRIPTION

shortest_avg_max_hist computes the distance (and the shortest paths)
between a given node and all the other nodes of an undirected graph
provided as input. The program implements the Breadth-First Search
algorithm, and works almost exactly as shortest(1), except for the
output.

kruskal (Spanning trees)

kruskal - Find the minimum/maximum spanning tree of a graph

SYNOPSIS

kruskalgraph_in [MAX]

DESCRIPTION

kruskal computes the minimum (or maximum) spanning tree of
graph_in, using the Kruskal's algorithm. If grahp_in is
unweighted, kruskal computes one of the spanning trees of the
graph. The program prints on output the (weighted) edge list of the
spanning tree.

strong_conn (Strongly connected components)

SYNOPSIS

strong_conngraph_in [SHOW]

DESCRIPTION

strong_conn finds the strongly connected components of the directed
graph given as input using the Kosaraju-Sharir algorithm, and prints
the size of each of them. If the optional second parameter SHOW is
provided, the program dumps on output also the list of nodes belonging
to each component.

Graph models

ba (BA model)

ba - Grow a Barabasi-Albert scale-free random graph

SYNOPSIS

baNmn0

DESCRIPTION

ba grows an undirected random scale-free graph with N nodes using
the linear preferential attachment model proposed by Barabasi and
Albert. The initial network is a ring of n0 nodes, and each new node
creates m new edges. The resulting graph will have a scale-free
degree distribution, whose exponent converges to gamma=3.0 for large
N.

conf_model_deg (Conf. model)

conf_model_deg - Sample a simple graph from the configuration model

SYNOPSIS

conf_model_degdegs [threshold]

DESCRIPTION

conf_model_deg samples a simple random undirected graph (i.e., a
graph without self-loops and multiple edges) from the configuration
model associated to the degree sequence provided in the input file
degs.

er_A (ER model A)

er_A - Sample a random graph from the Erdos-Renyi model A

SYNOPSIS

er_ANK [fileout]

DESCRIPTION

er_A samples a random graph with N nodes and K edges from the
Erdos-Renyi model A, i.e. the ensemble of random graphs where K links
are placed uniformly at random among N nodes. The program dumps the
edge list of the resulting graph on output. If the optional fileout
is provided, the output is written on a file with that name.

er_B (ER model B)

er_B - Sample a random graph from the Erdos-Renyi model B

SYNOPSIS

er_BNp [fileout]

DESCRIPTION

er_B samples a random graph from the Erdos-Renyi model B, i.e. a
graph with N nodes where each of the <N(N-1)/2> edges is created
independently with probability p. The program dumps the edge list of
the resulting graph on output. If the optional fileout is provided,
the output is written on a file with that name.

dms (DMS model)

dms - Grow a scale-free random graph with tunable exponent

SYNOPSIS

dmsNmn0a

DESCRIPTION

dms grows an undirected random scale-free graph with N nodes using
the modified linear preferential attachment model proposed by
Dorogovtsev, Mendes and Samukhin. The initial network is a clique of
n0 nodes, and each new node creates m new edges. The resulting
graph will have a scale-free degree distribution, whose exponent
converges to gamma=3.0 + a/m for large N.

bb_fitness (Fitness model)

bb_fitness - Grow a random graph with the fitness model

SYNOPSIS

bb_fitnessNmn0 [SHOW]

DESCRIPTION

bb_fitness grows an undirected random scale-free graph with N
nodes using the fitness model proposed by Bianconi and Barabasi. The
initial network is a clique of n0 nodes, and each new node creates
m new edges. The probability that a new node create an edge to node
j is proportional to

a_j * k_j

where a_j is the attractiveness (fitness) of node j. The values of
node attractiveness are sampled uniformly in the interval [0,1].

bbv (Growing weighted graphs)

bbv - Grow a weighted scale-free random graph

SYNOPSIS

bbvNmn0w0delta

DESCRIPTION

bbv grows an undirected weighted random scale-free graph with N
nodes using the model proposed by Barrat, Barthelemy, and
Vespignani. The initial network is a clique of n0 nodes, and each
new node creates m new edges, each with weight w0. The parameter
delta sets the amount of weight to be redistributed in the
neighbourhood of newly-connected nodes.

ws (WS model)

ws - Create a small-world graph using the Watts-Strogatz model

SYNOPSIS

wsNmp [SHOW]

DESCRIPTION

ws creates a small-world undirected graph with 'N' nodes using the
Watts-Strogatz small-world network model. The nodes are initially
placed around a circle and each node is connected to its 'm' closest
neighbours on either side. Then, each edge is rewired (independently)
with probability 'p'. The program prints on output the edge-list of
the resulting graph.