Beispiel #1
0
        private void MakeEdges(IGraphLoader <TV, TE> loader, int vid, Dictionary <VfEdge, VfEdge> dctEdge, List <int> mpIvtxGraphIvtxVf)
        {
            var ivtxGraph = loader.PosFromId(vid);
            var vfeKey    = new VfEdge(mpIvtxGraphIvtxVf[ivtxGraph], 0, null);

            MakeOutEdges(loader, vid, dctEdge, mpIvtxGraphIvtxVf, ref vfeKey);
            MakeInEdges(loader, vid, dctEdge, mpIvtxGraphIvtxVf, ref vfeKey);
        }
Beispiel #2
0
 /// <summary>
 /// Add edge to a vertex that is defined only by its mandatory fields
 /// </summary>
 /// <typeparam name="V"></typeparam>
 /// <typeparam name="E"></typeparam>
 /// <param name="loader"></param>
 /// <param name="outVertex"></param>
 /// <param name="edge"></param>
 /// <param name="inVId"></param>
 /// <param name="inVLabel"></param>
 /// <param name="inVPk"></param>
 /// <returns></returns>
 public static Task AddEdgeAsync <V, E>(this IGraphLoader loader,
                                        V outVertex, E edge, string inVId, string inVLabel, string inVPk = null)
 {
     return(loader.AddEdgeAsync(outVertex, edge, new {
         id = inVId,
         label = inVLabel,
         __pk = inVPk
     }));
 }
Beispiel #3
0
        internal VfnNode(IGraphLoader loader, int inodGraph, Dictionary <VfeNode, VfeNode> dctEdge, int[] mpInodGraphInodVf)
        {
            int nid = loader.IdFromPos(inodGraph);

            _objAttr      = loader.GetNodeAttr(nid);
            _arvfeEdgeOut = new VfeNode[loader.OutEdgeCount(nid)];
            _arvfeEdgeIn  = new VfeNode[loader.InEdgeCount(nid)];
            MakeEdges(loader, nid, dctEdge, mpInodGraphInodVf);
        }
Beispiel #4
0
        internal VfVertex(IGraphLoader <TV, TE> loader, int ivtxGraph, Dictionary <VfEdge, VfEdge> dctEdge, List <int> mpIvtxGraphIvtxVf)
        {
            var vid = loader.IdFromPos(ivtxGraph);

            _attribute = loader.GetVertexAttr(vid);
            _outEdges  = new VfEdge[loader.OutEdgeCount(vid)];
            _inEdges   = new VfEdge[loader.InEdgeCount(vid)];
            MakeEdges(loader, vid, dctEdge, mpIvtxGraphIvtxVf);
        }
Beispiel #5
0
 /// <summary>
 /// Add edge from a vertex that is defined only by its mandatory fields
 /// </summary>
 /// <typeparam name="E"></typeparam>
 /// <typeparam name="V"></typeparam>
 /// <param name="loader"></param>
 /// <param name="outVId"></param>
 /// <param name="outVLabel"></param>
 /// <param name="edge"></param>
 /// <param name="outVertex"></param>
 /// <param name="outVPk"></param>
 /// <returns></returns>
 public static Task AddEdgeAsync <E, V>(this IGraphLoader loader,
                                        string outVId, string outVLabel, E edge, V outVertex, string outVPk = null)
 {
     return(loader.AddEdgeAsync(new {
         id = outVId,
         label = outVLabel,
         __pk = outVPk
     }, edge, outVertex));
 }
Beispiel #6
0
 public ETLContext(
     GraphExtractor graphExtractor,
     GraphTransformer graphTransformer,
     IGraphLoader graphLoader,
     Presenter presenter)
 {
     this.graphExtractor   = graphExtractor;
     this.graphTransformer = graphTransformer;
     this.graphLoader      = graphLoader;
     this.presenter        = presenter;
 }
Beispiel #7
0
 /// <summary>
 /// Create node stream decoder
 /// </summary>
 /// <param name="loader"></param>
 /// <param name="deviceId"></param>
 /// <param name="tags"></param>
 /// <param name="revision"></param>
 /// <param name="codec"></param>
 /// <param name="logger"></param>
 internal NodeSetStreamLoader(IGraphLoader loader, string deviceId,
                              IDictionary <string, string> tags, long revision, IVariantEncoderFactory codec,
                              ILogger logger)
 {
     _logger   = logger ?? throw new ArgumentNullException(nameof(logger));
     _codec    = codec?.Default ?? throw new ArgumentNullException(nameof(codec));
     _deviceId = deviceId ?? throw new ArgumentNullException(nameof(deviceId));
     _tags     = tags ?? throw new ArgumentNullException(nameof(tags));
     _loader   = loader ?? throw new ArgumentNullException(nameof(loader));
     _revision = revision;
 }
Beispiel #8
0
        private void MakeEdges(IGraphLoader loader, int nid, Dictionary <VfeNode, VfeNode> dctEdge, int[] mpInodGraphInodVf)
        {
            int     inodGraph = loader.PosFromId(nid);
            int     inodVf    = mpInodGraphInodVf[inodGraph];
            VfeNode vfeKey    = new VfeNode(0, 0, null);

            vfeKey._inodFrom = inodVf;
            MakeOutEdges(loader, nid, dctEdge, mpInodGraphInodVf, ref vfeKey);
            vfeKey._inodTo = inodVf;
            MakeInEdges(loader, nid, dctEdge, mpInodGraphInodVf, ref vfeKey);
        }
Beispiel #9
0
        internal VfGraph(IGraphLoader loader, int[] mpInodVfInodGraph)
        {
            _arNodes = new VfnNode[loader.NodeCount];
            int[] mpInodGraphInodVf = ReversePermutation(mpInodVfInodGraph);
            Dictionary <VfeNode, VfeNode> dctEdge = new Dictionary <VfeNode, VfeNode>();

            for (int inodVf = 0; inodVf < loader.NodeCount; inodVf++)
            {
                _arNodes[inodVf] = new VfnNode(loader, mpInodVfInodGraph[inodVf], dctEdge, mpInodGraphInodVf);
            }
        }
        public VfState(
            IGraphLoader <TV, TE> loader1,
            IGraphLoader <TV, TE> loader2,
            bool fIsomorphism  = false,
            bool fContextCheck = false)
        {
            LstIn1           = new SortedListNoValue <int>();
            LstOut1          = new SortedListNoValue <int>();
            LstIn2           = new SortedListNoValue <int>();
            LstOut2          = new SortedListNoValue <int>();
            LstDisconnected2 = new SortedListNoValue <int>();
            LstDisconnected1 = new SortedListNoValue <int>();
            _ldr1            = loader1;
            _ldr2            = loader2;

            _fContextCheck = fContextCheck;

            if (fIsomorphism)
            {
                // normal isomorphism - degrees must match exactly
                FnCompareDegrees = CmpIsomorphism;
            }
            else
            {
                // Subgraph isomorphism - degrees in graph2 must be less than
                // those of graph1.
                FnCompareDegrees = CmpSubgraphIsomorphism;
            }

            // Vertex indices in VfGraphs are sorted by vertex degree
            _degreeSortedToOriginal1 = new CmpVertexDegrees <TV, TE>(loader1).Permutation;
            _degreeSortedToOriginal2 = new CmpVertexDegrees <TV, TE>(loader2).Permutation;
            VfGraph1 = new VfGraph <TV, TE>(loader1, _degreeSortedToOriginal1);
            VfGraph2 = new VfGraph <TV, TE>(loader2, _degreeSortedToOriginal2);

            // Set up space for isomorphism mappings
            _vfGraphIvtx1To2Isomorphism = new Dictionary <int, int>(loader1.VertexCount);
            _vfGraphIvtx2To1Isomorphism = new Dictionary <int, int>(loader2.VertexCount);

            // When we start no isomorphic mappings and all vertices are disconnected
            // from the isomorphism.
            for (var i = 0; i < loader1.VertexCount; i++)
            {
                _vfGraphIvtx1To2Isomorphism[i] = MapIllegal;
                LstDisconnected1.Add(i);
            }
            for (var i = 0; i < loader2.VertexCount; i++)
            {
                _vfGraphIvtx2To1Isomorphism[i] = MapIllegal;
                LstDisconnected2.Add(i);
            }
        }
Beispiel #11
0
        internal VfGraph(IGraphLoader <TVAttr, TEAttr> loader, List <int> mpIvtxVfIvtxGraph = null)
        {
            if (mpIvtxVfIvtxGraph == null)
            {
                mpIvtxVfIvtxGraph = (new CmpVertexDegrees <TVAttr, TEAttr>(loader)).Permutation;
            }
            _arNodes = new VfVertex <TVAttr, TEAttr> [loader.VertexCount];
            var mpIvtxGraphIvtxVf = ReversePermutation(mpIvtxVfIvtxGraph);
            var dctEdge           = new Dictionary <VfEdge, VfEdge>();

            for (var ivtxVf = 0; ivtxVf < loader.VertexCount; ivtxVf++)
            {
                _arNodes[ivtxVf] = new VfVertex <TVAttr, TEAttr>(loader, mpIvtxVfIvtxGraph[ivtxVf], dctEdge, mpIvtxGraphIvtxVf);
            }
        }
Beispiel #12
0
        private static void ProcessGraph(IArgumentsParser parser, TextWriter writer)
        {
            IGraphLoader loader = ServiceLocator.Current.GetInstance <IGraphLoader>();
            IList <Node> graph  = loader.LoadGraph(parser.Path, writer);

            IGraphStorageService storage = ServiceLocator.Current.GetInstance <IGraphStorageService>();

            if (parser.UseRecreationMode)
            {
                storage.DeleteGraph();
                writer.WriteLine("Old graph has been deleted.");
            }

            storage.SaveGraph(graph);
            writer.WriteLine("Graph data has been saved.");
            writer.Flush();
        }
Beispiel #13
0
        private void MakeInEdges(IGraphLoader <TV, TE> loader, int vid, Dictionary <VfEdge, VfEdge> dctEdge, List <int> mpIvtxGraphIvtxVf, ref VfEdge vfeKey)
        {
            for (var i = 0; i < loader.InEdgeCount(vid); i++)
            {
                TE attr;
                vfeKey.IvtxFrom = mpIvtxGraphIvtxVf[loader.PosFromId(loader.GetInEdge(vid, i, out attr))];

                if (!dctEdge.ContainsKey(vfeKey))
                {
                    _inEdges[i] = dctEdge[vfeKey] = new VfEdge(vfeKey.IvtxFrom, vfeKey.IvtxTo, attr);
                    vfeKey      = new VfEdge(vfeKey.IvtxFrom, vfeKey.IvtxTo, null);
                }
                else
                {
                    _inEdges[i] = dctEdge[vfeKey];
                }
            }
        }
Beispiel #14
0
        private void MakeInEdges(IGraphLoader loader, int nid, Dictionary <VfeNode, VfeNode> dctEdge, int[] mpInodGraphInodVf, ref VfeNode vfeKey)
        {
            object attr;

            for (int i = 0; i < loader.InEdgeCount(nid); i++)
            {
                vfeKey._inodFrom = mpInodGraphInodVf[loader.PosFromId(loader.GetInEdge(nid, i, out attr))];

                if (!dctEdge.ContainsKey(vfeKey))
                {
                    _arvfeEdgeIn[i] = dctEdge[vfeKey] = new VfeNode(vfeKey._inodFrom, vfeKey._inodTo, attr);
                    vfeKey          = new VfeNode(vfeKey._inodFrom, vfeKey._inodTo, null);
                }
                else
                {
                    _arvfeEdgeIn[i] = dctEdge[vfeKey];
                }
            }
        }
Beispiel #15
0
        public VfState(IGraphLoader loader1, IGraphLoader loader2, bool fIsomorphism, bool fContextCheck, bool fFindAll)
        {
            _ldr1 = loader1;
            _ldr2 = loader2;

            _fContextCheck = fContextCheck;
            _fFindAll      = fFindAll;

            if (fIsomorphism)
            {
                fnCmp = new FCompareDegreesDelegate(CmpIsomorphism);
            }
            else
            {
                fnCmp = new FCompareDegreesDelegate(CmpSubgraphIsomorphism);
            }

            // Salmon commend becuase never used.
            // _fIsomorphism = fIsomorphism;

            _armpInodVfInodGraph1 = new CmpNodeDegrees(loader1).Permutation;
            _armpInodVfInodGraph2 = new CmpNodeDegrees(loader2).Permutation;
            _vfgr1         = new VfGraph(loader1, _armpInodVfInodGraph1);
            _vfgr2         = new VfGraph(loader2, _armpInodVfInodGraph2);
            _arinodMap1To2 = new int[loader1.NodeCount];
            _arinodMap2To1 = new int[loader2.NodeCount];
            for (int i = 0; i < loader1.NodeCount; i++)
            {
                _arinodMap1To2[i] = map_Illegal;
                _lstDisconnected1.Add(i);
            }
            for (int i = 0; i < loader2.NodeCount; i++)
            {
                _arinodMap2To1[i] = map_Illegal;
                _lstDisconnected2.Add(i);
            }
        }
Beispiel #16
0
/*
 * //    void Load() {
 *  public void Load() {
 *      GraphLoader graphLoader = new GraphLoader(GRAPH_XML);
 *      states = graphLoader.LoadStateGraph();
 *  }
 */
    public void Load(IGraphLoader graphLoader)
    {
        states = graphLoader.LoadStateGraph();
    }
Beispiel #17
0
 public VfState(IGraphLoader loader1, IGraphLoader loader2, bool fIsomorphism, bool fContextCheck) : this(loader1, loader2, fIsomorphism, fContextCheck, false)
 {
 }
Beispiel #18
0
 public VfState(IGraphLoader loader1, IGraphLoader loader2, bool fIsomorphism) : this(loader1, loader2, fIsomorphism, false, false)
 {
 }
Beispiel #19
0
 public VfState(IGraphLoader loader1, IGraphLoader loader2) : this(loader1, loader2, false, false, false)
 {
 }
 internal CmpVertexDegrees(IGraphLoader <TV, TE> loader)
 {
     _loader = loader;
 }
Beispiel #21
0
 internal CmpNodeDegrees(IGraphLoader loader)
 {
     _loader = loader;
 }