0

I want to add two 10 by 10 matrices (same dimension) together but get a weird result. This is the screenshot of it:

enter image description here

The matrices are defined in this manner:

r1 = ({
{0, 2, 2, 10, 8, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 6, 0, 0, 0, 0},
{0, 4, 0, 0, 0, 0, 4, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 4, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 6, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 11},
{0, 0, 0, 0, 0, 4, 0, 0, 0, 4},
{0, 0, 0, 0, 0, 0, 6, 0, 0, 4},
{0, 0, 0, 0, 0, 0, 0, 2, 0, 4},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
})

g = WeightedAdjacencyGraph[({
  {0, 2, 2, 2, 10, 0, 0, 0, 0, 0},
  {0, 0, 0, 0, 0, 2, 0, 0, 0, 0},
  {0, 2, 0, 0, 0, 0, 6, 0, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
  {0, 0, 6, 0, 0, 0, 0, 0, 2, 0},
  {0, 0, 0, 0, 0, 0, 0, 0, 0, 5},
  {0, 0, 0, 0, 0, 1, 0, 0, 0, 2},
  {0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
  {0, 0, 0, 0, 0, 0, 0, 4, 0, 6},
  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
 }) /. {0 -> Infinity}];

F = FindMaximumFlow[g, 1, 10, "OptimumFlowData", EdgeCapacity -> EdgeWeight]

F["FlowGraph"]

r2 = WeightedAdjacencyMatrix[%] // MatrixForm

So, to get the result I have to add those two matrices together but get the result shown in the picture above. I searched how to resolve this problem but didn't find anything similar, also haven't found any other way to add two matrices instead of using the + operator.

I assume I made some fundamental mistake since this shouldn't be happening but can't figure out what it is. Any help would be appreciated!

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Larisa
  • 175
  • 3

0 Answers0