The Bass diffusion model: agent-based implementation on arbitrary networks

We show how the combined use of the free software packages networkX and NetLogo allows to implement quickly and with large flexibility agent-based network simulations of the classical Bass diffusion model and of its extensions and modifications. In addition to the standard internal graph implementations available in NetLogo (random, Barabasi-Albert-1 and small world), one can thus employ more complex Barabasi-Albert and small-world networks, plus scale-free networks with arbitrary power-law exponent $\gamma$ built in networkX through a configuration model algorithm. It is also possible to induce degree correlations in the networks in a controlled way via Newman rewiring and to simulate dynamics on arbitrary signed networks (networks where link can have positive or negative weights, with corresponding effects on diffusion). Some new results obtained in the agent-based simulations (and differing from those in mean-field approximation) are the following. The introduction of assortative correlations in scale-free networks has the effect of delaying the adoption peak in the Bass model, compared to the uncorrelated case. The peak time $t_{max}$ depends strongly also on the maximum degree effectively present in the network. For diffusion models with threshold on signed network, if negative influences have a weight equal to or greater than positive influences, then a high level of clustering tends to cause adoption blockades. In connection to this, by analysing statistical ensembles of assortative scale-free networks generated via Newman rewiring one observes a remarkable strong correlation between the function of the average degree of first neighbors $\bar{k}_{nn}(k)$ and the average clustering coefficient depending on the degree $\bar{C}(k)$.


I. INTRODUCTION
In the quantitative analysis of complex systems, in particular for applications to social science and economics, agent-based simulations represent a valid alternative and complement to modelling techniques based on ordinary or stochastic differential equations.Agent-based simulations benefit from the steady increase in available computational power.They allow to represent the behavior of single individuals and to discover the dynamical emergence of collective behavior and interactions at an aggregate level.
We are mainly interested in this work into agent-based diffusion models of innovation and technological change, a phenomenon of great economic and social relevance, systematically studied since the 1960s [1] and mathematically formalized through the Bass equation and its developments (see e.g.[2][3][4][5]).The review by Kiesling et al. [6] summarizes briefly the classical theory of Bass and describes all the main agent-based models of innovation diffusion, incorporating contents of previous reviews [7][8][9].Kiesling et al. emphasize the importance of agent-based models for overcoming issues and limitations of the analytical models through an individual-based modeling approach.
More specifically, we will consider the implementation of diffusion models on complex networks.This is an essential aspect for social science models, independently from their detailed formulation.In our previous work we investigated the Bass equation on many kinds of scale-free networks in Heterogeneous Mean Field approximation [10][11][12].Recently we developed some numerical techniques, based on Newman rewiring, for the explicit construction of scale-free networks with assortative degree correlations (a typical feature of social networks).On these networks it is possible to solve the Bass equations for each node.The codes were first written in C++ and Mathematica, then in Python, taking full advantage of object-based programming with the powerful package networkX [13][14][15][16].Some typical features of the networks generated by Newman rewiring are represented in Figs. 1, 2. Fig. 1 shows an r-K plot of some small network ensembles generated with different target correlations and, for comparison, two "clouds" of Barabasi-Albert networks built with a standard stochastic preferential attachment process.The quantities r and K represent respectively the Newman assortativity coefficient and the network average of the average nearest neighbor degree of each node.In terms of the degree distribution P (k) and of the average nearest neighbor degree function knn (k), one has K = k P (k) knn (k).
The use of r-K plots is quite natural for assortative and disassortative rewiring.When the rewiring preserves the degree distribution, the variations ∆r and ∆K in a rewiring step are univocally related by where L is the total number of links in the network, N the total number of nodes, σ 2 q the variance of the excess degrees of the nodes, and A, B, C, D are the degrees of the nodes involved in the rewiring step [17].Both r and K are relevant for diffusion processes on the network.Greater assortativity generally leads to an accelerated diffusion in the initial stages [13], while a larger K decreases the epidemic threshold ( [17] and refs.).Fig. 2 shows an FIG.1: Location in the r-K plane of some small statistical ensembles of scale-free networks, each one with 1000 nodes.The Barabasi-Albert-1 and Barabasi-Albert-2 networks are generated with a standard preferential attachment process, in which new nodes are attached respectively to 1 and 2 existing nodes.Their maximum degree is variable, which accounts for the larger dispersion.In the other "clouds" the degree distribution is fixed through a configuration model algorithm; the different realizations have been obtained by Newman rewiring with assortative target correlations for BM1 and BM2 [13], and with uncorrelated target correlations for the remaining ones.The plot coordinates r and K represent respectively the Newman assortativity coefficient and the network average of the nearest-neighbor degrees of the nodes (see exact definition in the text, and also see the general relation between ∆K and ∆r, according to which in a degree-conserving rewiring ∆K and ∆r always have opposite signs).
example of a scale-free assortative network obtained with the configuration model followed by rewiring with a target correlation matrix.
The first purpose of this work is to show and test how the assortative scale-free networks generated by our codes can be quickly exported in standard graphml format into the simulation software NetLogo, in order to implement on them the agent-based Bass diffusion model.As recalled in Sect.II, NetLogo is widely used for agent-based simulations; it has some built-in network structures, but is quite limited under this respect.The Python connector PyNetLogo can be used to control NetLogo and to perform a numerical and statistical analysis of the results of the simulations.In Sect.III we report the results of agent-based simulations with assortative networks.Sect.III A describes a relation occurring, in assor-FIG.2: An example of an assortative network obtained via Newman rewiring from a scale-free configuration model network with 1000 nodes and critical exponent γ = 2.5.Typical values of r and K for networks of this kind are shown in Fig. 1.The minimum degree of the nodes is 2 and their average degree about 4. Note the strongly connected central region, where the hubs link preferentially to other hubs (compare Fig. 4).The long chains in the periphery are due to the probabilistic enforcement in the rewiring of a large value of the correlation P (2|2).
tative scale-free networks, between the function knn (k) and the clustering-degree function

C(k).
A strong correlation was found computing the average of C(k) over an ensemble of networks generated by rewiring.In Sect.III B we review some recent applications of NetLogo to the Bass diffusion model with improved dynamical rules (e.g., including marketing-mix utility functions, analysis of brands, cathegories of adopters, opinion leaders etc.).This review is motivated by the fact that the techniques described in Sect.II and III for assortative networks and for the peak diffusion time could in principle be applied to all these models.
Sect.IV presents the second main achievement of this work, namely the implementation in NetLogo of the Bass model on arbitrary signed networks, following and extending the work by Mueller and Ramkumar [18].The extension concerns both the network aspect and the transition rules.Any network which can be generated in networkX, including our assortative scale-free networks and modifications (for example, with cuts in the power law tail), or custom-built small-world networks etc., can be transformed into a signed network with given probability of positive/negative links or also with a continuous random distribution of their weights.Then, any kind of transition rules compatible with NetLogo, like those reviewed in Sect.III B, can be implemented on these networks.Results confirm Mueller's concern that the presence of a threshold for diffusion based on the computation of positive and negative feedback of neighbors hinders the process of spreading by influencing the clustering effect of the network itself.This process is dependent on both the amount and the weight of negative links, provided that there is a random distribution of the seed.

II. MAIN FEATURES OF NETLOGO SIMULATIONS
NetLogo is a free simulation software for agent-based models, widely used in the social and economic sciences [19].The transition rules which define the behavior of the agents can be set with a high degree of flexibility.We gave in [13] a first example of agent dynamics corresponding to the classical network Bass model, with a suitable renormalization of the imitation coefficient q in order to allow comparisons among different network topologies.
In the simulation one can distinguish between adoptions due to network-social effects (the Bass q-term) and those due to "broadcast" effects (the Bass "advertising" p-term).The values of the p and q parameters are fixed as global variables, or global.In the setup part of the code the agents are defined, with possible states of adopter or non-adopter.In the network setup part, the procedures create-network and make-node create the new nodes and attach them to the existing nodes according to the prescriptions for Barabasi-Albert networks (only of type-1, i.e., with one link for each new node), Erdös-Renyi random networks or simple ring small-world networks.Graphically, a visualization layout is generated.
Alternatively, one can import arbitrary networks in graphml format, as explained below.
The number of initial adopters ("seed") can be chosen in the user interface, in addition to the total number of agents, or population, and to the parameters of social influence and broadcast influence.
The adopt procedure for social influence adoptions starts with a count of the number k of nearest neighbors of each node in the network; if the agent on this node has not yet adopted, it adopts with a probability equal to qk/⟨k⟩, where ⟨k⟩ is the network average of k.The adopters change color in the graphical interface and their total is updated and represented as a function of time (i.e., of the number of steps or "ticks"), to build a typical S-shaped curve.
The derivative of the S curve cannot be directly obtained; however, it is possible to manipulate the data produced by the model through the use of extension modules and connectors.Two well known available tools are the Mathematica [20] and R [21] connectors.Here the PyNetLogo connector was used [22], namely a library that allows to con-trol NetLogo by means of the Python programming language.PynetLogo can be called from a main program in order to launch a simulation and to do some straightforward statistical analysis.To this end, one further needs the package ctype, for wrapping the dll libraries and calling functions in shared libraries, and the module os, in order to import the environment variable corresponding to JAVA HOME.Also PyNetLogo must be im- shown in [13] and is available at https://github.com/Ladilu/python-bass-accessible.
Then, the netlogo.repeatreport command is used for returning the desired data (in our case, the number of agents that have adopted) from NetLogo to the Python workspace.This action can be repeated for a certain number of ticks of the simulation.Some basic examples, not related to the current study, are available at https://pynetlogo.readthedocs.io/en/latest/.
In our case the duration of the simulation has been set to 100 ticks, well beyond the saturation of the diffusion curve.Then the result is transformed into a pandas data-frame and the derivative of the curve is obtained by the diff method.In this way one can identify the adoption peak time t max , namely the time at which the number of new adoptions per unit time reaches its maximum.This quantity is useful for characterizing the Bass diffusion process when there are no initial adopters.Such a characterization is not possible in the pure SI model, in which being the p-term absent, diffusion does not start without an initial seed.Therefore in the SI model the peak time depends strongly on the initial conditions and cannot be easily put in relation, e.g., to the network topology.
For a random graph the network setup is different.The procedure wire4 creates the links with a probability set in the user interface.A window in the user interface displays a list of the nodes' degrees and can be programmed to show the average degree.For importing an external graph, e.g. in the case of scale-free assortative networks, an extension of the software is needed called nw extension, with the command nw:load-graphml.See code examples at https://github.com/Ladilu/MuellerBass accessible.

III. AGENT-BASED SIMULATIONS WITH ASSORTATIVE NETWORKS
By performing agent-based simulations of Bass diffusion with the techniques described above, one can obtain information about peak diffusion times, to be compared with the results of models based upon differential equations.
In [13] we have computed peak diffusion times on scale-free assortative networks generated via configuration model and Newman rewiring.A large system of coupled differential equations was used, namely one equation for each node.This was possible because realizations of the networks were available, and not only their probabilistic degree distribution and correlation functions.It turns out that, unlike in the HMF approximation, the diffusion peak is reached earlier in assortative than in uncorrelated networks.One also observes a strong dependence on the maximum degree effectively present in the network: the larger this degree, the shorter the peak diffusion time.
These results are confirmed by the agent-based simulations: see Tab.I.It is further observed that when the maximum degree is very large, the peak time is delayed for uncorrelated networks.Note that here the Bass coefficients p and q have been chosen to be smaller than in [13], since all agent-based models include a finite time for the spreading process of the technology .

A. Relation between assortativity and the clustering-degree function C(k)
Considerations on the role of clustering in diffusion processes (see also Sect.IV) suggest to use our algorithm of Newman rewiring for investigating the relation between clustering and assortativity in scale-free networks.This is a further example of the advantage of using full statistical ensembles of networks with pre-defined correlations.Only in such ensembles can certain correlations become evident.
On the relation between clustering and assortativity only a few empirical studies have been published, limited to the total clustering coefficient C. For example, in [23] a weak positive correlation between C and r has been reported.Looking at four sets of biological networks, it was found that their representation in an r-C plane occupied a bounded region with elongated shape.
A qualitative analysis of our assortative networks obtained with Newman rewiring, like that in Fig. 2, indicates that the densely connected core is made of hubs of intermediate   [13] and in uncorrelated networks.All networks have scale-free exponent γ = 2.5, number of nodes N = 1000, minimum degree k min = 2 and have been generated via configuration model plus Newman rewiring.The parameters for the Bass diffusion equations are p = 0.025, q = 0.155.One observes that the diffusion peak is reached earlier in assortative than in uncorrelated networks.
size.These nodes have a degree around a value k 0 such that the function knn (k) is close to its maximum at k 0 ; they are thus able to find in the network approximately k 0 neighbors of similar degree.On the contrary, the hubs with k ≫ k 0 cannot find enough assortative partners with similar degree, and therefore lie on the decreasing part of the knn (k) plot.
It can be expected that the assortative core has a high clustering level, and this can be confirmed by computing the average over several rewiring cycles of the function C(k) which gives the mean clustering coefficient of the nodes of the newtwork having degree k.
The function C(k) has been previously evaluated for some large real social networks [24] and for a class of rewired BA networks [25], but is otherwise little known.We find that in a statistical ensemble of uncorrelated scale-free networks built via configuration model, C(k) is very small and exhibits a random behavior (see Fig. 3, obtained through Newman rewiring with uncorrelated target).Using a correlated target, the function changes completely and clearly shows a high level of clustering in the assortative core, see Fig. 4. Codes are available at https://github.com/Ladilu/MuellerBass accessible.

B. Other agent-based models of Bass diffusion
This Subsection contains a brief review of recent results on agent-based simulations of the Bass diffusion model.The techniques described above for assortative networks and for the peak diffusion time could be applied to these models.In Sect.IV, however, we will focus on the version proposed by Mueller and Ramkumar [18] on signed networks, which requires some specific steps for assigning the weights of the graph edges.
Kiesling et al. [6] describe several applications of agent-based Bass diffusion models.They can serve either as intuition aids for the purpose of theory building or as tools to analyze real-world scenarios and obtain policy recommendations, also in sight of future management decisions which need some form of support.The latter stream of research integrates the Bass model with further elements which were not introduced at first in [2], namely the marketing mix factors: product, price, promotion and distribution.
An analysis of brands was implemented in [26].The adopters are divided in three categories: pioneers, early adopters and late adopters.The model combines brand-level diffusion curves in order to form a product-type diffusion curve.In order to know the marketing mix parameters for the brands it is enough to have an initial evaluation of the brand agents' characteristics and of the proportion of the adopters.Then, an individual threshold can be built at the microlevel for simulating with NetLogo the diffusion at the macro level of a given product category.In this real-world scenario the network is fixed but in principle an extension to heterogenous networks is allowed and encouraged.
Another simulation dynamics is based on the concept of critical mass for diffusion, introduced systematically by Watts and Dodds [27] as constituted by individuals who are easily influenced by "influentials", namely the ones who contribute to create the determinant opinion about a single product.The influentials came to occupy a central place in the literature dealing with diffusion of innovations, of which one main example is the previous 1995 edition of [1].They are also called opinion leaders and they are especially relevant to the diffusion of certain technologies such as mobile phones and computers, which change the social behaviour of people.
One study which examines the opinion leaders' role by means of agent-based simulations is [28].It is found that innovative behaviour of opinion leaders yields a higher adoption percentage; in addition to that, another advantage of the presence of opinion leaders is a faster diffusion process, as it was measured from simulations.The threshold for adoption is calculated using a simplified version of the model by [29].In the latter study, the probability of adoption for an agent i is given by where Here, U i,j is the utility agent i has if it adopts innovation j and U i,M IN specifies its minimum utility requirement.The individual preference y i and the local social influence x i on the agent i are both threshold functions, whereas β j represents how strong the social influence effect is in the market of the product j.In the definition of the social influence part, p i is the individual preference of agent i and q j is the quality of innovation j.In the definition of the individual part, h i is the threshold value for the fraction of adopters in i's personal network, namely the value that must be overcome in order to activate adoption for agent i.A i is the fraction of adopters in the L-th order set of alters of agent i -the alters are the agents included in i's personal network.Both L = 1 and L = 2 were examined in [29].In a later work, [30], the local social influence was re-defined as where a i is the percentage of adopters in i's personal network.
In the model by Bohlmann et al. [31], a threshold defines the minimum proportion of adopters among all those connected to individuals before they can adopt.The simulation is carried out with 1600 agents, of which 50 are selected randomly as innovators who have adopted at the earliest stage of the innovation.This external influence is fixed consistently among all topologies of the network.The agent examines the status of the immediate neighborhood; if the percentage of the adopters exceeds the threshold, the agent adopts with probability 0.5.Four topologies are selected: cellular automata, random network, small world network (random and small world use Poisson distribution, their average number of links per vertex are the same), power-law network (BA network).Five levels of the adoption threshold are allowed: 0,01, 0.05, 0.10, 0.15, 0.20.The peak time is compared for the different topologies and a threshold of 0.05.All simulations show a diffusion cascade for the lower values of the threshold, the percentage diminishes from 100% to less than 100% when the threshold reaches the values of 0.15 and 0.20.The adoption threshold negatively affects the number of new adopters at the point of peak adoption.The effects are less pronounced for the random network under diffusion cascade.The network topology has a more pronounced effect on diffusion processes for higher adoption thresholds.At a high threshold level of 0.20, the random network fails to diffuse at all, whereas the other networks have pronounced differences in their peak adoption times.A model in which the agents belong to one of two market segments is proposed for a first analysis of the peak of the adoption and is foreseen as a future application for agent-based simulations of an heterogeneous market configuration.
In the work of Delre et al. [32], the graph is fully connected, the percentage of initial adopters is fixed and they are randomly distributed.In contrast to percolation models without social influence, in this model it is possible that an agent first does not adopt when being informed about the product, but later, when several neighbors have adopted, he or she may decide to adopt as well because of the increased social utility of the product.If agent i is informed about product g and he or she decides to adopt it, he or she is considered an adopter until the end of the simulation.For the purpose of choosing a suitable network configuration a more realistic version of the scale-free network (Amaral et al., [33]) is adopted.Here, when a new node is attached to the network, the probability of all the other nodes of being selected for the attachment is still proportional to the number of nodes they already have, but it decays exponentially due to a fixed probability h to become inactive at any moment of the process.The scale-free network of Amaral et al. also yields a power law distribution of links for low connected links, but the number of links decays faster when the probability h increases.In other words, the scale-free network model is generalized as follows: Vertices are classified into one of two groups, the active and the inactive.All vertices are created active but in time they can become inactive, namely they cannot receive any more links.
The constraints that are responsible for the transition of the vertices from active to inactive lead to cutoffs on the power law decay of the tail of connectivity distribution and when they are strong enough no power law region is visible.
It is important to mention that transitions between nodes' different states have been modeled in SIR epidemic diffusion studies by means of Markov processes, which actually allow to go beyond the mean field model -see for example the GEMF model in [34] in which the agents who have adopted reconsider their preference at every iteration step, namely they receive information from neighbors, pass information to neighbors and finally decide to adopt if the preference for the new technology is greater than a fixed adoption threshold.In order to augment the model reality and in sight of practical applications with empirical data, they introduce the disappointment extension, which includes the possibility that the innovation disappoints the adopter.When this case occurs, the model provides a possible third action for the ordinary agent, to reduce its preference towards the innovation by a variable amount (between 25 and 75%).In this version of the model, the disappointment is modeled as a random event which affects a variable fraction of the population (between 0 and 25%).The results of the ABM simulations indicate that the individual properties of the IPs are not primarily responsible for the diffusion process.Instead, the density and clusterization of the network play a significant role.
The model proposed in [18] for agent-based simulation employs a network (first random, then small-world or BA) with N agents and L links where the sign of existing links are randomly switched from positive to negative, with a probability p n .This random distribution of negative links in the network is in contrast with balance theory, which assumes that some triangles in signed networks are likely to be found.
It is then assumed that an agent i adopts the innovation at each timestep according to a threshold condition, namely if the sum (θ − • f F OE + θ + ) is strictly positive.Here θ − represents the number of first neighbors who have already adopted and are connected to the agent through a negative link, and similarly for θ + .The coefficient f F OE describes the strength of the negative influence and typically varies between -3 and 0; the value -1 represents the case in which a negative link has the same strength as a positive one.When f F OE is a simple fraction, an interesting step-wise foe effect is observed in the final adoption rate; for example, if f F OE = −0.5, then it takes exactly 2 negative links to counter the effect of a positive link, ans therefore for f F OE slightly larger than that value the adoption rate has a positive jump.
Simulations are performed with a custom-made code (not available), varying mainly the parameters p n , f F OE and the kind of network.The starting scenario is a random network with 300 nodes, 900 links and a population of 3% initial adopters randomly chosen.The principal output of the simulations is the final percentage of adopters.While in the traditional Bass model the entire population eventually adopts the innovation, here the presence of a threshold has the consequence that a certain number of individuals never adopt, especially if their neighbors are connected with negative links.These "resistant" nodes also become an obstacle for the adoption of their contacts with positive links, because they make it harder to reach the threshold.The whole process depends strongly on the parameters p n and f F OE .In fact, the curves displaying the final adoption rate as a function of p n ("share negative ties") always have a decreasing behavior, like an inverted S-curve passing from 100% final adoptions when p n = 0 to approx.0% when p n = 1.
The reference curve with f F OE = 0 is markedly higher than the curve with, e.g., f F OE = −1: in the middle of the graph, with p n = 0.5, the observed difference is about 40% in the final adoption rate.For comparison, the differences in the adoption rate due to the effect of the network for equal p n and f F OE are at most a few percent.They are more significant at large p n , as relative value, when the final adoption rate is small.In addition to random networks, BA and small-world networks are employed.Their exact features are not specified in the paper.It is recalled that, as general criteria, a high clustering level of the network facilitates diffusion in the case of complex contagion, while a small average path length and a fat tail in the degree distribution are beneficial for simple contagion processes [38], [6], [29], [39], [40][...].In the presence of many negative links one expects for BA networks several adoption blockades in the network periphery, where a single resistant node can block many others, due to the low clustering.On the other hand, in small-world networks the regions with high clustering are more frequently blocked.In order to confirm these hypotheses, Mueller and Ramkumar produce graphs which relate the nodes' degrees to their probability of being a final non-adopter.
As anticipated in the Introduction, in this work we reproduce and extend the model of [18] by applying it to a wide set of networks generated with networkX using the configuration model and Newman rewiring.These networks are imported into NetLogo, and then NetLogo performs the agent-based simulations using the threshold transition rule of [18].In order to assign negative signs to some links with a pre-defined probability p n , we use the following trick.NetLogo allows to assign to each link a random weight with uniform distribution in a user-defined interval.It is easy to check that if the interval is equal to (−α, 1), where α = p n /(1−p n ), then the total probability to obtain a negative weight is actually p n .Since in the transition rule only the sign of the link matters, and not its weight, this implementation is equivalent to that of [18], further allowing to simulate, if needed, a more general situation in which the weights of the links play a role.In other words, one could simulate a model in which links can influence diffusion positively or negatively with a continuous distribution of strengths.
A. Parallel runs of NetLogo simulations The already mentioned tool named PyNetLogo for connecting NetLogo with a Python environment can also be used in order to run a set of simulations and collect the desired statistics.This feature is generally described in https://pynetlogo.readthedocs.io/en/latest/; in that context the ipyparallel Python package is proposed, for the purpose of running on 4 clusters the subsequent simulations.The document also describes the use of pandas data-frames for further analysis.
In the current problem it was found that actually the package concurrent futures better satisfies our needs of fast and secure parallelization of the tasks, with the number of In our work we have performed an analysis of the emerging features of dynamics of preference diffusion about technology, based on ABM simulations.We recall that both Markov Chain Approaches (MCA) and Agent Based Models (ABM) have an empirical usage and the most general subject where both lines ground their common root is structure (or pattern) generation.While in the context of MCA, patterns emerge from time correlations or memory effects in the lifetime of a system, in the context of ABM the emerging structures are mostly related to cross-correlations between the agents.We have focused on the latest approach, providing a first statistical analysis of the main emerging quantitative characteristic features, namely the diffusion maximum and the peak time for diffusion.We believe that also opinion models with other interaction mechanisms could benefit from a descriptive representation given through our scheme, constituted by an input network provided by Python rewiring and NetLogo simulations for the diffusion on these imported graphs.
ported and the command netlogo = pynetlogo.NetLogoLink(gui=False) uses the script core.py in PyNetLogo to create a link with NetLogo.Underneath, the NetLogo JVM is accessed through JPype.Once the link with the Java Machine is established, the command netlogo.loadmodel allows to open the file with the NetLogo code.The netlogo.command line can be used to start the setup and create-network procedures.One example was

max workers of PoolExecutor set to 4 .
This allows to exploit the 4 processors that we have currently available.It takes a few tens of seconds to run 100 simulations, then the analysis must be performed separately by means of data-frame statistics and writing to files for plotting with Gnuplot.For our purposes, extracting values for the maximum adoption rate and calculating the mean and standard deviation of each data-frame maximum are the desired statistical output.In this way two curves have been reconstructed for the study of the Mueller-Ramkumar model, using a random network with 3% initial seed for diffusion and setting two values of the parameter f F OE , namely −1 and −2.The two datasets show the behaviour of the maximum adoption rate as a function of the percentage of negative links -see Fig. 5. B. Results with Mueller-Ramkumar threshold model on assortative and uncorrelated networks The set of 100 runs of Netlogo achieved by means of parallel computing with PyNetLogo and the concurrent future Python package was repeated in order to obtain more statistics about the effect of Mueller threshold on the diffusion on an assortative network generated by means of the configuration model function and Newman rewiring with BM1.The random negative links are added with 50% probability in NetLogo after the graphml format of the network is loaded and the results are compared with the ones obtained by means of an analogous procedure but starting from an uncorrelated network.The output for different maximum degrees from a start configuration of 500 nodes and a scale law with γ = 2.5 are presented in Tab.II.It is visible how the diffusion is higher in the uncorrelated case; the values are demonstrated to be stable by the size of the standard deviation, which is compatible with a detailed analysis.V. CONCLUSIONS In this article a new framework for diffusion studies on networks was proposed, based on numerical codes written in Python-networkX and NetLogo.Although these free software packages are well-known and widely employed, their combined use is not simple (networkX is for network generation and analysis, NetLogo for agent-based simulations).A connector tool called PyNetLogo is available and partially documented; it also allows to run parallel simulations via the ipyparallel Python package.There are no previous examples in the literature, however, of the application of these methods to established diffusion models which have been defined and analyzed in the past with systems of differential equations.Besides the specific models considered in this work (Bass model and Mueller-Ramkumar threshold model), several other models can potentially benefit from agent-based simulations on networks.Some of them have been briefly reviewed in Sect.III B.
FIG. 4: Left: cloud of knn (k) functions for a cycle of 20 Newman rewirings with assortative target, starting from a scale-free configuration-model network with γ = 2.5.Right: average of the clustering C(k) as a function of degree over the same ensemble.Note the high level of maximum clustering in the assortative core of the network and the strong correlation between the curves knn (k) and C(k).Networks with 15000 nodes.Approx.130000 rewirings per each cycle.

TABLE I :
Examples of peak times and maximum values for the derivative of the Bass diffusion curve ("adoption rate"), observed in assortative networks with correlations of the BM1 type

TABLE II :
Examples of diffusion values with the Mueller threshold as it is observed in assortative networks with correlations of the BM1 type, γ