MultiGraph-class: EXPERIMENTAL class "MultiGraph"

Description Usage Arguments Constructors Methods Author(s) Examples

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

1
2
3
4
5
6
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

edgeSets

A named list of data.frame objects each representing an edge set of the multigraph. Each 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.

nodes

A character vector of node labels. Nodes with zero degree can be included in a graph by specifying the node labels in nodes. The node set of the resulting multigraph is the union of the node labels found in edgeSets and nodes.

directed

A logical vector indicating whether the edge sets specified in edgeSets represent directed edges. If this argument has length one, the value applies to all edge sets in edgeSets. Otherwise, this argument must have the same length as edgeSets, values are aligned by position.

object

A MultiGraph instance

g

A MultiGraph instance

names.sep

The string to use as a separator between from and to node labels. If NULL no names will be attached to the returned vector.

ignore_dup_edges

If FALSE (default), specifying duplicate edges in the input is an error. When set to TRUE duplicate edges are ignored. Edge weight values are ignored when determining duplicates. This is most useful for graph import and conversion.

edgeFun

A user specified named list of functions to resolve edge attributes in a union or intersection operation

Constructors

MultiGraph

Methods

nodes

Return the nodes of the multigraph.

numEdges

Return an integer vector named by edge set containing edge counts for each edge set.

numNodes

Return the number of nodes in the multigraph.

eweights

Return a list named by edge set; each element is a numeric vector of edge weights for the corresponding edge set.

isDirected

Return a logical vector named by the edge sets in object with a TRUE indicating a directed edge set and FALSE for undirected.

edges

Returns a list named by edge set; for the edges in the MultiGraph

edgeNames

Returns a list named by the edge set; for the names of the edges in the MultiGraph

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.

subsetEdgeSets

Return a new MultiGraph object representing the subset of edge sets from the original MultiGraph.

extractGraphAM

Return a named list of graphAM objects corresponding to the edge sets from the original MultiGraph.

extractGraphBAM

Return a named list of graphBAM objects corresponding to the edge sets from the original MultiGraph.

ugraph

Return a new 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.

edgeSetIntersect0

Return a new MultiGraph object representing the intersection of edges across all edge sets within g. The return value will have a single edge set if the edge sets in 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.

edgeSetUnion0

Return a new MultiGraph object representing the union of edges across all edge sets within 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.

graphIntersect(x, y, nodeFun, edgeFun)

When given two MultiGraph objects, graphIntersect returns a new 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 x and 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 (edgeFun). For resolving any of the conflicting node attributes, the user has the option of providing a named list of functions corresponding to the node attribute names (nodeFun).

graphUnion(x, y, nodeFun, edgeFun)

When given two MultiGraph objects, graphUnion returns a new MultiGraph containing the union of nodes and edges between the two graphs. The corresponding pairs of named edgeSets in x and 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 (edgeFun). For resolving any of the conflicting node attributes, the user has the option of providing a named list of functions corresponding to the node attribute names (nodeFun).

edgeSets(object, ...)

Returns the names of the edgeSets in the MultiGraph object as a character vector.

show

Prints a short summary of a MultiGraph object

Author(s)

S. Falcon, Gopalakrishnan N

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
27
28
29
30
31
32
33
34
35
36
37
38
    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") 

pshannon-bioc/graph documentation built on May 26, 2019, 10:32 a.m.