Example #1
0
        public SparseMatrix(SparseMatrix other)
        {
            _numVertices = other._numVertices;
            _matrix = new Dictionary<AST.Address, Dictionary<AST.Address, HashSet<int>>>(_numVertices);

            foreach (var kvp in other._matrix)
            {
                var source = kvp.Key;
                var dests = kvp.Value;
                foreach (var dkvp in dests)
                {
                    var dest = dkvp.Key;
                    var distances = dkvp.Value;

                    foreach (var distance in distances)
                    {
                        this.Connect(source, dest, distance);
                    }
                }
            }
        }
Example #2
0
        public SparseMatrix Transpose()
        {
            var transpose = new SparseMatrix(_numVertices);

            foreach (var kvp in _matrix)
            {
                var dest = kvp.Key;
                var sources = kvp.Value;

                foreach (var skvp in sources)
                {
                    var source = skvp.Key;
                    var distances = skvp.Value;

                    foreach (var distance in distances)
                    {
                        transpose.Connect(source, dest, distance);
                    }
                }
            }

            return transpose;
        }