Description Usage Arguments Details Value Note Author(s) See Also Examples
For our purposes an edge matrix is a matrix with two rows and as many columns as there are edges. The entries in the first row are the index of the node the edge is from, those in the second row indicate the node the edge is to.
If the graph is “undirected” then the duplicates
option
can be used to indicate whether reciprocal edges are wanted. The
default is to leave them out. In this case the notions of from
and to are not relevant.
1 2 3 4 | edgeMatrix(object, duplicates=FALSE)
eWV(g, eM, sep = ifelse(edgemode(g) == "directed", "->",
"--"), useNNames=FALSE)
pathWeights(g, p, eM=NULL)
|
object |
An object that inherits from |
g |
An object that inherits from |
duplicates |
Whether or not duplicate edges should be produced for “undirected” graphs. |
eM |
An edge matrix |
sep |
a character string to concatenate node labels in the edge label |
useNNames |
a logical; if TRUE, node names are used in the edge label; if FALSE, node indices are used |
p |
a vector of node names constituting a path in graph |
Implementations for graphNEL
, clusterGraph
and
distGraph
are available.
edgeMatrix
returns a matrix with two rows, from and to, and as many columns
as there are edges. Entries indicate the index in the node vector that
corresponds to the appropriate end of the edge.
eWV
uses the edge matrix to create an annotated vector of
edge weights.
pathWeights
returns an annotated vector of edge weights
for a specified path in a graph.
A path through an undirected graph may have several representations as a named vector of edges. Thus in the example, when the weights for path b-a-i are requested, the result is the pair of weights for edges a–b and a–i, as these are the edge labels computed for graph g1.
R. Gentleman
1 2 3 4 5 6 7 8 | set.seed(123)
g1 <- randomGraph(letters[1:10], 1:4, p=.3)
edgeMatrix(g1)
g2 <- new("clusterGraph", clusters=list(a=c(1,2,3), b=c(4,5,6)))
em2 <- edgeMatrix(g2)
eWV(g1, edgeMatrix(g1))
eWV(g1, edgeMatrix(g1), useNNames=TRUE)
pathWeights(g1, c("b", "a", "i"))
|
Loading required package: BiocGenerics
Loading required package: parallel
Attaching package: 'BiocGenerics'
The following objects are masked from 'package:parallel':
clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
clusterExport, clusterMap, parApply, parCapply, parLapply,
parLapplyLB, parRapply, parSapply, parSapplyLB
The following objects are masked from 'package:stats':
IQR, mad, sd, var, xtabs
The following objects are masked from 'package:base':
Filter, Find, Map, Position, Reduce, anyDuplicated, append,
as.data.frame, cbind, colMeans, colSums, colnames, do.call,
duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted,
lapply, lengths, mapply, match, mget, order, paste, pmax, pmax.int,
pmin, pmin.int, rank, rbind, rowMeans, rowSums, rownames, sapply,
setdiff, sort, table, tapply, union, unique, unsplit, which,
which.max, which.min
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
from 1 1 1 1 1 1 1 2 2 2 2 2 3 4
to 7 9 2 4 5 6 8 6 10 4 5 8 8 5
[,15] [,16] [,17] [,18] [,19] [,20] [,21]
from 4 4 5 5 6 6 7
to 6 8 6 8 10 8 9
1--7 1--9 1--2 1--4 1--5 1--6 1--8 2--6 2--10 2--4 2--5 2--8 3--8
1 1 1 1 1 1 1 2 1 1 1 1 1
4--5 4--6 4--8 5--6 5--8 6--10 6--8 7--9
1 1 1 1 1 1 1 1
a--g a--i a--b a--d a--e a--f a--h b--f b--j b--d b--e b--h c--h d--e d--f d--h
1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1
e--f e--h f--j f--h g--i
1 1 1 1 1
a--i a--b
1 1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.