Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. pos={{1,4},{1,8},{1,9},{2,2},{2,3},{2,4},{2,5},{2,6},{2,8},{2,9},{3,2},{3,6},{4,1},{4,2},{4,3},{4,4},{4,5},{4,6},{4,7},{4,8},{5,2},{5,7},{6,2},{6,5},{6,6},{6,7},{7,2},{7,5},{7,8},{8,2},{8,4},{8,5},{8,6},{8,7},{8,8},{8,9},{9,2}};
  2. m=SparseArray[pos->0,{9,9},1];
  3. ArrayPlot[m,Mesh->All]
  4.  
  5. g = Graph[Range[81],
  6. UndirectedEdge @@@ {36 -> 35, 17 -> 26, 26 -> 35, 35 -> 44,
  7. 44 -> 53, 17 -> 16, 16 -> 15, 15 -> 14, 14 -> 13, 13 -> 12,
  8. 12 -> 11, 11 -> 10, 6 -> 15, 15 -> 24, 24 -> 33, 33 -> 42,
  9. 42 -> 51, 51 -> 60, 60 -> 59, 59 -> 58, 58 -> 49, 49 -> 40,
  10. 40 -> 39, 39 -> 38, 29 -> 38, 38 -> 47, 47 -> 56, 56 -> 65,
  11. 65 -> 74, 66 -> 65, 71 -> 72, 72 -> 81, 81 -> 80, 80 -> 71,
  12. 53 -> 52, 51 -> 52, 60 -> 69}, {
  13. VertexCoordinates -> Tuples[Range[9], 2]}, VertexLabels -> "Name"]
  14. FindPath[%, 36, 74, Infinity, All]
  15. HighlightGraph[g, PathGraph[#]] & /@ %
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement