Sunday, 14 January 2018

Subgraph in igraph

Cited from the Book "Statistical Analysis of Network With R"

A graph H = (VH,EH) is a subgraph of another graph G = (Vg,Eg) if Vh ⊆ Vg and Eh ⊆ Eg. Often we are interested in an induced subgraph of a graph G, i.e., a subgraph G' = (V' ,E' ), where V' ⊆ V is a prespecified subset of vertices and E' ⊆ E is the collection of edges to be found in G among that subset of vertices.

The inclusion or exclusion of vertices or edges in a graph G = (V,E) can be conceived of as the application of addition or subtraction operators, respectively, to the sets V and E. 

For example, 
h <- g - vertices(c(6,7)) 

Similarly, g can be recovered from h by first adding these two vertices back in, and then, adding the appropriate edges.

h <- h + vertices(c(6,7)) 
g <- h + edges(c(4,6),c(4,7),c(5,6),c(6,7)) 

Finally, the basic set-theoretic concepts of union, disjoint union, intersection, difference, and complement all extend in a natural fashion to graphs. For example, the union of two graphs, say H1 and H2, is a graph G in which vertices and edges are included if and only if they are included in at least one of H1 or H2. 

For example,
g <- graph.union(h1,h2)

No comments:

Post a Comment