SHARE
TWEET

Untitled

a guest Dec 16th, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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]]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top