Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Algorithms
  4. Creating paths in a 2D array

Creating paths in a 2D array

Scheduled Pinned Locked Moved Algorithms
comdata-structureshelpquestionlounge
3 Posts 3 Posters 8 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member_15615426
    wrote on last edited by
    #1

    Hello! Given a 2D array each node in the array may or may not be "alive" based on random values. I'm trying to find a way to connect "live" nodes in this 2D array to each other so that no isolated groups are created during the process, meaning that from any live node I can reach any other live node via the created paths. A picture to visualize the problem.[^] Can someone point me in the right direction?

    L S 2 Replies Last reply
    0
    • M Member_15615426

      Hello! Given a 2D array each node in the array may or may not be "alive" based on random values. I'm trying to find a way to connect "live" nodes in this 2D array to each other so that no isolated groups are created during the process, meaning that from any live node I can reach any other live node via the created paths. A picture to visualize the problem.[^] Can someone point me in the right direction?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Hi, You are not really giving enough information about the problem you are trying to solve. The screenshot implies that there are impassable nodes.

      Member 15615426 wrote:

      Can someone point me in the right direction?

      If you are trying to find the Eulerian path check out Fleury's algorithm as that might be what you're are looking for.

      1 Reply Last reply
      0
      • M Member_15615426

        Hello! Given a 2D array each node in the array may or may not be "alive" based on random values. I'm trying to find a way to connect "live" nodes in this 2D array to each other so that no isolated groups are created during the process, meaning that from any live node I can reach any other live node via the created paths. A picture to visualize the problem.[^] Can someone point me in the right direction?

        S Offline
        S Offline
        Syed Mubashshir Hasan
        wrote on last edited by
        #3

        You can use BFS or DFS to determine whether or not there is a path. The graph is not required to execute the bfs, but the matrix itself will be utilized as one. Begin the traversal from the upper right corner, and if there is a method to the lower right corner, there is a path.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups