コード例 #1
0
        /// <summary>
        /// Removes duplicate vertex clusters from the adjacencies.
        /// </summary>
        public void RemoveDuplicateVertexClusters()
        {
            VertexAdjacencyRow temporaryRow = new VertexAdjacencyRow();

            foreach (VertexCluster vertexCluster in m_adjacencies)
            {
                if (!temporaryRow.ContainsAdjacency(vertexCluster))
                {
                    temporaryRow.Adjacencies.Add(vertexCluster);
                }
            }

            m_adjacencies = temporaryRow.Adjacencies;
        }
コード例 #2
0
        /// <summary>
        /// Merges this row with the specified row.
        /// </summary>
        /// <param name="adjacencyRow">The row to merge with this row.</param>
        public void MergeWith(VertexAdjacencyRow adjacencyRow)
        {
            // Remove the headers of the merging rows from their respective adjacency lists.
            this.RemoveVertex(adjacencyRow.Header);
            adjacencyRow.RemoveVertex(this.Header);

            // OR-Wise Merging of Adjacencies
            foreach (VertexCluster adjacency in adjacencyRow.Adjacencies)
            {
                if (!this.ContainsAdjacency(adjacency))
                {
                    m_adjacencies.Add(adjacency);
                }
            }

            m_rowHeader.MergeWith(adjacencyRow.Header);
        }
コード例 #3
0
        /// <summary>
        /// Mergers two vertices together once a direct connection has been determined.
        /// </summary>
        /// <param name="fromVertexCluster">The vertex on the from side of the edge.</param>
        /// <param name="toVertexCluster">The vertex on the to side of the edge.</param>
        public void ConnectionEstablished(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 = m_adjacencyList.RowWithHeader(fromVertexCluster);
            VertexAdjacencyRow target = m_adjacencyList.RowWithHeader(toVertexCluster);

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

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

            // Update the vertices in the rest of the table
            foreach (VertexAdjacencyRow row in m_adjacencyList.Rows)
            {
                foreach (VertexCluster vertexCluster in row.Adjacencies)
                {
                    if (vertexCluster.Equals(fromCluster) || vertexCluster.Equals(toCluster))
                    {
                        vertexCluster.Vertices = source.Header.Vertices;
                    }
                }
                row.RemoveDuplicateVertexClusters();
            }
        }
コード例 #4
0
 /// <summary>
 /// Removes a specified row from the list.
 /// </summary>
 /// <param name="row">The row to remove.</param>
 public void RemoveRow(VertexAdjacencyRow row)
 {
     m_adjacencyRows.Remove(row);
 }
コード例 #5
0
 /// <summary>
 /// Merges this row with the specified row and returns the resulting row
 /// </summary>
 /// <param name="adjacencyRow">The row to merge with this row.</param>
 /// <returns>A row which is the OR-wise union of two rows.</returns>
 public VertexAdjacencyRow MergeToFormNewRow(VertexAdjacencyRow adjacencyRow)
 {
     this.MergeWith(adjacencyRow);
     return(this);
 }