title: Get Only Ring Nodes from a diagram
body: <p>I am facing a problem that requires me get nodes that are within a ring. I wrote a recursie method but it is not doing what I want so I need some help on this one.</p>
  
  <p>The <a href="http://i.stack.imgur.com/zKryo.jpg" rel="nofollow">picture</a> below explains what I am looking for since I am having a hard time explaining it.</p>
  
  <p>given the root node 0, I would like to get the ring from those nodes which is basically 0 , 1 , 2 , 7,  8,  9</p>
  
  <p>keep in mind that each node contains list of nodes connected to it, so node 0 has both node 1, and node 9 as connected to it. so everything is there, but I cant get the correct logic to get that ring.  here is the method I wrote but unfortunatly it is not working for all diagrams.</p>
  
  <pre><code>    private bool SetMainRingList(StructureFeature strct, StructureFeature root, List&lt;StructureFeature&gt; mainRing) {
          if ((strct.Equals(root) &amp;&amp; mainRing.Contains(strct))) {
              return false;
          }
          var children = strct.GetConnectedStructures();
          if ((children.Contains(root) &amp;&amp; mainRing.Contains(strct))) {
              return false;
          }
          mainRing.Add(strct);
          foreach (var structureFeature in children) {
              if (mainRing.Contains(structureFeature)) {
                  var strcture = mainRing.Find(x =&gt; x.Oid == structureFeature.Oid);
                  if (strcture.ParentFeature == null)
                      continue;
                  if (strcture.ParentFeature.Equals(root)) {
                      bool skip = false;
                      var crntChildren = strcture.GetConnectedStructures();
                      foreach (var childContainerse in crntChildren) {
                          if (!mainRing.Contains(childContainerse)) {
                              skip = true;
                              break;
                          }
                      }
                      if (!skip)
                          return false;
                  }
                  continue;
              }
              structureFeature.ParentFeature = strct;
              var leaf = SetMainRingList(structureFeature, root, mainRing);
              var exchangeSite = structureFeature as ExchangeStructure;
              if (leaf &amp;&amp; ReferenceEquals(exchangeSite, null)) {
                  mainRing.Remove(structureFeature);
              } else {
                  return false;
              }
          }
          return true;
      }
  </code></pre>