Comments (5)
@tomermilo actually the following version does not give any problem (essentially it is what you also mentioned I think) and I was able to run the example provided:
==============================================
def custom_exponential_graph(base_graph=None, scale=100, min_num_edges=0, m=9, n=None):
# Generate a random preferential attachment power law graph as a starting point.
# By the way this graph is constructed, it is expected to have 1 connected component.
# Every node is added along with m=8 edges, so the min degree is m=8.
if(base_graph):
graph = base_graph.copy()
else:
assert(n is not None), "Argument n (number of nodes) must be provided when no base graph is given."
graph = networkx.barabasi_albert_graph(n=n, m=m)
# To get a graph with power-law-esque properties but without the fixed minimum degree,
# We modify the graph by probabilistically dropping some edges from each node.
for node in graph:
neighbors = list(graph[node].keys())
quarantineEdgeNum = int( max(min(numpy.random.exponential(scale=scale, size=1), len(neighbors)), min_num_edges) )
quarantineKeepNeighbors = numpy.random.choice(neighbors, size=quarantineEdgeNum, replace=False)
for neighbor in neighbors:
if(neighbor not in quarantineKeepNeighbors):
graph.remove_edge(node, neighbor)
return graph
from seirsplus.
I did the same and it solved this problem, but then I had a runtime error
RuntimeError: dictionary changed size during iteration
at the line 1177:
for neighbor in neighbors:
Any thoughts?
from seirsplus.
@kpelechrinis can you send your new custom_exponential_graph function?
from seirsplus.
This is how I fixed it as well. Good luck
from seirsplus.
The change to list(dict.keys())
has been made throughout the package to make this keys lookup work in both Python 2 and 3. Thank you for flagging this issue.
from seirsplus.
Related Issues (20)
- Scalability and complexity? HOT 2
- Identify nodes in each state HOT 1
- Most images on main page (https://github.com/ryansmcgee/seirsplus) are broken HOT 2
- Wiki typo about accessing sim results HOT 2
- Update to text of Basic SEIRS Model Description HOT 1
- Random "division by zero" error HOT 1
- KeyError triggered by model.run() HOT 2
- Events might sometimes skip a day HOT 1
- Testing a fixed amount of randomly selected individuals HOT 1
- Variable name errors in models.py HOT 1
- Running seirsplus on top of a graph_tool network. HOT 1
- Color return-to-work model
- Problem in running Extended SEIRS Model
- Problem running Basic_SEIRS_Network_Model_Demo
- iuhih
- joi
- want to see the 2.0 version code, please
- Apply the Version 2.0 code
- bug in models.py
- README.MD code example incorrect - nonexistent keyword "Q" being passed to constructor of SEIRSNetworkModel
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from seirsplus.