Learn R Programming

RNetLogo (version 0.9.2)

NLGetGraph: Captures a network.

Description

NLGetGraph returns a graph object.

Usage

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

Arguments

link.agentset
(optional) A string defining the set of links/network. Default is "links", which are all links.
nl.obj
(optional) A variable holding a reference to a NetLogo instance created with NLStart.

Value

  • Return a graph object of package igraph.

Details

Save 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 4.1.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