Skip to content

Commit 346690f

Browse files
authored
highlight more prominently that GraphSpace != social network (#1156)
1 parent dc38b5a commit 346690f

File tree

4 files changed

+43
-30
lines changed

4 files changed

+43
-30
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Agents"
22
uuid = "46ada45e-f475-11e8-01d0-f70cc89e6671"
33
authors = ["George Datseris", "Tim DuBois", "Aayush Sabharwal", "Ali Vahdati", "Adriano Meligrana"]
4-
version = "6.2.9"
4+
version = "6.2.10"
55

66
[deps]
77
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"

examples/schoolyard.jl

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
# # Social networks with Graphs.jl
1+
# # [Social networks with Graphs.jl](@id social_networks)
22

33
# ```@raw html
44
# <video width="auto" controls autoplay loop>
55
# <source src="../schoolyard.mp4" type="video/mp4">
66
# </video>
77
# ```
88

9-
# Many ABM frameworks provide graph infrastructure for analysing network properties of agents.
10-
# Agents.jl is no different in that aspect, we have [`GraphSpace`](@ref) for when spatial structure
11-
# is not important, but connections are.
9+
# Many ABM frameworks provide graph infrastructure for implementing network-based interactions
10+
# properties of agents. Agents.jl does not provide any graph infrastructure for network-based
11+
# interactions because it doesn't have to!
12+
# Since Agents.jl is implemented in Julia, it can integrate directly
13+
# with Julia's premier package for graphs, Graphs.jl.
1214

13-
# What if you wish to model something a little more complex? Perhaps a school yard full of students
14-
# running around (in space), interacting via some social network. This is precisely the scenario that
15-
# the [MASON](https://cs.gmu.edu/~eclab/projects/mason/) ABM framework uses as an introductory example
16-
# in their [documentation](https://cs.gmu.edu/~eclab/projects/mason/manual.pdf).
15+
# _Note as mentioned in the documentation of [`GraphSpace`](@ref) that network-based
16+
# interactions should not be modeled as a space, even though other ABM frameworks
17+
# implement it as such as an only option!_
1718

18-
# Rather than implementing an Agents.jl⸺specific graph structure, we can interface with
19-
# [Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl): a high class library for managing
20-
# and implementing graphs, which can be re-used to establish social networks within existing spaces.
19+
# In this example we will model the situation where there is both a network structure
20+
# in agent interactions, but also a completely independent spatial structure in the model.
21+
# We will model a school yard full of students
22+
# running around (in space) _and_ interacting via some social network.
2123

2224
# To begin, we load in some dependencies
2325

@@ -47,21 +49,22 @@ const Student = ContinuousAgent{2,Float64}
4749
# ## Initialising the model
4850

4951
function schoolyard(;
50-
numStudents = 50,
51-
teacher_attractor = 0.15,
52-
noise = 0.1,
53-
max_force = 1.7,
54-
spacing = 4.0,
55-
seed = 6998,
56-
velocity = (0, 0),
57-
)
52+
numStudents = 50,
53+
teacher_attractor = 0.15,
54+
noise = 0.1,
55+
max_force = 1.7,
56+
spacing = 4.0,
57+
seed = 6998,
58+
velocity = (0, 0),
59+
)
5860
model = StandardABM(
5961
Student,
6062
ContinuousSpace((100, 100); spacing=spacing, periodic=false);
6163
agent_step!,
6264
properties = Dict(
6365
:teacher_attractor => teacher_attractor,
6466
:noise => noise,
67+
## This is the graph
6568
:buddies => SimpleWeightedDiGraph(numStudents),
6669
:max_force => max_force,
6770
),
@@ -81,9 +84,10 @@ function schoolyard(;
8184
model
8285
end
8386

84-
# Our model contains the `buddies` property, which is our Graphs.jl directed, weighted graph.
85-
# As we can see in the loop, we choose one `friend` and one `foe` at random for each `student` and
86-
# assign their relationship as a weighted edge on the graph.
87+
# Our model contains the `buddies` property, which is our Graphs.jl directed and weighted graph.
88+
# Here we chose one `friend` and one `foe` at random for each student` and assign their
89+
# relationship as a weighted edge on the graph.
90+
# By construction, the agent ID and graph node ID coincide.
8791

8892
# ## Movement dynamics
8993

@@ -132,7 +136,7 @@ end
132136
# that force should be in a positive or negative direction (*friend* or *foe*?).
133137

134138
# The `findnz` function is something that may require some further explanation.
135-
# Graphs uses sparse vectors internally to efficiently represent data.
139+
# Graphs.jl uses sparse vectors internally to efficiently represent data.
136140
# When we find the `network` of our `student`, we want to convert the result to
137141
# a dense representation by **find**ing the **n**on-**z**ero (`findnz`) elements.
138142

examples/sir.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
# # SIR model for the spread of COVID-19
1+
# # [SIR model for the spread of COVID-19](@id sir_graphspace)
22
# ```@raw html
33
# <video width="auto" controls autoplay loop>
44
# <source src="../covid_evolution.mp4" type="video/mp4">
55
# </video>
66
# ```
77
#
8-
# This example illustrates how to use `GraphSpace` and how to model agents on an graph
8+
# This example illustrates how to use [`GraphSpace`](@ref) and how to model agents moving on a graph
99
# (network) where the transition probabilities between each node (position) is not constant.
10+
1011
# ## SIR model
1112

1213
# A SIR model tracks the ratio of Susceptible, Infected, and Recovered individuals within a population.

src/spaces/graph.jl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,20 @@ The underlying graph can be altered using [`add_vertex!`](@ref) and [`rem_vertex
2424
2525
An example using `GraphSpace` is [SIR model for the spread of COVID-19](@ref).
2626
27-
If you want to model social networks, where each agent is equivalent with a node of
28-
a graph, you're better of using `nothing` as the model space, and using
29-
a graph from Graphs.jl directly in the model parameters, as shown in the
30-
[Social networks with Graphs.jl](@ref) integration example.
27+
!!! note "Not for social networks!"
28+
`GraphSpace` is not intended for "social-network-like" agent based
29+
modelling, where each agent is equivalent with a node of a network/graph and
30+
the graph represents connections between agents. Rather, `GraphSpace` is
31+
suitable for when the coordinates of spatial locations are not as important as the
32+
connections between them. `GraphSpace` is suited for e.g., modelling cities
33+
where each can host many agents.
34+
35+
If you want to make a "social-network" like simulation, see [the integration with
36+
Graphs.jl example](@ref social_networks). Typically you won't need a space structure at all!
37+
3138
3239
## Distance specification
40+
3341
In functions like [`nearby_ids`](@ref), distance for `GraphSpace` means
3442
the degree of neighbors in the graph (thus distance is always an integer).
3543
For example, for `r=2` includes first and second degree neighbors.

0 commit comments

Comments
 (0)