Skip to content

Commit

Permalink
Update D3 library and some text changes
Browse files Browse the repository at this point in the history
Update D3 library and some text changes
  • Loading branch information
cauemello committed Nov 17, 2017
1 parent 30caeaf commit 7ac0ecc
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 13 deletions.
11 changes: 6 additions & 5 deletions examples/boltzmann_wealth_model_network/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ This is the same Boltzmann Wealth Model, but with a network grid implementation.

A simple model of agents exchanging wealth. All agents start with the same amount of money. Every step, each agent with one unit of money or more gives one unit of wealth to another random agent. This is the model described in the [Intro Tutorial](http://mesa.readthedocs.io/en/latest/intro-tutorial.html).

In this network implementation, agents must be located on a node, with a limit of one agent per node. In order to give or receive the unit of money, the agent must be directly connected to the other agent (there must be a direct link between the nodes).

As the model runs, the distribution of wealth among agents goes from being perfectly uniform (all agents have the same starting wealth), to highly skewed -- a small number have high wealth, more have none at all.

JavaScript library used in this example to render the network: [sigma.js](http://sigmajs.org/).

## Installation

To install the dependencies use pip and the requirements.txt in this directory. e.g.
Expand All @@ -30,15 +34,12 @@ Then open your browser to [http://127.0.0.1:8521/](http://127.0.0.1:8521/) and p

* ``run.py``: Launches a model visualization server.
* ``model.py``: Contains the agent class, and the overall model class.
* ``NetworkGrid.py``: Contains the grid class with a network topology.
* ``server.py``: Defines classes for visualizing the model in the browser via Mesa's modular server, and instantiates a visualization server.
* ``NetworkVisualization.py``: Contains the NetworkElement class, necessary to the visualization of the network, using the [sigma.js](http://sigmajs.org/) framework.

* ``server.py``: Defines classes for visualizing the model (network layout) in the browser via Mesa's modular server, and instantiates a visualization server.

## Further Reading

The full tutorial describing how the model is built can be found at:
http://mesa.readthedocs.io/en/latest/intro-tutorial.html
http://mesa.readthedocs.io/en/master/tutorials/intro_tutorial.html

This model is drawn from econophysics and presents a statistical mechanics approach to wealth distribution. Some examples of further reading on the topic can be found at:

Expand Down
42 changes: 37 additions & 5 deletions examples/virus_on_network/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,44 @@
# Virus on a Network

TODO
## Summary

This model is based on the netlogo model "Virus on Network".

### Citations
For more information about this model, read the netlogo's webpage: http://ccl.northwestern.edu/netlogo/models/VirusonaNetwork

This model is based on the netlogo model "Virus on Network".
## Installation

To install the dependencies use pip and the requirements.txt in this directory. e.g.

```
$ pip install -r requirements.txt
```

## How to Run

To run the model interactively, run ``run.py`` in this directory. e.g.

```
$ python run.py
```

Then open your browser to [http://127.0.0.1:8521/](http://127.0.0.1:8521/) and press Reset, then Run.

## Files

* ``run.py``: Launches a model visualization server.
* ``model.py``: Contains the agent class, and the overall model class.
* ``server.py``: Defines classes for visualizing the model (network layout) in the browser via Mesa's modular server, and instantiates a visualization server.

## Further Reading

The full tutorial describing how the model is built can be found at:
http://mesa.readthedocs.io/en/master/tutorials/intro_tutorial.html


[Stonedahl, F. and Wilensky, U. (2008). NetLogo Virus on a Network model](http://ccl.northwestern.edu/netlogo/models/VirusonaNetwork).
Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

Stonedahl, F. and Wilensky, U. (2008). NetLogo Virus on a Network model. http://ccl.northwestern.edu/netlogo/models/VirusonaNetwork. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.
[Wilensky, U. (1999). NetLogo](http://ccl.northwestern.edu/netlogo/)
Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.
2 changes: 1 addition & 1 deletion mesa/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def out_of_bounds(self, pos):


class NetworkGrid:
""" Network Grid where each node contains one agente. """
""" Network Grid where each node contains zero or one agent. """

def __init__(self, G):
self.G = G
Expand Down
8 changes: 8 additions & 0 deletions mesa/visualization/modules/NetworkVisualization.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# -*- coding: utf-8 -*-
"""
Network Visualization Module
============
Module for rendering the network, using [sigma.js](http://sigmajs.org/) or [d3.js](https://d3js.org/) frameworks.
"""
from mesa.visualization.ModularVisualization import VisualizationElement


Expand Down
4 changes: 2 additions & 2 deletions mesa/visualization/templates/js/d3.min.js

Large diffs are not rendered by default.

0 comments on commit 7ac0ecc

Please sign in to comment.