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. C#
  4. Chech if a graph is connected

Chech if a graph is connected

Scheduled Pinned Locked Moved C#
questiondata-structureshelp
2 Posts 2 Posters 0 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.
  • B Offline
    B Offline
    brkonja
    wrote on last edited by
    #1

    Hello, How can I check if my graph stays connected, after removing one or more edges from it? I try to implement Christofides heuristik, and in some cases my code works (that is when the graph dosent disconnect under the process). Unlucky that is not the case for all the graphs. I use Dijkstras to check if there is a route from my last node in the edge I am to remove, to other nodes. But, how du I see that "this" edge if removed is disconnecting the graph, so I can leave the edge and try the next one? Thanks... It would be easier to understand if I could post a picture of the problem. :(

    S 1 Reply Last reply
    0
    • B brkonja

      Hello, How can I check if my graph stays connected, after removing one or more edges from it? I try to implement Christofides heuristik, and in some cases my code works (that is when the graph dosent disconnect under the process). Unlucky that is not the case for all the graphs. I use Dijkstras to check if there is a route from my last node in the edge I am to remove, to other nodes. But, how du I see that "this" edge if removed is disconnecting the graph, so I can leave the edge and try the next one? Thanks... It would be easier to understand if I could post a picture of the problem. :(

      S Offline
      S Offline
      Super Lloyd
      wrote on last edited by
      #2

      how about a visited bool flag on each node. make it false on all node then start visit the graph from a root to all its connected node recursively and set the visited flag to true for each visited node when finished review all node, those with the false to false are disconnected, voila! :) For your information this is roughly what the GC is doing to find object to collect!! ^^

      My programming get away... The Blog... DirectX for WinRT/C# since 2013! Taking over the world since 1371!

      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