as.igraph.dpp_population: Exports a population as an igraph graph.

Description Usage Arguments Value Author(s) Examples

Description

The resulting graph is directed. Depending to parameters its vertices might be attributed.

Usage

1
2
## S3 method for class 'dpp_population'
as.igraph(pop, with.attributes = FALSE, ...)

Arguments

pop

the population to convert

with.attributes

if TRUE, the attributes of entities are copied as vertex attributes

...

ignored

Value

an igraph graph

Author(s)

Samuel Thiriot <samuel.thiriot@res-ear.ch>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
library(igraph)
# generate a population based on sample case 1
data(dwellings_households)
prepared <- matching.prepare(
                    dwellings_households$sample.A, dwellings_households$sample.B, 
                    dwellings_households$pdi, dwellings_households$pdj, 
                    dwellings_households$pij)
solved <- matching.solve(prepared, 
                    nA=500,nB=400, 
                    nu.A=0, phi.A=0, delta.A=1, 
                    gamma=1, 
                    delta.B=0, phi.B=0, nu.B=0)
sampled <- matching.generate(solved, dwellings_households$sample.A, dwellings_households$sample.B)

# convert the population as a population
g <- as.igraph(sampled$pop, with.attributes=TRUE)

# can export the graph using one of the igraph formats
write.graph(g,file="mygraph.graphml", format="graphml")

# can visualize the population as a graph
#lay <- layout_nicely(g)
#tkplot(g,layout=lay)

# test structural properties
is.connected(g)
average.path.length(g)

# check attributes 
# ... list all the attributes defined for verticies 
vertex_attr_names(g)
# ... view all attributes
vertex_attr(g)

samthiriot/gosp.dpp documentation built on May 18, 2019, 3:44 p.m.