コード例 #1
0
        public GraphAnalyzer(Graph graph, PatternMap patterns = null)
        {
            this.graph = graph;
            matrix     = AdjacencyMatrix.FromGraph(graph);
            invariants = matrix.GetInvariantGroups();

            KnownPatterns = patterns ?? new PatternMap(matrix);
            if (patterns != null)
            {
                KnownPatterns.ClearInstances();
            }

            filterer = new PatternFilterer(KnownPatterns);
            selector = new PatternSelector(KnownPatterns);
        }
コード例 #2
0
        /// <summary>
        /// Группирует связные подграфы по инвариантам.
        /// </summary>
        internal InvariantMap GetInvariantGroups()
        {
            var cache        = new MinorCache(this);
            var invariantMap = new InvariantMap(this);

            //Находим миноры размера 2
            for (int i = 0; i < Vertices; i++)
            {
                for (int j = 0; j < Vertices; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }

                    int det = Matrix[i, i] * Matrix[j, j] - Matrix[i, j] * Matrix[j, i];
                    cache[i, j] = det;
                }
            }

            //Находим остальные миноры рекурсивно
            for (int n = 3; n <= Vertices; n++)
            {
                var minors = MinorsOfSize(n);
                foreach (var minor in minors)
                {
                    int det = 0;
                    for (int i = 0; i < minor.Length; i++)
                    {
                        int   sign        = i % 2 == 0 ? 1 : -1;
                        int[] lesserMinor = minor.SkipIndex(i);
                        det += this[minor[i], minor[0]] * cache[lesserMinor] * sign;
                    }

                    cache[minor] = det;
                    if (MinorIsConnected(minor))
                    {
                        invariantMap.Add(minor, det);
                    }
                }
            }

            return(invariantMap);
        }
コード例 #3
0
ファイル: Invariant.struct.cs プロジェクト: 0xCM/Meta.Core
 public Invariant(InvariantMap <X, CX, Y, CY> imap)
 => this._imap = imap;