BACKGROUND
over the last decade, network models have advanced our understanding of biology at all scales, from gene regulatory networks to metabolic cycles to global food webs  <cit> .
they are also driving the forefront of sociology, information technology and many other disciplines  <cit> .
researchers often build network models from empirical data and then seek to characterize and explain non-trivial structural properties such as heavy-tail degree distributions, clustering, short average path lengths, degree correlations and community structure  <cit> .
many of these properties appear in diverse natural and man-made systems, and can fundamentally influence dynamical processes of and on these networks  <cit> .
clustering is a network characteristic describing the presence of triangles in a network, that is, the propensity of neighbors of a common vertex to also be neighbors with each other.
it is an important topological characteristic that can significantly impact dynamical processes over complex networks  <cit> .
clustering is often correlated with local graph properties such as correlations in the number of edges emanating from neighboring vertices  <cit>  and graph motifs  <cit> , as well as global properties such as community structure  <cit> .
clustering in biological and other empirical networks can stem from two sources:  it can arise as a byproduct of other, more fundamental, topological properties such as the degree sequence  or degree correlations ; or  it can be generated directly by some inherent property or mechanism within the system, for example, "the friends of my friends tend to become my friends" in social networks.
some researchers have claimed that high clustering is a general feature of complex networks  <cit> .
when we measure clustering in a variety of empirical networks, however, we find that it varies considerably.
table  <dig> shows that the clustering coefficients and transitivity values  for these networks span the entire range of possible values .
thus, it is important to understand not only the origins of clustering, but also the impact of clustering on network functions and dynamics.
towards this end, we introduce a method for generating random networks with a specified level of clustering.
the number of nodes , the average node degree , the mean-squared of node degree , clustering coefficient , transitivity , soffer-vasquez clustering coefficient (), and soffer-vasquez transitivity () for a set of empirical networks.
related work
random graphs are graphs that are generated by some random process  <cit> .
they are widely used as models of complex networks  <cit>  and can assume various levels of complexity.
the simplest model for generating random graphs, with only a single parameter, is the bernoulli or erdös-renyi random graph model, which produces graphs that are completely defined by their average degree and are random in all other respects.
a slightly more complex and general model is one that generates graphs with a specified degree distribution  and ones which are random in all other respects  <cit> .
these models can be extended to include additional structural constraints, such as degree correlations or the density of triangles or longer cycles, as we will demonstrate below.
existing methods for generating clustered graphs, however, do not take this approach.
one of the first examples is the seminal work of watts and strogatz  <cit> .
they introduced a model that produces networks with high clustering and low average path length , now known as the small world property.
although not intended as a generative algorithm for clustered graphs, the model produces graphs with clustering spanning the range from  <dig> to  <dig>  the graphs generated under this model, however, have rigid spatial structure and cannot accommodate varying degree distributions.
the first algorithms that were designed to generate graphs with a specified level of clustering for arbitrary degree distributions belonged to the class of projected bipartite graphs.
newman  <cit>  introduced a three-step method that first builds a bipartite graph of individuals and affiliations, then projects the bipartite graph to a unipartite graph of individuals only, and finally runs a percolation process over the unipartite graph.
this results in a clustered graph with a degree distribution that depends on the original distributions of numbers of individuals per group and groups per individual.
the level of clustering in the final graph varies smoothly from  <dig> to  <dig> as a function of the percolation probability.
in  <cit> , guillaume suggested a similar bipartite graph approach.
although these approaches can generate clustered graphs with diverse degree distributions, they lack straightforward methods for choosing parameters that yield graphs with not only a pre-specified clustering coefficient but also a pre-specified degree distribution.
these algorithms also tends to produce graphs that leave a significant proportion of the graph vertices isolated.
a second class of clustered graph models use "growing network" algorithms  <cit> .
the inputs to these models are a degree distribution and level of clustering.
the method begins with a set of vertices with no edges; the graph is then "grown" by adding edges based on the degree and clustering constraints.
although the algorithms of this class allow for arbitrary degree distributions and levels of clustering, they either require a complex implementation  <cit> , produce graphs of a highly specific structure  <cit>  or introduce large amounts of degree correlations  <cit> .
finally, the family of statistical models known as exponential random graph  models  <cit>  also provide tools to fit the structure of observed networks, for statistics such as degree distribution and number of triangles.
these erg model-based methods, although they have advanced significantly in recent years , still suffer from problems of degeneracy and computational intractability for large networks.
our approach
here, we present a model that generates undirected, simple and connected graphs with prescribed degree sequences and a specified frequency of triangles, while maintaining a graph structure that is as random  as possible.
or multiedges ; and a connected graph is one where every node in the graph is reachable by a path of edges from every other graph node.)
prior models in this area were intended to generate clustered graphs that replicate the properties of real-world networks; our goal, on the other hand, is to generate a class of null networks with arbitrary degree distributions that are simple and connected and have a high density of triangles, but are random in all other respects.
this method thus leads to two valuable applications.
first, network structure fundamentally influences the functions of and dynamical processes on networks.
we can use clustered random graphs to systematically study the consequences of clustering, both independently and in combination with various degree patterns.
second, these networks can serve as null models for detecting whether an empirical network can be boiled down to its degree distribution and clustering values or, instead, contains substantial degree correlations or other important structures .
one would first use the algorithm to generate an ensemble of networks that match the empirical degree sequences and clustering values, and then compare the structural, functional, or dynamical properties of the empirical network to those of the clustered random networks.
we focus here on the role of these networks as null models as it is crucial to have appropriate random controls in the study of biological systems, as has been demonstrated in  <cit> .
the rest of this article is organized as follows.
in the implementation section, we review common measures of clustering and introduce our markov chain model and algorithm for generating clustered graphs with a specified degree sequence.
in the results section, we test our algorithm with numerical simulations and explore the structural properties of the generated graphs.
the discussion section is devoted to a demonstration of the randomly generated clustered networks as null networks for the analysis of empirical networks.
we finish off with our conclusions, presenting the benefits of our markov chain simulation method for biological networks.
implementation
our clustered random graph generation method begins with a random graph and iteratively rewires edges to introduce triangles.
network rewiring, also known as edge swapping, is a well-known method for generating networks with desired properties  <cit> .
two edges are called adjacent if they connect to a common node.
each rewiring is performed on two non-adjacent edges of the graph and consists of removing these two edges and replacing them with another pair of edges.
specifically, a pair of edges  and  is replaced with either  and , or  and  .
this change in the graph leaves the degrees of the participating nodes unchanged, thus maintaining the specified degree sequence.
below we describe a rewiring algorithm that increases the level of clustering in a random graph, while preserving the degree sequence.
the algorithm we develop below is implemented in python as clustrnet.
it is based on networkx, an open-source python library available for download at  <cit> , which provides standard graph library functionality .
the source code for clustrnet, along with documentation and test network datasets, is available on the web  <cit> .
our algorithm joins a existing suite of random graph model-based software tools for the analysis of biological networks and the dynamics on them  <cit> .
measures of clustering
we begin with a graph g =  which is undirected and simple.
v is the set of vertices of g and e is the set of the edges.
we let n = |v| and m = |e| denote the number of nodes and edges in g, respectively.
the degree of a node i will be denoted di.
the set of degrees for all nodes in the graph makes up the degree sequence, which follows a probability distribution called the degree distribution.
clustering is the likelihood that two neighbors of a given node are themselves connected.
in topological terms, clustering measures the density of triangles in the graph, where a triangle is the existence of the set of edges , ,  between any triplet of nodes i, j, k .
to quantify the local presence of triangles, δ is defined as the number of triangles in which node i participates.
since each triangle consists of three nodes, it is counted thrice when we sum δ for each node in the graph.
thus the total number of triangles in the graph is
a triple is a set of three nodes, i, j, k that are connected by edges  and , regardless of the existence of the edge  .
the number of triples of node i is simply
assuming di ≥  <dig>  to compute the total number of triples in the graph, τ, we sum τ for all i ∈ v.
the clustering coefficient was introduced by watts and strogatz  <cit>  as a local measure of triadic closure.
for a node i with di ≥  <dig>  the clustering coefficient c is the fraction of triples for node i which are closed, and can be measured as δ = τ. the clustering coefficient of the graph is then given by:
where n <dig> is the number of nodes with c ≥  <dig>  some authors do define the clustering coefficient for all nodes of g  <cit> .
a more global measure of the presence of triangles is called the transitivity of graph g and is defined as:
although they are often similar, t and c can vary by orders of magnitude  <cit> .
they differ most when the triangles are heterogeneously distributed in the graph.
these traditional measures of clustering are degree-dependent and thus can be biased by the degree sequence of the network.
the maximum number of possible triangles for a given node i is just its number of triples ).
for a node which is connected to only low degree neighbors, however, the maximum number of possible triangles may be much smaller than τ. to account for this, a new measure for clustering was introduced in  <cit>  that calculates triadic closure as a function of degree and neighbor degree.
specifically, the soffer-vasquez clustering coefficient () and transitivity () are given by:
where ω measures the number of possible triangles for node i, and nω is the number of nodes in g for which ω >  <dig>  we note that  and  are undefined if ω = Σi ω =  <dig>  ω is computed by counting the maximum number of edges that can be drawn among the di neighbors of a node i, given the degree sequence of i's neighbors; this value is often smaller than  <cit> .
for example, consider a star network of five nodes, where four nodes have degree  <dig> and one node has degree  <dig>  although the total number of triples is τ =  <dig>  the number of possible triangles is ω =  <dig> because the degree one nodes preclude their formation.
the computation of ω must be done algorithmically and is not possible in closed form.
generative model
here we develop a model to generate a simply connected random graph with a specified degree sequence and a desired level of clustering.
generating random graphs uniformly from the set of simply connected graphs with a prescribed degree sequence is a well-studied problem with algorithmic solutions  <cit> .
one of the simplest and most popular of these generative algorithms was suggested by molloy and reed and is known as the configuration model  <cit> .
given a specific realizable degree sequence  <cit> , {di}, this method assigns dj half-edges to each node j, and then randomly connects pairs half-edges to create edges until there are no half-edges left.
and the erdos-gallai criterion  although the model sometimes produces graphs that are not simple or connected, this can be remedied by subsequently removing multiple edges and self loops from the constructed graph and keeping only the largest connected component  <cit> .
our method begins by using this approach to generate a simple, connected random graph g, with a specific realizable degree sequence d. we then introduce triangles into g using a markov chain process without disturbing the degree sequence until we achieve the desired level of clustering, as follows.
let gd be the set of all simple, connected graphs with degree sequence d. if  are the graphs of gd, then we let  be the states of the markov chain, p, where xi represents the state in which our graph g = gi.
the states xi and xi+ <dig> are connected in the markov chain if gi can be changed to gi+ <dig> with the rewiring of one pair of edges.
the state space of the markov chain p is connected because there exists a path from xi to xj  by one or more rewiring moves that leave the degree sequence unchanged  <cit> .
our clustered graph generation algorithm involves starting with the random graph g  and transitioning from the state corresponding to g  to other states of p until a halting condition is reached.
a transition from one state of the markov chain to another only occurs when the algorithm makes an edge rewiring that both increases the clustering of the graph and leaves the graph connected.
since a rewiring does not alter the degree sequence of the graph, the rewired graph is still in gd.
the transition probabilities of the markov chain for a pair of connected states, xi to xj, are:
where clust is a clustering measure for graph gx, which can be replaced by any of the measures introduced in section.
the algorithm continues searching for a feasible rewiring  until one is found.
if a feasible move is not found, a transition is not made and the process remains in the current state.
the markov chain above is finite and aperiodic, but not irreducible as the process can never transition to a state in which the graph has lower clustering.
it does, however, have an absorbing state, x*, in which the transitivity of g* is greater than or equal to the desired transitivity or is the maximum possible transitivity given the particular degree sequence and connectivity constraints.
algorithm
to generate clustered graphs, we apply the above markov chain simulation model by iteratively applying rewirings that increase graph clustering.
each rewiring takes a set of five nodes {x, y <dig>  y <dig>  z <dig>  z2}, connected by four edges {, , , }, and swaps the outer edges: {, , , }.
this introduces a triangle among nodes {x, y <dig>  and y2}, without perturbing the degree sequence.
the algorithm proceeds as follows:
input: a realizable degree sequence {di} a desired clustering value, target
initialization: generate a random graph g with degree sequence {di} , and measure the clustering of g, clust.
while clust <target do
<dig>  uniformly select a random node, x, from the
set of all nodes of g such that dx >  <dig>
<dig>  uniformly select two random neighbors, y <dig>
and y <dig>  of x such that dy <dig> >  <dig> and
dy <dig> >  <dig> and y1≠y <dig>
<dig>  uniformly select a random neighbor, z <dig>
of y <dig> and a random neighbor, z <dig> of
y <dig> such that z <dig> ≠ x, z <dig> ≠ x,
z <dig> ≠ z <dig>
<dig>  gcand: = g where gcand is the candidate
graph to which the transition may be made.
<dig>  if  and  do not exist then
rewire two edges of gcand: delete  and , add  and .
end
<dig>  update the value of clust by measuring
δ   if relevant) for the nodes involved
in the rewiring and their neighbors.
<dig>  if clust > clust and gcand
is connected then
g: = gcand
end
end
output: a random graph, g with degree sequence {di} and clust ≥ target.
the algorithm terminates when the graph attains at least the desired level of clustering or reaches a threshold number of unsuccessful rewiring attempts.
in the latter case, the algorithm returns the graph with the maximum clustering achieved.
for practical purposes, a threshold is placed on the number of unsuccessful attempts made by the algorithm in clustrnet for the case that the desired clustering cannot be reached.
due to the random restarts made at every step, the algorithm is prevented from getting trapped in local minima.
the algorithm is designed to increase clustering while preserving both the degree sequence and connectedness of the graph.
however, there are some cases where the desired clustering can only be reached by disconnecting the graph; and thus clustrnet provides the option of removing the connectivity constraint .
choice of clustering measure
the algorithm is defined independent of the choice of clustering measure.
the term clust in the algorithm above can be replaced by any clustering measure described in section.
clustrnet includes all four of these clustering measures .
the algorithm output varies with the choice of clustering measure.
the clustering coefficient is a local measure; and thus c and  yield networks that are only locally optimized for the desired level of clustering.
the algorithm may have difficulty attaining target clustering values when using the absolute clustering measures  because of joint degree constraints  on the possible numbers of triangles, as with the example presented in section.
the soffer-vasquez clustering measures, which explicitly consider joint degree constraints, provide a way around this difficulty  <cit> .
although the rewiring in our algorithm changes the joint degree distribution  of the graph, ω is not altered significantly during network generation .
thus, when using  or , clustering is increased primarily by the addition of triangles ) rather than decreasing ω).
types of graph changes
as shown in figure  <dig>  there are six types of triangles that can be added or removed for every pair of edges that are rewired.
as illustrated in figure 1d, these additions and removals can occur in combination.
• type a: the addition of the edge between vertices y <dig> and y <dig> guarantees the addition of one triangle in every rewiring event.
• type b: the addition of the edge  could create new triangles with shared neighbors of y <dig> and y <dig>
• type c: the addition of the edge  could add a triangle if there existed edges between x and z <dig> and x and z <dig>
• type d: the addition of the edge between vertices z <dig> and z <dig> could create new triangles with shared neighbors of z <dig> and z <dig>
• type e: the removal of edges  and  removes one triangle each if the edges  or  exist.
• type f: the removal of the edges between vertices y <dig> and z <dig>  and y <dig> and z <dig> could lead to the removal of existing triangles with shared neighbors of y <dig> and z <dig> or y <dig> and z <dig>
we note that although the type a addition is a special case of type b, the type c addition is a special case of type d, and the type e removals are a special case of type f, we distinguish them because they have different probabilities of occurrence.
our look-ahead strategy only allows rewiring moves when the total number of type e and f losses is fewer than the total number of type a, b, c, and d gains.
computational complexity
like many heuristic search methods, the algorithm we propose can be computationally expensive.
the method outlined in section  <dig>  requires o steps to generate a connected graph, and up to o steps to randomize the graph, where m is the number of edges in the graph.
at each step of randomization, we test that the graph remains connected  operation), resulting in an overall o random network generation process.
a naive computation of the transitivity/clustering coefficient requires checking every node for the existence of edges between every pair of neighbors of the node.
this step requires o() operations, where n is the number of nodes and dmax is the maximum degree of any node in the graph.
the most expensive step of our algorithm is the introduction of triangles via rewiring.
a single rewiring step requires o operations for switching edges, checking for connectivity and updating the clustering measure.
although we cannot analytically calculate the number of attempted rewiring steps required to reach the desired transitivity, we have found it empirically to be o. thus, the average complexity of the clustered network algorithm presented here is o. this complexity has been computed for the most naive versions of our algorithms; and more efficient implementations may improve the complexity greatly.
for example, we might improve efficiency by performing connectivity tests once every x rewirings  rather than during every rewiring, as proposed in  <cit> .
RESULTS
performance
to test our algorithm, we generate networks with three different degree distributions and for a range of clustering target values.
specifically, we use poisson , exponential e-κ) and a truncated scale-free ) degree distribution, each with a mean degree of five.
starting with random graphs with specific degree sequences matching these degree distributions, we rewire the networks towards  sv-transitivity ) targets and  transitivity  targets in addition to allowing the algorithm to generate disconnected graphs.
these targets allow us to evaluate how the clustering measure and connectivity requirement constrain the results, and the second target, in particular, allows us to compare results to other algorithms.
figure  <dig> illustrates the rewiring of a network with a poisson distributed degree sequence evolving towards higher transitivity.
we evaluate the performance of our algorithm in comparison to one representative network growth algorithm  <cit>  and one representative bipartite network method  <cit> .
specifically, we measured the discrepancies between input and output degree distributions  and transitivity values .
our algorithm preserves the input degree sequence perfectly, while there are considerable mismatches between the input and output degree distributions in the volz and newman models.
for both comparisons, the transitivity values of the output graphs from our algorithm exactly match the target transitivity values, when those values can be attained given the network topology and the requirements of the algorithm.
some values at the lower end of the clustering scales cannot be reached because the expected transitivity for random graphs of specified degree distributions scales as  where pk is the degree distribution  <cit> .
this value is small for the poisson degree distribution but can be quite high  for highly-skewed degree distributions such as the scale-free degree distribution.
for the first comparison, the connectivity constraint imposes a maximum on the attainable clustering value, thus the highest sv-transitivity values cannot be reached without disconnecting the graphs.
in these cases, our algorithm returns the graph with the largest attainable sv-transitivity that is less than the desired sv-transitivity.
for the second comparison, , our algorithm performs better in all cases compared to the volz and newman models.
due to the definition of the standard transitivity measure , however, we see that the networks reach a maximum t value, beyond which no further clustering can be accommodated by the network topology.
structural properties of generated networks
there are several other topological properties  that can strongly influence network function and dynamics.
among these are degree correlations , community structure , and average path length .
we have specifically developed this model to increase clustering with minimal structural byproducts.
thus, we confirm that we have reached this goal by measuring the above properties in the networks generated by our algorithm.
we evaluated the extent to which the algorithm introduces degree correlations by comparing random  graphs to clustered random graphs generated by our algorithm and the volz  <cit>  and newman  <cit>  algorithms  and average path lengths  in random graphs with specified degree distributions  compared to clustered random graphs with the same degree distributions and t =  <dig>  generated by our algorithm , as well as the volz  <cit> and newman  <cit> algorithms .
the graphs present averages over  <dig> graphs generated by each algorithm.
our algorithm introduces fewer degree correlations than the alternatives, and the clustered graphs have only slightly higher average path lengths than their random counterparts:  <dig>  for the poisson random graphs versus  <dig>  for the clustered graphs; and  <dig>  for the exponential random graphs versus  <dig>  for the clustered graphs.
several authors have discussed the relationship between clustering and community structure  <cit> .
as figure  <dig> shows, the addition of triangles leads to modular structure.
this behavior is not surprising: as the number of edges in the graph is constrained, sets of connected nodes with high ω values  must be brought together to create additional clustering.
although the presence of a significant proportion of triangles tends to separate the network into modules, it is not clear that clustering is always sufficient to explain the modular structure of a graph.
we explore this further below.
short average path lengths are a characteristic feature of random graphs  <cit> .
to quantify the impact of our algorithm on path lengths, we calculated the average path length for each node to all other  nodes, and then compared the distributions of these values for several random and random clustered graphs .
while our algorithm mostly maintains short average path lengths, the mean of the path length distribution does tend to be slightly larger for the clustered graphs than for the corresponding random graphs.
the intuition behind this increase in average path length may lie in the increased community structure: as graphs become more clustered and separate into subgroups, nodes in different groups require more links to reach each other .
given that our algorithm can generate graphs of high clustering while preserving short path lengths, this introduces a novel method of generating graphs with the small world property without the correlations of watts-strogatz graphs  <cit> .
discussion
application: analysis of empirical networks
it is crucial to have random controls in the study of biological systems.
our algorithm can be used to generate null models and applied to the detection of structure in empirical biological networks.
we can generate ensembles of clustered random networks with empirically estimated degree sequences and clustering values to ascertain whether empirical networks have significant non-random structure in other respects.
we demonstrate this application using representatives from four classes of biological networks.
we also analyze one non-biological network that is made of human transportation links as it provides contrast to the range of topological properties and design principles found in the biologically-motivated networks.
the five real networks are as follows: a) a trophic exchange network for the little rock lake in wisconsin  <cit> ; b) a protein interaction network for yeast  <cit> ; c) a metabolic network for the eukaryote caenorhabditis elegans  <cit> ; d) a network made up of epidemiologically-relevant contacts for individuals in the city of vancouver  <cit> ; and e) a transportation network, made up of us metropolitan areas connected by air travel  <cit> .
these networks represent a diverse set of applications and are systems that are well-studied in their respective literatures.
the basic statistics of these networks, including clustering values, are listed in table  <dig>
we use the following method to quantify deviations from randomness in these networks.
first, we use our algorithm to generate  <dig> clustered random networks constrained to match the empirical degree sequence and clustering values.
second, we select a set of network topological measures , and compare these quantities for the empirical graph to the corresponding average quantities across the ensemble of generated graphs.
specifically, we generate  <dig> clustered random networks for each empirical network, constrained to match the empirical degree sequence and sv-transitivity.
in addition to the degree and clustering metrics, we also calculated diameter   <cit> , degree correlation coefficient  <cit>  and modularity   <cit>  .
other than diameter, each of these metrics range from  <dig> to  <dig>  the standard deviations for all statistics are negligible across the ensembles and thus not reported.
for every statistic, we also give the deviation between the empirical value and the average across the generated ensemble of random clustered networks .
small deviations suggest that the empirical network structure boils down to the degree distribution and clustering, and thus we turn our attention to possible mechanisms underlying these properties.
in contrast, large deviations suggest that there are other fundamental properties to consider in addition to or, perhaps, instead of clustering.
for each empirical network, we generated  <dig> random graphs constrained to have the observed degree sequences and soffer-vasquez transitivity values.
the table reports average values of several network statistics for the clustered random graphs: network size , mean degree , mean squared degree , soffer-vasquez clustering coefficient (), soffer-vasquez transitivity (), maximum shortest path length between any two nodes , degree correlation coefficient , and modularity .
the value given in brackets is the deviation of the ensemble mean from the corresponding statistic for the empirical network.
deviations are not listed for n, ⟨d⟩ and ⟨d2⟩ as network size and degree sequence are constrained by our algorithm to match the empirical networks perfectly.
of all the empirical networks analyzed, the random counterparts of the the us air traffic network are the only ones that have structural properties almost identical to the real network .
this suggests that the structure of the us air traffic network comes almost exclusively from its degree patterns.
we note that the us air traffic network is the only non-biological one and the most engineered of the networks we consider, and thus may have fewer emergent properties.
the remaining empirical networks  differ considerably from their random counterparts, suggesting that there are important mechanistic features not captured in the random model.
degree correlations vary somewhat systematically among the four biological networks .
the vancouver human epidemiological contact network has significantly higher degree assortativity than our random networks, thus showing that the positive degree correlations are not just the result of degree distribution or clustering, both of which have been found to be positively correlated with assortativity  <cit> .
this suggests the existence of social rules among humans that go beyond  variation in numbers of "friends" and  the tendency for "my friend's friend also to be my friend"  <cit> .
the remaining biological networks , on the other hand, all have negative degree correlations.
our results show that the c. elegans metabolic network, in particular, has degree correlations approximately equal to the amount expected to arise as a random byproduct of degree distribution and clustering.
one reason that a biological network only show random degree correlations might be due to the lack of a clear functional or structural advantage for strong correlations: negatively correlated networks are vulnerable to failures because functionality often depends on a few high degree nodes that provide essential connectivity.
if any of these fail  the whole system fails  <cit> .
on the other hand, positively correlated networks, which have short distances between hub  nodes, may be less favorable because they allow for the propagation of random perturbations   <cit> .
all of the natural networks we study have significantly higher modularity than the corresponding clustered random networks, despite having a wide range of transitivity values.
this suggests that clustering and community structure are not necessarily positively correlated, as has been previously suggested  <cit> .
the high modularity of the little rock foodweb, in particular, has been attributed to its high clustering  <cit> .
our generated clustered random graphs, however, indicate that the degree distribution and high transitivity only account for about half the modularity of the foodweb graph .
there is an extensive literature on the presence and evolution of modularity in protein, metabolic, and ecological networks highlighting its possible roles in functional specialization, innovation and robustness  <cit> .
since clustering and the mechanisms that give rise to it cannot fully account for the modularity of these empirical networks, such mechanistic explanations for the structure are warranted.
CONCLUSIONS
in this work, we have introduced a markov chain simulation algorithm to generate clustered random graphs with a specified degree sequence and level of clustering.
our algorithm perfectly preserves the degree sequence of a random graph and generally maintains other fundamental properties of random graphs like short path length and low degree correlations.
the use of random graphs as controls is a common and effective method for identifying important structural characteristics of biological networks .
our method provides a new null model for use with this technique.
since this method is based on a dynamic process, it can be used to generate both static networks with a specified amount of clustering and dynamic networks with evolving levels of clustering.
furthermore, since the process is a "memoryless" one, additional clustering can be added to any network without having to grow a new one from scratch.
these clustered networks can provide valuable insights into the interdependent impacts of connectedness and redundancy on biological processes, and serve as appropriate null models for investigating the biological significance of other structural attributes.
availability and requirements
• project name: clustrnet
• project home page: http://sbansal.com/clustrnet/
• operating system: platform independent
• programming language: python  <dig>
• other requirements: networkx python package  <dig>
• license: bsd-style
• any restrictions to use by non-academics: none
authors' contributions
sb, sk and lam contributed to algorithm design, implementation and manuscript writing.
all authors read and approved the final manuscript.
supplementary material
additional file 1
supplementary analysis.
additional analysis of algorithm with figures.
click here for file
acknowledgements
the authors acknowledge valuable feedback from joel miller, mark newman, erik volz, alberto segre ted herman, and two anonymous reviewers.
sb acknowledges financial support from the university of texas at austin.
lam acknowledges support from the mcdonnell foundation and nsf grant deb- <dig>

 over the last decade, network models have advanced our understanding of biology at all scales, from gene regulatory networks to metabolic cycles to global food webs. they are also driving the forefront of sociology, information technology and many other disciplines. researchers often build network models from empirical data and then seek to characterize and explain non-trivial structural properties such as heavy-tail degree distributions, clustering, short average path lengths, degree correlations and community structure. many of these properties appear in diverse natural and man-made systems, and can fundamentally influence dynamical processes of and on these networks. clustering is a network characteristic describing the presence of triangles in a network, that is, the propensity of neighbors of a common vertex to also be neighbors with each other. it is an important topological characteristic that can significantly impact dynamical processes over complex networks. clustering is often correlated with local graph properties such as correlations in the number of edges emanating from neighboring vertices and graph motifs, as well as global properties such as community structure. clustering in biological and other empirical networks can stem from two sources: it can arise as a byproduct of other, more fundamental, topological properties such as the degree sequence or degree correlations; or it can be generated directly by some inherent property or mechanism within the system, for example, "the friends of my friends tend to become my friends" in social networks. some researchers have claimed that high clustering is a general feature of complex networks. when we measure clustering in a variety of empirical networks, however, we find that it varies considerably. table shows that the clustering coefficients and transitivity values for these networks span the entire range of possible values. thus, it is important to understand not only the origins of clustering, but also the impact of clustering on network functions and dynamics. towards this end, we introduce a method for generating random networks with a specified level of clustering. the number of nodes, the average node degree, the mean-squared of node degree, clustering coefficient, transitivity, soffer-vasquez clustering coefficient (), and soffer-vasquez transitivity () for a set of empirical networks. related work random graphs are graphs that are generated by some random process. they are widely used as models of complex networks and can assume various levels of complexity. the simplest model for generating random graphs, with only a single parameter, is the bernoulli or erdös-renyi random graph model, which produces graphs that are completely defined by their average degree and are random in all other respects. a slightly more complex and general model is one that generates graphs with a specified degree distribution and ones which are random in all other respects. these models can be extended to include additional structural constraints, such as degree correlations or the density of triangles or longer cycles, as we will demonstrate below. existing methods for generating clustered graphs, however, do not take this approach. one of the first examples is the seminal work of watts and strogatz. they introduced a model that produces networks with high clustering and low average path length, now known as the small world property. although not intended as a generative algorithm for clustered graphs, the model produces graphs with clustering spanning the range from to the graphs generated under this model, however, have rigid spatial structure and cannot accommodate varying degree distributions. the first algorithms that were designed to generate graphs with a specified level of clustering for arbitrary degree distributions belonged to the class of projected bipartite graphs. newman introduced a three-step method that first builds a bipartite graph of individuals and affiliations, then projects the bipartite graph to a unipartite graph of individuals only, and finally runs a percolation process over the unipartite graph. this results in a clustered graph with a degree distribution that depends on the original distributions of numbers of individuals per group and groups per individual. the level of clustering in the final graph varies smoothly from to as a function of the percolation probability. in, guillaume suggested a similar bipartite graph approach. although these approaches can generate clustered graphs with diverse degree distributions, they lack straightforward methods for choosing parameters that yield graphs with not only a pre-specified clustering coefficient but also a pre-specified degree distribution. these algorithms also tends to produce graphs that leave a significant proportion of the graph vertices isolated. a second class of clustered graph models use "growing network" algorithms. the inputs to these models are a degree distribution and level of clustering. the method begins with a set of vertices with no edges; the graph is then "grown" by adding edges based on the degree and clustering constraints. although the algorithms of this class allow for arbitrary degree distributions and levels of clustering, they either require a complex implementation, produce graphs of a highly specific structure or introduce large amounts of degree correlations. finally, the family of statistical models known as exponential random graph models also provide tools to fit the structure of observed networks, for statistics such as degree distribution and number of triangles. these erg model-based methods, although they have advanced significantly in recent years, still suffer from problems of degeneracy and computational intractability for large networks. our approach here, we present a model that generates undirected, simple and connected graphs with prescribed degree sequences and a specified frequency of triangles, while maintaining a graph structure that is as random as possible. or multiedges; and a connected graph is one where every node in the graph is reachable by a path of edges from every other graph node.) prior models in this area were intended to generate clustered graphs that replicate the properties of real-world networks; our goal, on the other hand, is to generate a class of null networks with arbitrary degree distributions that are simple and connected and have a high density of triangles, but are random in all other respects. this method thus leads to two valuable applications. first, network structure fundamentally influences the functions of and dynamical processes on networks. we can use clustered random graphs to systematically study the consequences of clustering, both independently and in combination with various degree patterns. second, these networks can serve as null models for detecting whether an empirical network can be boiled down to its degree distribution and clustering values or, instead, contains substantial degree correlations or other important structures. one would first use the algorithm to generate an ensemble of networks that match the empirical degree sequences and clustering values, and then compare the structural, functional, or dynamical properties of the empirical network to those of the clustered random networks. we focus here on the role of these networks as null models as it is crucial to have appropriate random controls in the study of biological systems, as has been demonstrated in. the rest of this article is organized as follows. in the implementation section, we review common measures of clustering and introduce our markov chain model and algorithm for generating clustered graphs with a specified degree sequence. in the results section, we test our algorithm with numerical simulations and explore the structural properties of the generated graphs. the discussion section is devoted to a demonstration of the randomly generated clustered networks as null networks for the analysis of empirical networks. we finish off with our conclusions, presenting the benefits of our markov chain simulation method for biological networks. implementation our clustered random graph generation method begins with a random graph and iteratively rewires edges to introduce triangles. network rewiring, also known as edge swapping, is a well-known method for generating networks with desired properties. two edges are called adjacent if they connect to a common node. each rewiring is performed on two non-adjacent edges of the graph and consists of removing these two edges and replacing them with another pair of edges. specifically, a pair of edges and is replaced with either and, or and. this change in the graph leaves the degrees of the participating nodes unchanged, thus maintaining the specified degree sequence. below we describe a rewiring algorithm that increases the level of clustering in a random graph, while preserving the degree sequence. the algorithm we develop below is implemented in python as clustrnet. it is based on networkx, an open-source python library available for download at, which provides standard graph library functionality. the source code for clustrnet, along with documentation and test network datasets, is available on the web. our algorithm joins a existing suite of random graph model-based software tools for the analysis of biological networks and the dynamics on them. measures of clustering we begin with a graph g = which is undirected and simple. v is the set of vertices of g and e is the set of the edges. we let n = |v| and m = |e| denote the number of nodes and edges in g, respectively. the degree of a node i will be denoted di. the set of degrees for all nodes in the graph makes up the degree sequence, which follows a probability distribution called the degree distribution. clustering is the likelihood that two neighbors of a given node are themselves connected. in topological terms, clustering measures the density of triangles in the graph, where a triangle is the existence of the set of edges,, between any triplet of nodes i, j, k. to quantify the local presence of triangles, δ is defined as the number of triangles in which node i participates. since each triangle consists of three nodes, it is counted thrice when we sum δ for each node in the graph. thus the total number of triangles in the graph is a triple is a set of three nodes, i, j, k that are connected by edges and, regardless of the existence of the edge. the number of triples of node i is simply assuming di ≥ to compute the total number of triples in the graph, τ, we sum τ for all i ∈ v. the clustering coefficient was introduced by watts and strogatz as a local measure of triadic closure. for a node i with di ≥ the clustering coefficient c is the fraction of triples for node i which are closed, and can be measured as δ = τ. the clustering coefficient of the graph is then given by: where n is the number of nodes with c ≥ some authors do define the clustering coefficient for all nodes of g. a more global measure of the presence of triangles is called the transitivity of graph g and is defined as: although they are often similar, t and c can vary by orders of magnitude. they differ most when the triangles are heterogeneously distributed in the graph. these traditional measures of clustering are degree-dependent and thus can be biased by the degree sequence of the network. the maximum number of possible triangles for a given node i is just its number of triples ). for a node which is connected to only low degree neighbors, however, the maximum number of possible triangles may be much smaller than τ. to account for this, a new measure for clustering was introduced in that calculates triadic closure as a function of degree and neighbor degree. specifically, the soffer-vasquez clustering coefficient () and transitivity () are given by: where ω measures the number of possible triangles for node i, and nω is the number of nodes in g for which ω > we note that and are undefined if ω = Σi ω = ω is computed by counting the maximum number of edges that can be drawn among the di neighbors of a node i, given the degree sequence of i's neighbors; this value is often smaller than. for example, consider a star network of five nodes, where four nodes have degree and one node has degree although the total number of triples is τ = the number of possible triangles is ω = because the degree one nodes preclude their formation. the computation of ω must be done algorithmically and is not possible in closed form. generative model here we develop a model to generate a simply connected random graph with a specified degree sequence and a desired level of clustering. generating random graphs uniformly from the set of simply connected graphs with a prescribed degree sequence is a well-studied problem with algorithmic solutions. one of the simplest and most popular of these generative algorithms was suggested by molloy and reed and is known as the configuration model. given a specific realizable degree sequence, {di}, this method assigns dj half-edges to each node j, and then randomly connects pairs half-edges to create edges until there are no half-edges left. and the erdos-gallai criterion although the model sometimes produces graphs that are not simple or connected, this can be remedied by subsequently removing multiple edges and self loops from the constructed graph and keeping only the largest connected component. our method begins by using this approach to generate a simple, connected random graph g, with a specific realizable degree sequence d. we then introduce triangles into g using a markov chain process without disturbing the degree sequence until we achieve the desired level of clustering, as follows. let gd be the set of all simple, connected graphs with degree sequence d. if are the graphs of gd, then we let be the states of the markov chain, p, where xi represents the state in which our graph g = gi. the states xi and xi+ are connected in the markov chain if gi can be changed to gi+ with the rewiring of one pair of edges. the state space of the markov chain p is connected because there exists a path from xi to xj by one or more rewiring moves that leave the degree sequence unchanged. our clustered graph generation algorithm involves starting with the random graph g and transitioning from the state corresponding to g to other states of p until a halting condition is reached. a transition from one state of the markov chain to another only occurs when the algorithm makes an edge rewiring that both increases the clustering of the graph and leaves the graph connected. since a rewiring does not alter the degree sequence of the graph, the rewired graph is still in gd. the transition probabilities of the markov chain for a pair of connected states, xi to xj, are: where clust is a clustering measure for graph gx, which can be replaced by any of the measures introduced in section. the algorithm continues searching for a feasible rewiring until one is found. if a feasible move is not found, a transition is not made and the process remains in the current state. the markov chain above is finite and aperiodic, but not irreducible as the process can never transition to a state in which the graph has lower clustering. it does, however, have an absorbing state, x*, in which the transitivity of g* is greater than or equal to the desired transitivity or is the maximum possible transitivity given the particular degree sequence and connectivity constraints. algorithm to generate clustered graphs, we apply the above markov chain simulation model by iteratively applying rewirings that increase graph clustering. each rewiring takes a set of five nodes {x, y y z z2}, connected by four edges {,,, }, and swaps the outer edges: {,,, }. this introduces a triangle among nodes {x, y and y2}, without perturbing the degree sequence. the algorithm proceeds as follows: input: a realizable degree sequence {di} a desired clustering value, target initialization: generate a random graph g with degree sequence {di}, and measure the clustering of g, clust. while clust <target do uniformly select a random node, x, from the     set of all nodes of g such that dx > uniformly select two random neighbors, y    and y of x such that dy > and    dy > and y1≠y uniformly select a random neighbor, z    of y and a random neighbor, z of    y such that z ≠ x, z ≠ x,    z ≠ z gcand: = g where gcand is the candidate    graph to which the transition may be made. if and do not exist then    rewire two edges of gcand: delete and, add and.    end update the value of clust by measuring    δ if relevant) for the nodes involved    in the rewiring and their neighbors. if clust > clust and gcand    is connected then    g: = gcand    end end output: a random graph, g with degree sequence {di} and clust ≥ target. the algorithm terminates when the graph attains at least the desired level of clustering or reaches a threshold number of unsuccessful rewiring attempts. in the latter case, the algorithm returns the graph with the maximum clustering achieved. for practical purposes, a threshold is placed on the number of unsuccessful attempts made by the algorithm in clustrnet for the case that the desired clustering cannot be reached. due to the random restarts made at every step, the algorithm is prevented from getting trapped in local minima. the algorithm is designed to increase clustering while preserving both the degree sequence and connectedness of the graph. however, there are some cases where the desired clustering can only be reached by disconnecting the graph; and thus clustrnet provides the option of removing the connectivity constraint. choice of clustering measure the algorithm is defined independent of the choice of clustering measure. the term clust in the algorithm above can be replaced by any clustering measure described in section. clustrnet includes all four of these clustering measures. the algorithm output varies with the choice of clustering measure. the clustering coefficient is a local measure; and thus c and yield networks that are only locally optimized for the desired level of clustering. the algorithm may have difficulty attaining target clustering values when using the absolute clustering measures because of joint degree constraints on the possible numbers of triangles, as with the example presented in section. the soffer-vasquez clustering measures, which explicitly consider joint degree constraints, provide a way around this difficulty. although the rewiring in our algorithm changes the joint degree distribution of the graph, ω is not altered significantly during network generation. thus, when using or, clustering is increased primarily by the addition of triangles ) rather than decreasing ω). types of graph changes as shown in figure there are six types of triangles that can be added or removed for every pair of edges that are rewired. as illustrated in figure 1d, these additions and removals can occur in combination. • type a: the addition of the edge between vertices y and y guarantees the addition of one triangle in every rewiring event. • type b: the addition of the edge could create new triangles with shared neighbors of y and y • type c: the addition of the edge could add a triangle if there existed edges between x and z and x and z • type d: the addition of the edge between vertices z and z could create new triangles with shared neighbors of z and z • type e: the removal of edges and removes one triangle each if the edges or exist. • type f: the removal of the edges between vertices y and z and y and z could lead to the removal of existing triangles with shared neighbors of y and z or y and z we note that although the type a addition is a special case of type b, the type c addition is a special case of type d, and the type e removals are a special case of type f, we distinguish them because they have different probabilities of occurrence. our look-ahead strategy only allows rewiring moves when the total number of type e and f losses is fewer than the total number of type a, b, c, and d gains. computational complexity like many heuristic search methods, the algorithm we propose can be computationally expensive. the method outlined in section requires o steps to generate a connected graph, and up to o steps to randomize the graph, where m is the number of edges in the graph. at each step of randomization, we test that the graph remains connected operation), resulting in an overall o random network generation process. a naive computation of the transitivity/clustering coefficient requires checking every node for the existence of edges between every pair of neighbors of the node. this step requires o() operations, where n is the number of nodes and dmax is the maximum degree of any node in the graph. the most expensive step of our algorithm is the introduction of triangles via rewiring. a single rewiring step requires o operations for switching edges, checking for connectivity and updating the clustering measure. although we cannot analytically calculate the number of attempted rewiring steps required to reach the desired transitivity, we have found it empirically to be o. thus, the average complexity of the clustered network algorithm presented here is o. this complexity has been computed for the most naive versions of our algorithms; and more efficient implementations may improve the complexity greatly. for example, we might improve efficiency by performing connectivity tests once every x rewirings rather than during every rewiring, as proposed in.  performance to test our algorithm, we generate networks with three different degree distributions and for a range of clustering target values. specifically, we use poisson, exponential e-κ) and a truncated scale-free ) degree distribution, each with a mean degree of five. starting with random graphs with specific degree sequences matching these degree distributions, we rewire the networks towards sv-transitivity ) targets and transitivity targets in addition to allowing the algorithm to generate disconnected graphs. these targets allow us to evaluate how the clustering measure and connectivity requirement constrain the results, and the second target, in particular, allows us to compare results to other algorithms. figure illustrates the rewiring of a network with a poisson distributed degree sequence evolving towards higher transitivity. we evaluate the performance of our algorithm in comparison to one representative network growth algorithm and one representative bipartite network method. specifically, we measured the discrepancies between input and output degree distributions and transitivity values. our algorithm preserves the input degree sequence perfectly, while there are considerable mismatches between the input and output degree distributions in the volz and newman models. for both comparisons, the transitivity values of the output graphs from our algorithm exactly match the target transitivity values, when those values can be attained given the network topology and the requirements of the algorithm. some values at the lower end of the clustering scales cannot be reached because the expected transitivity for random graphs of specified degree distributions scales as where pk is the degree distribution. this value is small for the poisson degree distribution but can be quite high for highly-skewed degree distributions such as the scale-free degree distribution. for the first comparison, the connectivity constraint imposes a maximum on the attainable clustering value, thus the highest sv-transitivity values cannot be reached without disconnecting the graphs. in these cases, our algorithm returns the graph with the largest attainable sv-transitivity that is less than the desired sv-transitivity. for the second comparison,, our algorithm performs better in all cases compared to the volz and newman models. due to the definition of the standard transitivity measure, however, we see that the networks reach a maximum t value, beyond which no further clustering can be accommodated by the network topology. structural properties of generated networks there are several other topological properties that can strongly influence network function and dynamics. among these are degree correlations, community structure, and average path length. we have specifically developed this model to increase clustering with minimal structural byproducts. thus, we confirm that we have reached this goal by measuring the above properties in the networks generated by our algorithm. we evaluated the extent to which the algorithm introduces degree correlations by comparing random graphs to clustered random graphs generated by our algorithm and the volz and newman algorithms and average path lengths in random graphs with specified degree distributions compared to clustered random graphs with the same degree distributions and t = generated by our algorithm, as well as the volz and newman algorithms. the graphs present averages over graphs generated by each algorithm. our algorithm introduces fewer degree correlations than the alternatives, and the clustered graphs have only slightly higher average path lengths than their random counterparts: for the poisson random graphs versus for the clustered graphs; and for the exponential random graphs versus for the clustered graphs. several authors have discussed the relationship between clustering and community structure. as figure shows, the addition of triangles leads to modular structure. this behavior is not surprising: as the number of edges in the graph is constrained, sets of connected nodes with high ω values must be brought together to create additional clustering. although the presence of a significant proportion of triangles tends to separate the network into modules, it is not clear that clustering is always sufficient to explain the modular structure of a graph. we explore this further below. short average path lengths are a characteristic feature of random graphs. to quantify the impact of our algorithm on path lengths, we calculated the average path length for each node to all other nodes, and then compared the distributions of these values for several random and random clustered graphs. while our algorithm mostly maintains short average path lengths, the mean of the path length distribution does tend to be slightly larger for the clustered graphs than for the corresponding random graphs. the intuition behind this increase in average path length may lie in the increased community structure: as graphs become more clustered and separate into subgroups, nodes in different groups require more links to reach each other. given that our algorithm can generate graphs of high clustering while preserving short path lengths, this introduces a novel method of generating graphs with the small world property without the correlations of watts-strogatz graphs. discussion application: analysis of empirical networks it is crucial to have random controls in the study of biological systems. our algorithm can be used to generate null models and applied to the detection of structure in empirical biological networks. we can generate ensembles of clustered random networks with empirically estimated degree sequences and clustering values to ascertain whether empirical networks have significant non-random structure in other respects. we demonstrate this application using representatives from four classes of biological networks. we also analyze one non-biological network that is made of human transportation links as it provides contrast to the range of topological properties and design principles found in the biologically-motivated networks. the five real networks are as follows: a) a trophic exchange network for the little rock lake in wisconsin; b) a protein interaction network for yeast; c) a metabolic network for the eukaryote caenorhabditis elegans; d) a network made up of epidemiologically-relevant contacts for individuals in the city of vancouver; and e) a transportation network, made up of us metropolitan areas connected by air travel. these networks represent a diverse set of applications and are systems that are well-studied in their respective literatures. the basic statistics of these networks, including clustering values, are listed in table we use the following method to quantify deviations from randomness in these networks. first, we use our algorithm to generate clustered random networks constrained to match the empirical degree sequence and clustering values. second, we select a set of network topological measures, and compare these quantities for the empirical graph to the corresponding average quantities across the ensemble of generated graphs. specifically, we generate clustered random networks for each empirical network, constrained to match the empirical degree sequence and sv-transitivity. in addition to the degree and clustering metrics, we also calculated diameter, degree correlation coefficient and modularity. other than diameter, each of these metrics range from to the standard deviations for all statistics are negligible across the ensembles and thus not reported. for every statistic, we also give the deviation between the empirical value and the average across the generated ensemble of random clustered networks. small deviations suggest that the empirical network structure boils down to the degree distribution and clustering, and thus we turn our attention to possible mechanisms underlying these properties. in contrast, large deviations suggest that there are other fundamental properties to consider in addition to or, perhaps, instead of clustering. for each empirical network, we generated random graphs constrained to have the observed degree sequences and soffer-vasquez transitivity values. the table reports average values of several network statistics for the clustered random graphs: network size, mean degree, mean squared degree, soffer-vasquez clustering coefficient (), soffer-vasquez transitivity (), maximum shortest path length between any two nodes, degree correlation coefficient, and modularity. the value given in brackets is the deviation of the ensemble mean from the corresponding statistic for the empirical network. deviations are not listed for n, ⟨d⟩ and ⟨d2⟩ as network size and degree sequence are constrained by our algorithm to match the empirical networks perfectly. of all the empirical networks analyzed, the random counterparts of the the us air traffic network are the only ones that have structural properties almost identical to the real network. this suggests that the structure of the us air traffic network comes almost exclusively from its degree patterns. we note that the us air traffic network is the only non-biological one and the most engineered of the networks we consider, and thus may have fewer emergent properties. the remaining empirical networks differ considerably from their random counterparts, suggesting that there are important mechanistic features not captured in the random model. degree correlations vary somewhat systematically among the four biological networks. the vancouver human epidemiological contact network has significantly higher degree assortativity than our random networks, thus showing that the positive degree correlations are not just the result of degree distribution or clustering, both of which have been found to be positively correlated with assortativity. this suggests the existence of social rules among humans that go beyond variation in numbers of "friends" and the tendency for "my friend's friend also to be my friend". the remaining biological networks, on the other hand, all have negative degree correlations. our results show that the c. elegans metabolic network, in particular, has degree correlations approximately equal to the amount expected to arise as a random byproduct of degree distribution and clustering. one reason that a biological network only show random degree correlations might be due to the lack of a clear functional or structural advantage for strong correlations: negatively correlated networks are vulnerable to failures because functionality often depends on a few high degree nodes that provide essential connectivity. if any of these fail the whole system fails. on the other hand, positively correlated networks, which have short distances between hub nodes, may be less favorable because they allow for the propagation of random perturbations. all of the natural networks we study have significantly higher modularity than the corresponding clustered random networks, despite having a wide range of transitivity values. this suggests that clustering and community structure are not necessarily positively correlated, as has been previously suggested. the high modularity of the little rock foodweb, in particular, has been attributed to its high clustering. our generated clustered random graphs, however, indicate that the degree distribution and high transitivity only account for about half the modularity of the foodweb graph. there is an extensive literature on the presence and evolution of modularity in protein, metabolic, and ecological networks highlighting its possible roles in functional specialization, innovation and robustness. since clustering and the mechanisms that give rise to it cannot fully account for the modularity of these empirical networks, such mechanistic explanations for the structure are warranted.  in this work, we have introduced a markov chain simulation algorithm to generate clustered random graphs with a specified degree sequence and level of clustering. our algorithm perfectly preserves the degree sequence of a random graph and generally maintains other fundamental properties of random graphs like short path length and low degree correlations. the use of random graphs as controls is a common and effective method for identifying important structural characteristics of biological networks. our method provides a new null model for use with this technique. since this method is based on a dynamic process, it can be used to generate both static networks with a specified amount of clustering and dynamic networks with evolving levels of clustering. furthermore, since the process is a "memoryless" one, additional clustering can be added to any network without having to grow a new one from scratch. these clustered networks can provide valuable insights into the interdependent impacts of connectedness and redundancy on biological processes, and serve as appropriate null models for investigating the biological significance of other structural attributes. availability and requirements • project name: clustrnet • project home page: http://sbansal.com/clustrnet/ • operating system: platform independent • programming language: python • other requirements: networkx python package • license: bsd-style • any restrictions to use by non-academics: none authors' contributions sb, sk and lam contributed to algorithm design, implementation and manuscript writing. all authors read and approved the final manuscript. supplementary material additional file 1 supplementary analysis. additional analysis of algorithm with figures. click here for file acknowledgements the authors acknowledge valuable feedback from joel miller, mark newman, erik volz, alberto segre ted herman, and two anonymous reviewers. sb acknowledges financial support from the university of texas at austin. lam acknowledges support from the mcdonnell foundation and nsf grant deb- 
here we develop and implement a new markov chain simulation algorithm to generate simple, connected random graphs that have a specified degree sequence and level of clustering, but are random in all other respects. these graphs allow for systematic study of the impacts of connectivity and redundancies on network function and dynamics. finding appropriate null models is crucial in bioinformatics research, and is often difficult, particularly for biological networks. this process is a key step in unraveling the functional consequences of the structural properties of empirical biological systems and uncovering the mechanisms that drive these systems. the implementation of the algorithm provides the generation of random graphs optimized according to a local or global, and relative or absolute measure of clustering. as we demonstrate, the networks generated by clustrnet can serve as random controls when investigating the impacts of complex network features beyond the byproduct of degree and clustering in empirical networks. networks of biochemical interactions among proteins, epidemiological contacts among hosts, and trophic interactions in ecosystems, to name a few, have provided useful insights into the dynamical processes that shape and traverse these systems.
 complex biological systems are often modeled as networks of interacting units. networks of biochemical interactions among proteins, epidemiological contacts among hosts, and trophic interactions in ecosystems, to name a few, have provided useful insights into the dynamical processes that shape and traverse these systems. the degrees of nodes and the extent of clustering are two of many well-studied network properties that can fundamentally shape a system. disentangling the interdependent effects of the various network properties, however, can be difficult. simple network models can help us quantify the structure of empirical networked systems and understand the impact of various topological properties on dynamics.  here we develop and implement a new markov chain simulation algorithm to generate simple, connected random graphs that have a specified degree sequence and level of clustering, but are random in all other respects. the implementation of the algorithm provides the generation of random graphs optimized according to a local or global, and relative or absolute measure of clustering. we compare our algorithm to other similar methods and show that ours more successfully produces desired network characteristics. finding appropriate null models is crucial in bioinformatics research, and is often difficult, particularly for biological networks. as we demonstrate, the networks generated by clustrnet can serve as random controls when investigating the impacts of complex network features beyond the byproduct of degree and clustering in empirical networks.  clustrnet generates ensembles of graphs of specified edge structure and clustering. these graphs allow for systematic study of the impacts of connectivity and redundancies on network function and dynamics. this process is a key step in unraveling the functional consequences of the structural properties of empirical biological systems and uncovering the mechanisms that drive these systems. 