View source: R/func__networkAnalyser__extractSubgraphs.R
extractSubgraphs | R Documentation |
This is a generator function used for creating objects of subgraphs. Particularly in this package, a subgraph refers to a connected graph component in a linkage network.
extractSubgraphs(V, E, clusters)
V |
A data frame where the first column contains vertex names and the other columns (optional) are vertex attributes. |
E |
A data frame consisting of all edges of an overall graph. The first and second columns are considered as "from" and "to" vertices of directed edges. Other columns are treated as weights of edges. |
clusters |
A data frame of three columns for cluster IDs (the first column), "from" vertices (the second column) and "to" vertices (the third column). Recommend to name columns of clusters by c("cluster", "from", "to") for convenience of understanding, although column names are not used in this function. Notice for overlapping clusters, some edges may belong to multiple clusters. Cluster IDs will be treated as characters in this function. |
An object of the class "Graph", which has two slots: V: A data frame for vertices and vertex attributes. E: A data frame for edges and edge attributes. Method getV(object, cluster.id, sorted = TRUE), which extracts vertex names of the cluster 'cluster.id' from a Graph object. The names are sorted in an ascending order alphabetically if sorted = TRUE.
vertices in V are not necessarily the same as those in E. The idea to set a slot V is to keep vertex attributes vertices as well as to deal with singleton.
Yu Wan (wanyuac@126.com)
g <- extractSubgraphs(V = nodes, E = edges, clusters = c)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.