Esempio n. 1
0
        private void InitializeAdjacencyList()
        {
            m_adjacencyList = new VertexAdjacencyList();

            List <VertexCluster>      vertexClusters = new List <VertexCluster>();
            List <VertexAdjacencyRow> adjacencyRows  = new List <VertexAdjacencyRow>();

            foreach (Node node in m_vertexSet)
            {
                VertexCluster        vertexCluster     = new VertexCluster(node.InternalID);
                List <VertexCluster> vertexAdjacencies = new List <VertexCluster>();

                foreach (SwitchingDeviceBase switchingDevice in m_edgeSet)
                {
                    if (node.InternalID == switchingDevice.FromNode.InternalID)
                    {
                        vertexAdjacencies.Add(new VertexCluster(switchingDevice.ToNode.InternalID));
                    }
                    else if (node.InternalID == switchingDevice.ToNode.InternalID)
                    {
                        vertexAdjacencies.Add(new VertexCluster(switchingDevice.FromNode.InternalID));
                    }
                }

                m_adjacencyList.Rows.Add(new VertexAdjacencyRow(vertexCluster, vertexAdjacencies));
            }
        }
Esempio n. 2
0
        private void InitializeSeriesImpedanceAdjacencyList()
        {
            m_seriesImpedanceConnectedAdjacencyList = new VertexAdjacencyList();

            List <VertexCluster>      vertexClusters = new List <VertexCluster>();
            List <VertexAdjacencyRow> adjacencyRows  = new List <VertexAdjacencyRow>();

            foreach (Node node in m_vertexSet)
            {
                VertexCluster        vertexCluster     = new VertexCluster(node.InternalID);
                List <VertexCluster> vertexAdjacencies = new List <VertexCluster>();

                foreach (ITwoTerminal seriesBranch in m_edgeSet)
                {
                    if (node.InternalID == seriesBranch.FromNode.InternalID)
                    {
                        vertexAdjacencies.Add(new VertexCluster(seriesBranch.ToNode.InternalID));
                    }
                    else if (node.InternalID == seriesBranch.ToNode.InternalID)
                    {
                        vertexAdjacencies.Add(new VertexCluster(seriesBranch.FromNode.InternalID));
                    }
                }

                m_seriesImpedanceConnectedAdjacencyList.Rows.Add(new VertexAdjacencyRow(vertexCluster, vertexAdjacencies));
            }
        }
Esempio n. 3
0
        private void ConnectionEstablished(VertexAdjacencyList adjacencyList, VertexCluster fromVertexCluster, VertexCluster toVertexCluster)
        {
            List <int> fromVertices = new List <int>();
            List <int> toVertices   = new List <int>();

            foreach (int vertex in fromVertexCluster.Vertices)
            {
                fromVertices.Add(vertex);
            }

            foreach (int vertex in toVertexCluster.Vertices)
            {
                toVertices.Add(vertex);
            }

            VertexCluster fromCluster = new VertexCluster(fromVertices);
            VertexCluster toCluster   = new VertexCluster(toVertices);

            VertexAdjacencyRow source = adjacencyList.RowWithHeader(fromVertexCluster);
            VertexAdjacencyRow target = adjacencyList.RowWithHeader(toVertexCluster);

            // Merge the two rows into one
            source.MergeWith(target);

            // Remove the old from the list
            adjacencyList.RemoveRow(target);

            // Update the vertices in the rest of the table
            foreach (VertexAdjacencyRow row in adjacencyList.Rows)
            {
                foreach (VertexCluster vertexCluster in row.Adjacencies)
                {
                    if (vertexCluster.Equals(fromCluster) || vertexCluster.Equals(toCluster))
                    {
                        vertexCluster.Vertices = source.Header.Vertices;
                    }
                }
                row.RemoveDuplicateVertexClusters();
            }
        }