Guest User

Untitled

a guest
Dec 16th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. SeedRandom[1]
  2. arrayR = Append[Thread[RandomSample[Tuples[Range[1000], {2}], 5000] ->
  3. RandomReal[1, 5000]], {_, _} -> 0];
  4.  
  5. weightedGraph=WeightedAdjacencyGraph[SparseArray[Most@arrayR, {1000, 1000}, ∞]];
  6.  
  7.  
  8. weG = weightedGraph;
  9. resMatrix = AdjacencyMatrix[weG];
  10. Table[minST = FindSpanningTree[weG];
  11. adjM1 = AdjacencyMatrix[minST];
  12. adjWG1 = AdjacencyMatrix[weG];
  13. weG = WeightedAdjacencyGraph[
  14. SparseArray[
  15. Most@ArrayRules[
  16. Chop[(adjWG1 - adjM1)]*WeightedAdjacencyMatrix[weG]], {1000,
  17. 1000}, [Infinity]]];, {3}];
  18. Chop[resMatrix - AdjacencyMatrix[weG]]
Add Comment
Please, Sign In to add comment