Tag Info

New answers tagged

2

Here's the brute force way: og = CirculantGraph[100, Range[2]]; g = RandomGraph[WattsStrogatzGraphDistribution[100, 0.05]]; oelist = Sort /@ EdgeList[og]; elist = Sort /@ EdgeList[g]; rewired = Complement[oelist, elist] {4 <-> 6, 19 <-> 20, 21 <-> 23, 26 <-> 27, 31 <-> 32, 33 <-> 35, 44 <-> 45, 55 <-> 56, 56 <-> 58, ...


3

I think bill's tiling and extracting idea in his deleted answer is actually nice, only a little more effort is needed. First we define a handy plot function: Clear[morphPlot] morphPlot[m_] := ArrayPlot[m, ColorFunction -> "Pastel"] /. (List @@ ColorData["Pastel"][0]) -> {0, 0, 0} We generate a test array m, tile it and apply the ...


2

SeedRandom[43]; m = RandomInteger[{0, 1}, {14, 12}]; m1 = ArrayPad[m, 1, "Periodic"]; db = Dimensions@m1; m1[[1, 1]] = m1[[1, db[[2]]]] = m1[[db[[1]], db[[2]]]] = m1[[db[[1]], 1]] = 0 b = MorphologicalComponents[m1, CornerNeighbors -> False]; t[{x_, y_}] := Flatten[{{{#, 1}, {#, y}} & /@ Range@x, {{1, #}, {x, #}} & /@ Range@y}, 1] k = b ...


11

This generates a 20 by 20 binary matrix and finds the morphological components. SeedRandom[11]; m=RandomInteger[{0,1},{20,20}]; a=MorphologicalComponents[m,CornerNeighbors->False] Notice that morphological component 2, in row 1, col 6, abuts morphological component 42 in row 20, col 6. Morphological components 2 and 39 abut in column 8. These ...



Top 50 recent answers are included