Example #1
0
        static public void DeleteVertexByEdgeOnlyToVertex(IVertex baseVertex, IEdge edge)
        {
            IEdge e = FindEdgeByEdgeOnlyToVertex(baseVertex, edge);

            if (e != null)
            {
                baseVertex.DeleteEdge(e);
            }
        }
Example #2
0
        static public void DeleteVertexByEdgeTo(IVertex baseVertex, IVertex to)
        {
            IEdge e = FindEdgeByEdgeTo(baseVertex, to);

            if (e != null)
            {
                baseVertex.DeleteEdge(e);
            }
        }
Example #3
0
        static public void DeleteEdge(IVertex source, IVertex metaVertex, IVertex toVertex)
        {
            IEdge e = FindEdge(source, metaVertex, toVertex);

            if (e != null)
            {
                source.DeleteEdge(e);
            }
        }
Example #4
0
        static public void DeleteEdgeByMeta(IVertex source, string MetaValue)
        {
            IEdge e = FindEdgeByMetaValue(source, MetaValue);

            if (e != null)
            {
                source.DeleteEdge(e);
            }
        }
Example #5
0
        static public void DeleteEdgeByToVertex(IVertex source, IVertex toVertex)
        {
            IEdge e = FindEdgeByToVertex(source, toVertex);

            if (e != null)
            {
                source.DeleteEdge(e);
            }
        }
Example #6
0
        static public void RemoveAllEdges(IVertex v)
        {
            IList <IEdge> el = GeneralUtil.CreateAndCopyList <IEdge>(v);

            foreach (IEdge e in el)
            {
                v.DeleteEdge(e);
            }
        }
Example #7
0
        static public IEdge CreateOrReplaceEdge(IVertex Vertex, IVertex metaVertex, IVertex NewEdgeToVertex)
        {
            IEdge toReplace = FindEdgeByMetaVertex(Vertex, metaVertex);

            if (toReplace != null)
            {
                Vertex.DeleteEdge(toReplace);
            }

            return(Vertex.AddEdge(metaVertex, NewEdgeToVertex));
        }
Example #8
0
        static public IEdge ReplaceEdge(IVertex Vertex, IVertex metaVertex, IVertex NewEdgeToVertex)
        {
            IEdge toReplace = FindEdgeByMetaVertex(Vertex, metaVertex);

            if (toReplace == null)
            {
                throw new Exception("Vertex does not have edge of supplied Meta Vertex");
            }

            Vertex.DeleteEdge(toReplace);

            return(Vertex.AddEdge(toReplace.Meta, NewEdgeToVertex));
        }
Example #9
0
        static public IEdge ReplaceEdge(IVertex Vertex, string MetaValue, IVertex NewEdgeToVertex)
        {
            IEdge toReplace = FindEdgeByMetaValue(Vertex, MetaValue);

            if (toReplace == null)
            {
                throw new Exception("Vertex does not have \"" + MetaValue + "\" edge");
            }

            Vertex.DeleteEdge(toReplace);

            return(Vertex.AddEdge(toReplace.Meta, NewEdgeToVertex));
        }
Example #10
0
        static public IVertex ReplaceEdgeByValue(IVertex Vertex, string MetaValue, object VertexValue)
        {
            IEdge toReplace = FindEdgeByMetaValue(Vertex, MetaValue);

            if (toReplace == null)
            {
                throw new Exception("Vertex does not have \"" + MetaValue + "\" edge");
            }

            Vertex.DeleteEdge(toReplace);

            IVertex nv = Vertex.AddVertex(toReplace.Meta, VertexValue);

            return(nv);
        }
Example #11
0
        private bool testVertex(IVertex toTest, string query)
        {
            IVertex temp = MinusZero.Instance.CreateTempVertex();

            IEdge e = temp.AddEdge(null, toTest);

            IVertex res = temp.GetAll(query);

            temp.DeleteEdge(e);

            if (res.Count() > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #12
0
        static public void CopyAndReplaceEdge(IVertex baseVertex, string MetaValue, IVertex EdgeVertex)
        {
            IEdge toReplace = GraphUtil.FindEdgeByMetaValue(baseVertex, MetaValue);

            if (toReplace == null)
            {
                throw new Exception("Vertex does not have \"" + MetaValue + "\" edge");
            }

            baseVertex.DeleteEdge(toReplace);

            IVertex edge = baseVertex.AddVertex(toReplace.Meta, null);

            IVertex r = MinusZero.Instance.Root;

            edge.AddEdge(r.Get(@"System\Meta\ZeroTypes\Edge\From"), EdgeVertex.Get("From:"));
            edge.AddEdge(r.Get(@"System\Meta\ZeroTypes\Edge\Meta"), EdgeVertex.Get("Meta:"));
            edge.AddEdge(r.Get(@"System\Meta\ZeroTypes\Edge\To"), EdgeVertex.Get("To:"));
        }
Example #13
0
        static public void CreateEdgeAndCreateOrReplaceEdgeByMeta(IVertex baseVertex, IVertex metaVertex, IEdge Edge)
        {
            IEdge toReplace = GraphUtil.FindEdgeByMetaVertex(baseVertex, metaVertex);

            IVertex edge;

            if (toReplace == null)
            {
                edge = baseVertex.AddVertex(metaVertex, null);
            }
            else
            {
                baseVertex.DeleteEdge(toReplace);

                edge = baseVertex.AddVertex(toReplace.Meta, null);
            }

            IVertex r = MinusZero.Instance.Root;

            edge.AddEdge(r.Get(@"System\Meta\ZeroTypes\Edge\From"), Edge.From);
            edge.AddEdge(r.Get(@"System\Meta\ZeroTypes\Edge\Meta"), Edge.Meta);
            edge.AddEdge(r.Get(@"System\Meta\ZeroTypes\Edge\To"), Edge.To);
        }
Example #14
0
        static public IEdge ReplaceEdge(IVertex Vertex, IEdge toReplace, IVertex NewEdgeToVertex)
        {
            Vertex.DeleteEdge(toReplace);

            return(Vertex.AddEdge(toReplace.Meta, NewEdgeToVertex));
        }
Example #15
0
        void Parse_Reccurent(GOLD.Reduction reduction, IVertex v, List <IVertex> generatedVertexList)
        {
            IVertex current = v;

            for (int x = 0; x < reduction.Count(); x++)
            {
                if (reduction[x].Type() == GOLD.SymbolType.Nonterminal)
                {
                    GOLD.Reduction branch = (GOLD.Reduction)reduction[x].Data;

                    Parse_Reccurent(branch, current, generatedVertexList);
                }
                else
                {
                    string leaf = ParseLeaf((string)reduction[x].Data);

                    //IVertex def= langDef.Get("\"" + leaf + "\"");
                    IVertex def = GraphUtil.FindOneByValue(langDef, leaf);

                    if (def != null)
                    {
                        //if (def.Get("PreviousTerminalMoveDown:") != null)
                        if (GraphUtil.FindOneByMeta(def, "PreviousTerminalMoveDown") != null)
                        {
                            IEdge previousEdge = v.OutEdges.Last();

                            v.DeleteEdge(previousEdge);

                            current = v.AddVertex(def, leaf);

                            generatedVertexList.Add(current);

                            current.AddEdge(previousEdge.Meta, previousEdge.To);

                            // }else if(def.Get("MoveDownToPreviousContainerTerminalOrCretedEmpty:")!=null){
                        }
                        else if (GraphUtil.FindOneByMeta(def, "MoveDownToPreviousContainerTerminalOrCretedEmpty") != null)
                        {
                            IEdge previousEdge = v.OutEdges.LastOrDefault();

                            //if ((previousEdge!=null)&&((GeneralUtil.CompareStrings(previousEdge.Meta.Value,"$Empty"))||(previousEdge.Meta.Get("ContainerTerminal:")!=null)))
                            if (
                                ((previousEdge != null) && generatedVertexList.Contains(previousEdge.To)) && (
                                    ((GeneralUtil.CompareStrings(previousEdge.Meta.Value, "$Empty")) ||
                                     (GraphUtil.FindOneByMeta(previousEdge.Meta, "ContainerTerminal") != null))
                                    ))
                            {
                                IVertex previousVertex = previousEdge.To;

                                current = previousVertex.AddVertex(def, leaf);

                                generatedVertexList.Add(current);
                            }
                            else
                            {
                                //current = v.AddVertex(MetaTextLanguageParsedTree.Get("$EmptyContainerTerminal"), null);

                                current = v.AddVertex(GraphUtil.FindOneByValue(MetaTextLanguageParsedTree, "$EmptyContainerTerminal"), null);

                                generatedVertexList.Add(current);

                                current = current.AddVertex(def, leaf);
                            }
                        }
                        else
                        {
                            current = v.AddVertex(def, leaf);

                            generatedVertexList.Add(current);
                        }
                    }
                    else
                    {
                        current = v.AddVertex(def, leaf);

                        generatedVertexList.Add(current);
                    }
                }
            }
        }