Suppose that we have two matrices with identical dimensions: matA and matB. I want to identify a set of pathways using matA, but then map the respective edge weights from matB onto the pathways identified from matA. I like to perform this operation with a MMA function such as map[matA_, matB_, t1_,t2_]:=
ClearAll[n, matA, matB, map]; << IGraphM`; << BoolEval`; SeedRandom[4]; n = 10; matA = RandomReal[{0.1, 0.5}, {n, n}]; matB = RandomReal[{0.1, 0.4}, {n, n}]; map[matrixA_?MatrixQ, matrixB_?MatrixQ, t1_Real, t2_Real] := { selectBetween[t1, t2] = BoolEval[t1 <= matrixA < t2]; subgraphBetween[t1, t2] = AdjacencyGraph[selectBetween[t1, t2], VertexLabels -> "Name"]; pindex = FindPath[subgraphBetween[t1, t2], 1, 3, Infinity]; prule=Rule @@@ Partition[pindex[[4]], 2, 1] Graph[prule, EdgeWeight -> Flatten[matrixB], DirectedEdges->True, VertexLabels -> "Name", EdgeLabels -> "EdgeWeight"] I think everything works fine until Graph[..] in the above code. pindex is identified but I cannot map the associated edge weights from matB onto pindex.
Needless to say, any improvement on this code is most welcome. Thank you for your help.




