Learn R Programming

RNetLogo (version 0.9.4)

NLGetGraph: Captures a network.

Description

NLGetGraph converts a set of NetLogo Link agents into an igraph graph object (see package igraph for details on graph objects).

Usage

NLGetGraph(link.agentset="links", nl.obj=NULL)

Arguments

link.agentset
(optional) A string defining an agentset of NetLogo Links. Default is "links", which are all links.
nl.obj
(optional) A reference to a NetLogo instance created with NLStart.

Value

  • Returns a graph object of package igraph.

Details

Saves a link network in a graph object of package igraph for network analysis.

See Also

NLGetAgentSet

Examples

Run this code
nl.path <- "C:/Program Files/NetLogo 5.0.3"
NLStart(nl.path)
model.path <- 
"/models/Sample Models/Networks/Preferential Attachment.nlogo"
NLLoadModel(paste(nl.path,model.path,sep=""))
NLCommand("setup")
NLDoCommand(4, "go")
graph1 <- NLGetGraph()
plot(graph1, layout=layout.kamada.kawai, vertex.label=V(graph1)$name,
     vertex.shape="rectangle", vertex.size=20, asp=FALSE)

Run the code above in your browser using DataLab