示例#1
0
        public UndirectedGraph(IEnumerable <string> source  = null, IEnumerable <string> target = null,
                               IEnumerable <double> weights = null, bool saveStates             = true)
        {
            _source  = source as List <string> ?? new List <string>();
            _target  = target as List <string> ?? new List <string>();
            _weights = weights as List <double> ?? new List <double>();
            _all     = _source.Concat(_target).Distinct().ToList();

            _edges = new List <string[]>();
            for (var i = 0; i < _source.Count; i++)
            {
                _edges.Add(new [] { _source[i], _target[i] });
            }

            if (!saveStates)
            {
                return;
            }

            _saveStates   = true;
            _edgesHistory = new EdgesHistory
            {
                Marker = new List <byte>(),
                Source = new List <string>(),
                Target = new List <string>(),
                Weigth = new List <double>()
            };
        }
示例#2
0
 public DirectedGraph(IEnumerable <string> source  = null, IEnumerable <string> target = null,
                      IEnumerable <double> weights = null, bool saveStates             = true)
 {
     _source        = source as List <string> ?? new List <string>();
     _target        = target as List <string> ?? new List <string>();
     _weights       = weights as List <double> ?? new List <double>();
     _catalogCycles = new List <string>();
     _all           = _source.Concat(_target).Distinct().ToList();
     if (!saveStates)
     {
         return;
     }
     _saveStates   = true;
     _edgesHistory = new EdgesHistory
     {
         Marker = new List <byte>(),
         Source = new List <string>(),
         Target = new List <string>(),
         Weigth = new List <double>()
     };
 }