Exemplo n.º 1
0
        public List <SymmetryClass> GetSymmetryClasses(int height)
        {
            var symmetryClasses = new List <SymmetryClass>();

            for (int i = 0; i < this.GetVertexCount(); i++)
            {
                var           signatureString = this.SignatureStringForVertex(i, height);
                SymmetryClass foundClass      = null;
                foreach (var symmetryClass in symmetryClasses)
                {
                    if (symmetryClass.HasSignature(signatureString))
                    {
                        foundClass = symmetryClass;
                        break;
                    }
                }
                if (foundClass == null)
                {
                    foundClass = new SymmetryClass(signatureString);
                    symmetryClasses.Add(foundClass);
                }
                foundClass.AddIndex(i);
            }
            return(symmetryClasses);
        }
Exemplo n.º 2
0
        public void Construct(List <SymmetryClass> symmetryClasses)
        {
            // make the vertices from the symmetry classes
            for (int i = 0; i < symmetryClasses.Count; i++)
            {
                SymmetryClass symmetryClass   = symmetryClasses[i];
                string        signatureString = symmetryClass.GetSignatureString();
                List <int>    members         = new List <int>();
                foreach (var e in symmetryClass)
                {
                    members.Add(e);
                }
                vertices.Add(new Vertex(members, signatureString));
            }

            // compare all vertices (classwise) for connectivity
            List <Edge> visitedEdges = new List <Edge>();

            for (int i = 0; i < symmetryClasses.Count; i++)
            {
                SymmetryClass symmetryClass = symmetryClasses[i];
                for (int j = i; j < symmetryClasses.Count; j++)
                {
                    SymmetryClass otherSymmetryClass = symmetryClasses[j];
                    int           totalCount         = 0;
                    foreach (var x in symmetryClass)
                    {
                        int countForX = 0;
                        foreach (var y in otherSymmetryClass)
                        {
                            if (x == y)
                            {
                                continue;
                            }
                            if (IsConnected(x, y) &&
                                !InVisitedEdges(x, y, visitedEdges))
                            {
                                countForX++;
                                visitedEdges.Add(new Edge(x, y, 0));
                            }
                        }
                        totalCount += countForX;
                    }
                    if (totalCount > 0)
                    {
                        edges.Add(new Edge(i, j, totalCount));
                    }
                }
            }
        }