An induced subgraph of a graph is another graph, formed from a subset of the vertices of the graph and all of the edges (from the original graph) connecting pairs of vertices in that subset. For example:
Graph[{"A" <-> "B", "A" <-> "C", "A" <-> "F", "B" <-> "D",
"B" <-> "E", "D" <-> "E", "A" <-> "E", "B" <-> "F"},
VertexLabels -> Automatic]
There is only one subgraph induced by {A, B, D, E} in the above graph:
The InduceSubgraph function does not seem to be directly available from Mathematica.
When I use the Combinatorica package, it breaks mathematica's own Graph function.
So I wanted to get the induced subgraph by extracting sub-matrix. But I am not very clear how the vertex labels of the graph correspond to the labels of its adjacency matrix. So the code below is elementary and not very reliable.
Inducedgraph[g_, vlist_] := Module[{sub}, AdjacencyMatrix[g];
sub = s[[vlist, vlist]];
AdjacencyGraph[sub]];
Especially when vertices of a graph are labeled with letters rather than numbers, it seems more important to find reliable code.
Edit: Thanks yode for the reminder that Subgraph
can do that. But I'm also interested in a custom implementation of this function.