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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
|
\name{MultiGraph-class}
\Rdversion{1.1}
\docType{class}
\alias{MultiGraph-class}
\alias{nodes,MultiGraph-method}
\alias{numEdges,MultiGraph-method}
\alias{numEdges,MGEdgeSet-method}
\alias{numNodes,MultiGraph-method}
\alias{show,MultiGraph-method}
\alias{MultiGraph}
\alias{eweights}
\alias{edgeSetIntersect0}
\alias{edgeSetUnion0}
\alias{subsetEdgeSets}
\alias{extractFromTo}
\alias{extractFromTo,MultiGraph-method}
\alias{extractGraphAM}
\alias{extractGraphBAM}
\alias{isDirected,MultiGraph-method}
\alias{ugraph,MultiGraph-method}
% these are not supposed to be publicly available
% but aliased here to quiet R CMD check
\alias{isDirected,DiEdgeSet-method}
\alias{isDirected,UEdgeSet-method}
\alias{ugraph,DiEdgeSet-method}
\alias{ugraph,UEdgeSet-method}
\alias{graphIntersect,MultiGraph,MultiGraph-method}
\alias{graphUnion,MultiGraph,MultiGraph-method}
\alias{nodeData,MultiGraph,character,character-method}
\alias{nodeData,MultiGraph,character,missing-method}
\alias{nodeData,MultiGraph,missing,character-method}
\alias{nodeData,MultiGraph,missing,missing-method}
\alias{nodeData<-,MultiGraph,character,character-method}
\alias{nodeData<-,MultiGraph,missing,character-method}
\alias{mgEdgeDataDefaults}
\alias{mgEdgeDataDefaults<-}
\alias{mgEdgeDataDefaults,MultiGraph,character,character-method}
\alias{mgEdgeDataDefaults,MultiGraph,character,missing-method}
\alias{mgEdgeDataDefaults<-,MultiGraph,character,character,ANY-method}
\alias{mgEdgeDataDefaults<-,MultiGraph,character,missing,list-method}
\alias{nodeDataDefaults,MultiGraph,character-method}
\alias{nodeDataDefaults,MultiGraph,missing-method}
\alias{nodeDataDefaults<-,MultiGraph,character,ANY-method}
\alias{nodeDataDefaults<-,MultiGraph,missing,list-method}
\alias{mgEdgeData}
\alias{mgEdgeData<-}
\alias{mgEdgeData,MultiGraph,character,character,character,character-method}
\alias{mgEdgeData,MultiGraph,character,character,missing,character-method}
\alias{mgEdgeData,MultiGraph,character,missing,character,character-method}
\alias{mgEdgeData,MultiGraph,character,missing,missing,character-method}
\alias{mgEdgeData<-,MultiGraph,character,character,character,character-method}
\alias{mgEdgeData<-,MultiGraph,character,character,missing,character-method}
\alias{mgEdgeData<-,MultiGraph,character,missing,character,character-method}
\alias{mgEdgeData<-,MultiGraph,character,missing,missing,character-method}
\alias{edges,MultiGraph,character-method}
\alias{edgeNames,MultiGraph-method}
\alias{edges,MultiGraph,missing-method}
\alias{edgeSets}
\alias{edgeSets,MultiGraph-method}
\title{EXPERIMENTAL class "MultiGraph"}
\description{
The MultiGraph class represents a single node set and a set of edge
sets. Each edge set is either directed or undirected. We can think
of an edge in a MultiGraph as a 4-tuple (from-node, to-node,
edge-type, weight), where the edge-type field in the tuple identifies
the edge set, the weight is a numeric value, and the order of the
nodes only matters in the case of a directed edge set. Unlike some of
the graph representations, self-loops are allowed (from-node ==
to-node).
There is support for arbitrary edge attributes which is primarily
useful for rendering plots of MultiGraphs. These attributes are
stored separately from the edge weights to facilitate efficient edge
weight computation.
}
\usage{
MultiGraph(edgeSets, nodes = NULL, directed = TRUE, ignore_dup_edges = FALSE)
eweights(object, names.sep = NULL)
edgeSetIntersect0(g, edgeFun = NULL)
edgeSetIntersect0(g, edgeFun = NULL)
extractGraphAM(g, edgeSets)
extractGraphBAM(g, edgeSets)
}
\arguments{
\item{edgeSets}{
A named list of \code{data.frame} objects each representing an edge
set of the multigraph. Each \code{data.frame} must have three
columns: "from", "to", and "weight". Columns "from" and "to" can be
either factors or character vectors. The "weight" column must be
numeric.
}
\item{nodes}{
A character vector of node labels. Nodes with zero degree can be
included in a graph by specifying the node labels in \code{nodes}.
The node set of the resulting multigraph is the union of the node
labels found in \code{edgeSets} and \code{nodes}.
}
\item{directed}{
A logical vector indicating whether the edge sets specified in
\code{edgeSets} represent directed edges. If this argument has
length one, the value applies to all edge sets in \code{edgeSets}.
Otherwise, this argument must have the same length as
\code{edgeSets}, values are aligned by position.
}
\item{object}{
A \code{MultiGraph} instance
}
\item{g}{
A \code{MultiGraph} instance
}
\item{names.sep}{
The string to use as a separator between from and to node labels.
If \code{NULL} no names will be attached to the returned vector.
}
\item{ignore_dup_edges}{
If \code{FALSE} (default), specifying duplicate edges in the input
is an error. When set to \code{TRUE} duplicate edges are ignored.
Edge weight values are ignored when determining duplicates. This is
most useful for graph import and conversion.
}
\item{edgeFun}{
A user specified named list of functions to resolve edge attributes in a union
or intersection operation
}
}
\section{Constructors}{
\code{MultiGraph}
}
\section{Methods}{
\describe{
\item{nodes}{Return the nodes of the multigraph.}
\item{numEdges}{Return an integer vector named by edge set
containing edge counts for each edge set.}
\item{numNodes}{Return the number of nodes in the multigraph.}
\item{eweights}{Return a list named by edge set; each element is a
numeric vector of edge weights for the corresponding edge set.}
\item{isDirected}{Return a logical vector named by the edge sets in
\code{object} with a \code{TRUE} indicating a directed edge set
and \code{FALSE} for undirected.}
\item{edges}{Returns a list named by edge set; for the edges in the
MultiGraph}
\item{edgeNames}{Returns a list named by the edge set; for the names
of the edges in the MultiGraph}
\item{extractFromTo}{Return a list named by the edge sets; each
element is a data frame with column names from, to and weight
corresponding to the connected nodes in the edge set.}
\item{subsetEdgeSets}{Return a new \code{MultiGraph} object
representing the subset of edge sets from the original
\code{MultiGraph}.}
\item{extractGraphAM}{Return a named \code{list} of \code{graphAM}
objects corresponding to the edge sets from the original
\code{MultiGraph}.}
\item{extractGraphBAM}{Return a named \code{list} of \code{graphBAM}
objects corresponding to the edge sets from the original
\code{MultiGraph}.}
\item{ugraph}{Return a new \code{MultiGraph} object in which all
edge sets have been converted to undirected edge sets. This
operation sets all edge weights to one and drops other edge
attributes.}
\item{edgeSetIntersect0}{Return a new \code{MultiGraph} object
representing the intersection of edges across all edge sets within
\code{g}. The return value will have a single edge set if the edge
sets in \code{g} are disjoint. Otherwise, there will be a single
edge set containing the shared edges. The node set is preserved.
Edge weights and edge attributes are transferred over to the output if they
have the same value, else user has the option of providing a function
to resolve the conflict.}
\item{edgeSetUnion0}{Return a new \code{MultiGraph} object
representing the union of edges across all edge sets within
\code{g}. The node set is preserved. Edge weights and edge attributes are
transferred over to the output if they have the same value, else user has
the option of providing a function to resolve the conflict.}
\item{\code{graphIntersect(x, y, nodeFun, edgeFun)}}{
When given two \code{MultiGraph} objects, \code{graphIntersect}
returns a new \code{MultiGraph} containing the nodes and edges in
common between the two graphs. The intersection is computed by
first finding the intersection of the node sets, obtaining the
induced subgraphs, and finding the intersection of the resulting
edge sets. The corresponding named edgeSets in \code{x} and \code{y} should
both be either directed or undirected.Node/Edge attributes that are equal
are carried over to the result. Non equal edge/node attributes will result
in the corresponding attribute being set to NA. The user has the option
of providing a named list(names of edgeSets) of list (names of edge attributes)
of edge functions correspoding to the names of the edge attributes for
resolving conflicting edge attributes (\code{edgeFun}). For resolving any
of the conflicting node attributes, the user has the option of providing a
named \code{list} of functions corresponding to the node attribute names (\code{nodeFun}).
}
\item{\code{graphUnion(x, y, nodeFun, edgeFun)}}{
When given two \code{MultiGraph} objects, \code{graphUnion}
returns a new \code{MultiGraph} containing the union of nodes and
edges between the two graphs. The corresponding pairs of named edgeSets
in \code{x} and \code{y} should both be either directed or undirected.
Non equal edge/node attributes will result in the corresponding attribute
being set to NA. The user has the option of providing a named list(names of
edgeSets) of list (names of edge attributes) of edge functions correspoding
to the names of the edge attributes for resolving conflicting edge
attributes (\code{edgeFun}). For resolving any of the conflicting node attributes, the user
has the option of providing a named \code{list} of functions corresponding
to the node attribute names (\code{nodeFun}).
}
\item{ \code{edgeSets(object, ...)}}{
Returns the names of the edgeSets in the MultiGraph
\code{object} as a character vector.
}
\item{show}{Prints a short summary of a MultiGraph object}
}
}
\author{S. Falcon, Gopalakrishnan N}
\examples{
ft1 <- data.frame(from=c("a", "a", "a", "b", "b"),
to=c("b", "c", "d", "a", "d"),
weight=c(1, 3.1, 5.4, 1, 2.2))
ft2 <- data.frame(from=c("a", "a", "a", "x", "x", "c"),
to=c("b", "c", "x", "y", "c", "a"),
weight=c(3.4, 2.6, 1, 1, 1, 7.9))
esets <- list(es1=ft1, es2=ft2)
g <- MultiGraph(esets)
nodes(g)
numEdges(g)
eweights(g)
eweights(g, names.sep = "=>")
isDirected(g)
edges(g, edgeSet ="es1")
edges(g, "a", "es1")
edgeNames(g, "es2")
edgeSets(g)
ug <- ugraph(g)
isDirected(ug)
numEdges(ug)
edgeSetIntersect0(g)
subsetEdgeSets(g, "es1")
extractFromTo(g)
extractGraphAM(g)
extractGraphAM(g, "es1")
extractGraphBAM(g, "es1")
graphIntersect(g, g)
graphUnion(g,g)
mgEdgeDataDefaults(g, "es1", attr = "color" ) <- "white"
mgEdgeData(g, "es1", from = "a", to = c("b", "c"), attr = "color") <- "red"
mgEdgeData(g, "es1", from = "a", to = c("b", "c"), attr = "color")
nodeDataDefaults(g, attr ="shape") <- "circle"
nodeData(g, n = c("a", "b", "c"), attr = "shape") <- "triangle"
nodeData(g, n = c("a", "b", "x", "y"), attr = "shape")
}
\keyword{classes}
|