Example #1
0
 // ReSharper disable once UnusedParameter.Local
 bool FValidDegrees(int ivtx1, int ivtx2)
 {
     // We must always have the degrees in graph1 at least as large as those in graph2.  Also,
     // since we order the vertices by total degree size, when we fail this condition, we know that
     // there are no further vertices in graph1 which will match the current graph2 vertex so we can
     // abandon the search.
     return _vfs.FnCompareDegrees(_vfs.VfGraph1.InDegree(ivtx1) + _vfs.VfGraph1.OutDegree(ivtx1), _totalDegree2);
 }
Example #2
0
        /// <summary>
        /// Find a candidate graph2 vertex and the list of possible matches from graph1
        /// </summary>
        /// <remarks>
        /// Find a candidate list from graph1 vertices for a particular graph2 vertex.  If we've got vertices
        /// in both out lists, take the first graph2 vertex in the outlist and use all the vertices in the
        /// graph1 out list as candidates.  If that doesn't work, do the same for the two respective
        /// in lists and finally for the vertices disconnected from the current isomorphism.
        /// </remarks>
        /// <param name="vfs">State to grab vertices from</param>
        internal CandidateFinder(VfState<TVAttr, TEAttr> vfs)
        {
            _vfs = vfs;

            // Check to see if degrees are valid - this is only available because we sort the vertices
            // by degree
            if (
                !vfs.FnCompareDegrees(vfs.LstOut1.Count, vfs.LstOut2.Count) ||
                !vfs.FnCompareDegrees(vfs.LstIn1.Count, vfs.LstIn2.Count) ||
                !vfs.FnCompareDegrees(vfs.LstDisconnected1.Count, vfs.LstDisconnected2.Count))
            {
                // Life isn't worth living - signal to ourselves to fail at the first call to
                // NextCandidateMatch().
                _fFailImmediately = true;
                return;
            }

            // Try to find a match in vertices pointed to from the isomorphism
            if (vfs.LstOut2.Count > 0 && vfs.LstOut1.Count > 0)
            {
                _graph1Candidates = new int[vfs.LstOut1.Count];
                vfs.LstOut1.CopyTo(_graph1Candidates);
                SetInitialMatch(vfs.LstOut1[0], vfs.LstOut2[0]);
            }
            // Try to find a match in vertices pointing into the isomorphism
            else if (vfs.LstIn2.Count > 0 && vfs.LstIn1.Count > 0)
            {
                _graph1Candidates = new int[vfs.LstIn1.Count];
                vfs.LstIn1.CopyTo(_graph1Candidates);
                SetInitialMatch(vfs.LstIn1[0], vfs.LstIn2[0]);
            }
            // Try to find a match in vertices unattached to the isomorphism
            else if (vfs.LstDisconnected1.Count >= 0)
            {
                _graph1Candidates = new int[vfs.LstDisconnected1.Count];
                vfs.LstDisconnected1.CopyTo(_graph1Candidates);
                SetInitialMatch(vfs.LstDisconnected1[0], vfs.LstDisconnected2[0]);
            }
        }