Beispiel #1
0
        //key = val,.....
        private bool econdition(Dictionary<string,object>dic,wordtype[] logics)
        {
            int i=0;
            string name;
            object val=null;
            name = strArray[count];
            count++;
            if (strArray[count] == "=")
            {
                count++;
                val = valtype();
                logics[i] = wordtype.eql;
                i++;
            }
            if (strArray[count] == ">")
            {
                count++;
                if (strArray[count] == "=")
                {
                    count++;
                    val = valtype();
                    logics[0] = wordtype.aeql;
                    i++;
                }
                else
                {
                    val = valtype();
                    logics[0] = wordtype.above;
                    i++;
                }
            }
            if (strArray[count] == "<")
            {
                count++;
                if (strArray[count] == "=")
                {
                    count++;
                    val = valtype();
                    logics[0] = wordtype.beql;
                    i++;
                }
                else
                {
                    val = valtype();
                    logics[0] = wordtype.below;
                    i++;
                }
            }

            dic[name] = val;

            while (strArray[count] == ",")
            {
                count++;
                name = strArray[count];
                count++;
                if (strArray[count] == "=")
                {
                    count++;
                    val = valtype();
                    logics[i] = wordtype.eql;
                    i++;
                }
                if (strArray[count] == ">")
                {
                    count++;
                    if (strArray[count] == "=")
                    {
                        count++;
                        val = valtype();
                        logics[0] = wordtype.aeql;
                        i++;
                    }
                    else
                    {
                        val = valtype();
                        logics[0] = wordtype.above;
                        i++;
                    }
                }
                if (strArray[count] == "<")
                {
                    count++;
                    if (strArray[count] == "=")
                    {
                        count++;
                        val = valtype();
                        logics[0] = wordtype.beql;
                        i++;
                    }
                    else
                    {
                        val = valtype();
                        logics[0] = wordtype.below;
                        i++;
                    }
                }
                dic[name] = val;
            }
            if (strArray[count] == ")")
                return true;

            return false;
        }
Beispiel #2
0
 //根据v1,v2,edge的属性返回边
 private bool getedges(IEnumerable<IEdge> es, IVertex v1, IVertex v2, Dictionary<string,object>ckey,wordtype[] logic)
 {
     Func<IEdge, bool> aa=null;
     int i=0;
     foreach (var k in ckey.Keys)
     {
         switch (logic[i])
         {
             case wordtype.eql: aa = a => Convert.ToDouble(a[k]) == Convert.ToDouble(ckey[k]);
                 break;
             case wordtype.above: aa = a => Convert.ToDouble(a[k]) > Convert.ToDouble(ckey[k]);
                 break;
             case wordtype.below: aa = a => Convert.ToDouble(a[k]) < Convert.ToDouble(ckey[k]);
                 break;
             case wordtype.beql: aa = a => Convert.ToDouble(a[k]) <= Convert.ToDouble(ckey[k]);
                 break;
             case wordtype.aeql: aa = a => Convert.ToDouble(a[k]) >= Convert.ToDouble(ckey[k]);
                 break;
         }
         i++;
         es = gHelper.SelectEdges(k, ckey[k], v1, v2, null, es, aa);
     }
     return true;
 }
Beispiel #3
0
        //select edge语句
        private bool selectedge()
        {
            string v1type="",v2type="";
            object v1typeval=null,v2typeval=null;
            Dictionary<string, object>  v1 = new Dictionary<string, object>();
            Dictionary<string, object>  v2 = new Dictionary<string, object>();
            Dictionary<string, object>  con = new Dictionary<string, object>();
            wordtype[] lo=new wordtype[5];
            count++;

            _returns = new HashSet<Edge>();
            ReturnsType = _ReturnsType.Edge;
            if (strArray[count] == "(")
            {
                count++;
                if (verter_type_keyval(ref v1type, ref v1typeval, v1))
                {
                    if (strArray[count] == ",")
                    {
                        count++;
                        if (verter_type_keyval(ref v2type, ref v2typeval, v2))
                        {
                            IEnumerable<IVertex> v1s = new HashSet<IVertex>();
                            IEnumerable<IVertex> v2s = new HashSet<IVertex>();
                            if ((v1s=getvertexs(v1s, v1type, v1typeval, v1))!=null && (v2s=getvertexs(v2s, v2type, v2typeval, v2))!=null)
                            {
                                if (strArray[count] == ",")
                                {
                                    count++;
                                    if(econdition(con,lo))
                                    {
                                        foreach (var vsrc in v1s)
                                        {
                                            foreach (var vdest in v2s)
                                            {
                                                IEnumerable<IEdge> es = gHelper.SelectParallelEdges(vsrc, vdest);
                                                getedges(es, vsrc, vdest, con, lo);
                                                _returns = _returns.Concat(es);
                                            }
                                        }
                                    }
                                    else
                                        return false;
                                }
                                else
                                {
                                    foreach (var vsrc in v1s)
                                    {
                                        foreach (var vdest in v2s)
                                        {
                                            IEnumerable<IEdge> es = gHelper.SelectEdges(null, null, vsrc, vdest);
                                            _returns = _returns.Concat(es);
                                        }
                                    }

                                }
                                if (strArray[count] == ")")
                                {
                                    count++;
                                    return true;
                                }
                                else
                                    return false;
                            }
                            else
                                return false;
                        }
                        else
                            return false;
                    }
                    else
                        return false;
                }
                else
                    return false;
            }
            else
                return false;
        }