Plot the subgraph around a Specific Node in a Graph Object
Description
Plots a subgraph for a specified starting node and a given graph. The subgraph consists of those nodes that can be reached from the starting node by passing no more than a specified number of edges.
Usage
1 
Arguments
graphObj 
An R object of class 
y 
(integer) position of the starting node in the adjacency matrix. 
dist 
Distance of nodes included in subgraph from starting node 
amat 
Precomputed adjacency matrix of type amat.cpdag (optional) 
directed 

main 
Title to be used, with a sensible default; see 
Details
Commencing at the starting point y
the function looks for the
neighbouring nodes. Beginning with direct parents and children it
will continue hierarchically through the distances to y
. If
directed
is true (as per default), the orientation of the edges
is taken from the initial graph.
The package Rgraphviz must be installed, and is used for the plotting.
Value
the desired subgraph is plotted and returned via
invisible
.
Author(s)
Daniel Stekhoven (hoven@stat.math.ethz.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  if (require(Rgraphviz)) {
## generate a random DAG:
p < 10
set.seed(45)
myDAG < randomDAG(p, prob = 0.3)
## plot whole the DAG
plot(myDAG, main = "randomDAG(10, prob = 0.3)")
op < par(mfrow = c(3,2))
## plot the neighbours of node number 8 up to distance 1
plotSG(myDAG, 8, 1, directed = TRUE)
plotSG(myDAG, 8, 1, directed = FALSE)
## plot the neighbours of node number 8 up to distance 2
plotSG(myDAG, 8, 2, directed = TRUE)
plotSG(myDAG, 8, 2, directed = FALSE)
## plot the neighbours of node number 8 up to distance 3
plotSG(myDAG, 8, 3, directed = TRUE)
plotSG(myDAG, 8, 3, directed = FALSE)
## Note that the layout of the subgraph might be different than in the
## original graph, but the graph structure is identical
par(op)
}
