I am trying to efficiently extract sub-graphs from very large weighted directed graphs. I thought Subgraph
would do this, but it does not, which seems a bit odd since edge weights are intrinsic properties of the graph.
First, a toy directed, weighted graph as an example:
size = 10;
rAm = Table[If[Or[i == j, RandomReal[{0, 1}] < .8], Infinity,
RandomInteger[{1, 100}] - 1], {i, size}, {j, size}];
wAg = WeightedAdjacencyGraph[rAm]
Extracting the weighted adjacency matrix
MatrixForm[WeightedAdjacencyMatrix[wAg]
But when I extract a subgraph that includes the first 6 vertices, the edge weights are not preserved.
rSg = Subgraph[wAg, Range[6]]
WeightedAdjacencyMatrix[rSg] // MatrixForm
I would expect:
Edge weights do not come with the Subgraph
even if I specify edges, as opposed to vertices.