# Non-induced subgraphs

I would like to construct graphs that are generated by subsets of the graph edges but that are non necessarily induced subgraphs, so to be able to construct a function that returns all spanning subgraphs of a graph. I thought this could be done with the Subgraph function, but the example below shows that this is not the case.

G = Graph[{1 <-> 2, 1 <-> 3, 2 <-> 3, 2 <-> 4, 3 <-> 4}];

H = Subgraph[G, {1 <-> 2, 1 <-> 3, 2 <-> 4, 3 <-> 4}];

H == G
(* True *)


(However in this example I would like to get the subgraph without the edge 2<->3)

How can I proceed? Do I need to implement the whole construction, or are there pre-implemented functions that I could use?

1. You cannot use == to compare graphs. Do not do this. It may give unexpected results.
2. Just use Graph[{1 <-> 2, 1 <-> 3, 2 <-> 4, 3 <-> 4}] to get the subgraph containing exactly thes edges. There is no need to refer to the original graph to get this "subgraph" as it's just the collection of the same edges that you specified.
To take a non-induced subgraph and preserve any properties, use IGTakeSubgraph from IGraph/M.
• @MaurizioMoreschi My point is that since it is not an induced subgraph you want, there is nothing to induce/generate. There is no need for a function. Just state the edges you want included and that's it. A special function would be warranted for the case when we want to retain attributes. The IGTakeSubgraph function of my IGraph/M package can do this. – Szabolcs Feb 24 '20 at 9:23