Example #1
0
        private void RemoveVertex(DateVertex v)
        {
            // We want to enforce the re-assignment of cycles
            _cycles = null;

            v = _verteces.Find(v1 => v.Key == v1.Key);

            if(null != v)
            {
                _verteces.Remove(v);
                _edges.Remove(v.Key);

                foreach (var key in _edges.Keys)
                {
                    var list = _edges[key];
                    int index = 0;
                    while(index < list.Count)
                    {
                        var e = list[index];
                        if(e.V1.Key == v.Key || e.V2.Key == v.Key)
                        {
                            list.Remove(e);
                            --index;
                        }
                        ++index;
                    }
                }
            }
        }
Example #2
0
 internal List<DateVertex> GetAdjustentVerteces(DateVertex vertex)
 {
     var list = new List<DateVertex>();
     GetEdges(vertex.Key).ForEach(e => list.Add(e.V2));
     return list;
 }
Example #3
0
        private DateVertex GetVertex(string key)
        {
            DateVertex v = _verteces.Find(vx => vx.Key == key);

            if (null == v)
            {
                v = new DateVertex(key);
                _verteces.Add(v);
            }

            return v;
        }
Example #4
0
 private static List<List<DateVertex>> Traverse(DateVertex startingVertex)
 {
     _stack.Clear();
     _g.Verteces.ToList().ForEach(v => v.Visited = false);
     _target = startingVertex.Key;
     _stack.Push(startingVertex);
     startingVertex.Visited = true;
     MakeAVisit();
     return _cycles;
 }