Learn R Programming

dynamicGraph (version 0.1.6.6)

returnFactorVerticesAndEdges: The factor vertex list

Description

Create factor vertex and factor edge lists.

Usage

returnFactorVerticesAndEdges(Vertices, factors = NULL, types = "Generator", 
                             factorVertexColor = "default", 
                             factorEdgeColor = "DarkOliveGreen",                             factorClasses = validFactorClasses())

Arguments

Vertices
The list of Vertices, each containing the class VertexProto.
factors
The list of vectors identifying the factors. Each item in the list is a vector of the indices of vertices of a factor.
types
The types of the factors. Either a single type or a list of the same length as factors. Each item of types should match the labels of factorC
factorVertexColor
The factorVertexColor of the factor vertices.
factorEdgeColor
The factorEdgeColor of the factor edges.
factorClasses
The valid factorClasses.

Value

  • A list with components
  • FactorVerticesThe list of factor vertices, each of class containing FactorVertexProto.
  • FactorEdgesThe list of factor edge, each of class containing FactorEdgeProto.
  • PairEdgesA matrix with the edges of the graph, two columns with the indices of the vertices of two ends of the edges.

Details

The argument factors is a list of vectors identifying the factors, or generators. Each item in the list is a vector with of the indices (or names) of the vertices of a factor, or variables of a generator. A factor vertex is made for each factor, and factor edges from this factor vertex to the vertices of the factor or added to the factor edge list. Also the edges between pairs of the vertices in the factors are returned.

Examples

Run this code
setClass("defaultModelObjectProto", representation(name = "character"))

if (!isGeneric("modifyModel")) {
  if (is.function("modifyModel"))
    fun <- modifyModel
  else
    fun <- function(object, action, name, name.1, name.2, ...)
                    standardGeneric("modifyModel")
  setGeneric("modifyModel", fun)
}

setMethod("modifyModel", signature(object = "defaultModelObjectProto"),
          function(object, action, name, name.1, name.2, ...)
 {
    args <- list(...)
    FactorVertices <- NULL
    FactorEdges <- NULL
    f <- function(type) if(is.null(type)) "" else paste("(", type, ")")
    if (action == "dropEdge") {
       message(paste("Should return an object with the edge from",
                     name.1, f(args$from.type), "to", name.2, f(args$to.type),
                     "deleted from the argument object"))
    } else if (action == "addEdge") {
       message(paste("Should return an object with the edge from",
                     name.1, f(args$from.type), "to", name.2, f(args$to.type),
                     "added to the argument object"))
    } else if (action == "dropVertex")  {
       message(paste("Should return an object with the vertex", 
                     name, f(args$type),
                     "deleted from the argument object"))
       if (!is.null(args$Arguments) && (args$index > 0)
                       && !is.null(args$Arguments$factorVertexList)
                       && !is.null(args$Arguments$vertexList)) {
         x <- (args$Arguments$factorVertexList)
         factors <- lapply(x, function(i) i@vertex.indices)
         types <- lapply(x, function(i) class(i))
         factors <- lapply(factors, function(x) x[x != args$index])
         if (!(is.null(factors))) {
           result <- returnFactorVerticesAndEdges(
                                   args$Arguments$vertexList, factors, types, 
                                   factorClasses = validFactorClasses())
           FactorVertices <- result$FactorVertices
           FactorEdges <- result$FactorEdges
         }
       }
    } else if (action == "addVertex") {
       message(paste("Should return an object with the vertex", 
                     name, f(args$type), args$index, 
                     "added to the argument object"))
    }
    return(list(object = object,
                FactorVertices = FactorVertices,
                FactorEdges = FactorEdges))
 })

Run the code above in your browser using DataLab