当前位置: 首页>>代码示例>>C#>>正文


C# IGraphDB.GetVertexType方法代码示例

本文整理汇总了C#中IGraphDB.GetVertexType方法的典型用法代码示例。如果您正苦于以下问题:C# IGraphDB.GetVertexType方法的具体用法?C# IGraphDB.GetVertexType怎么用?C# IGraphDB.GetVertexType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IGraphDB的用法示例。


在下文中一共展示了IGraphDB.GetVertexType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, TransactionToken myTransactionToken)
        {
            _query = myQuery;

            var vertexType = myGraphDB.GetVertexType<IVertexType>(
                mySecurityToken,
                myTransactionToken,
                new RequestGetVertexType(_typeName),
                (stats, vType) => vType);

            _WhereExpression.Validate(myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, vertexType);

            var expressionGraph = _WhereExpression.Calculon(myPluginManager, myGraphDB, mySecurityToken,
                                                            myTransactionToken,
                                                            new CommonUsageGraph(myGraphDB, mySecurityToken,
                                                                                 myTransactionToken));

            var toBeDeletedVertices =
                expressionGraph.Select(
                    new LevelKey(vertexType.ID, myGraphDB, mySecurityToken, myTransactionToken),
                    null, true);

            //TODO: do sth that is better than that: ew RequestDelete(new RequestGetVertices(_typeName, toBeDeletedVertices.Select(_ => _.VertexID))).
            return myGraphDB.Delete<QueryResult>(
                mySecurityToken,
                myTransactionToken,
                new RequestDelete(new RequestGetVertices(_typeName, toBeDeletedVertices.Select(_ => _.VertexID))).AddAttributes(_toBeDeletedAttributes),
                CreateQueryResult);
        }
开发者ID:loubo,项目名称:sones,代码行数:29,代码来源:DeleteNode.cs

示例2: LevelKey

        public LevelKey(IEnumerable<EdgeKey> myEdgeKey, IGraphDB myGraphDB, SecurityToken mySecurityToken, TransactionToken myTransactionToken)
        {
            Edges = new List<EdgeKey>();

            foreach (var aEdgeKey in myEdgeKey)
            {
                if (aEdgeKey.IsAttributeSet)
                {
                    var vertexType = myGraphDB.GetVertexType<IVertexType>
                        (mySecurityToken,
                        myTransactionToken,
                        new RequestGetVertexType(aEdgeKey.VertexTypeID),
                        (stats, type) => type);

                    var attribute = vertexType.GetAttributeDefinition(aEdgeKey.AttributeID);

                    if (attribute != null && attribute.Kind != AttributeType.Property)
                    {
                        //so there is an edge
                        Edges.Add(aEdgeKey);
                        Level++;

                        AddHashCodeFromSingleEdge(ref _hashcode, aEdgeKey);
                    }
                    else
                    {
                        if (Level == 0)
                        {
                            var newEdgeKey = new EdgeKey(aEdgeKey.VertexTypeID);
                            Edges.Add(newEdgeKey);

                            AddHashCodeFromSingleEdge(ref _hashcode, newEdgeKey);

                            break;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else
                {
                    if (Level == 0)
                    {
                        Edges.Add(aEdgeKey);

                        AddHashCodeFromSingleEdge(ref _hashcode, aEdgeKey);

                        break;
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }
开发者ID:loubo,项目名称:sones,代码行数:58,代码来源:LevelKey.cs

示例3: StringParser

        public List<TypeWithProperty> StringParser(String current_string, IGraphDB myDB, SecurityToken mySecurityToken, Int64 myTransactionToken)
        {
            current_string = current_string.Replace(" ","");

            List<TypeWithProperty> list = new List<TypeWithProperty>();
            bool endFlag = false;
            int EndPos = 0;

                do
                {

                    EndPos = current_string.IndexOf(',');
                    if (EndPos == -1)
                    {
                        EndPos = current_string.Length;
                        endFlag = true;
                    }

                    var typeVertexString = current_string.Substring(0, current_string.IndexOf('.'));


                    IVertexType typeVertex = null;

                    try
                    {

                        typeVertex = myDB.GetVertexType<IVertexType>(
                                                         mySecurityToken,
                                                         myTransactionToken,
                                                         new sones.GraphDB.Request.RequestGetVertexType(typeVertexString),
                                                         (statistics, type) => type);
                    }
                    catch
                    {
                        throw new InvalidFunctionParameterException("edgeType", "Object reference not set to an instance of an object.", "null");
                    }
                    var propertyIDString = current_string.Substring(current_string.IndexOf('.') + 1, EndPos - current_string.IndexOf('.') - 1);
                    var property = typeVertex.GetPropertyDefinition(propertyIDString);
                     if (property==null)
                         throw new InvalidFunctionParameterException("Property", "Property: " + propertyIDString + " not exist in VertexType:" + typeVertexString, "null");
                    TypeWithProperty value = new TypeWithProperty();
                    value.propertyDifinition = property;
                    value.type = typeVertex;

                    if (!list.Contains(value))
                        list.Add(value);

                    if (!endFlag)
                        current_string = current_string.Substring(EndPos + 1);

                }
                while (endFlag != true);
 
            return list;
        }
开发者ID:kuba85,项目名称:sones,代码行数:55,代码来源:TypeWithProperty.cs

示例4: GetResult

        /// <summary>
        /// <seealso cref=" ADescribeDefinition"/>
        /// </summary>
        public override QueryResult GetResult(GQLPluginManager myPluginManager,
            IGraphDB myGraphDB,
            SecurityToken mySecurityToken,
            TransactionToken myTransactionToken)
        {
            var resultingVertices = new List<IVertexView>();
            ASonesException error = null;

            if (!String.IsNullOrEmpty(_TypeName))
            {

                #region Specific type

                var request = new RequestGetVertexType(_TypeName);
                var type = myGraphDB.GetVertexType<IVertexType>(mySecurityToken, myTransactionToken, request, (stats, vertexType) => vertexType);

                if (type != null)
                {
                    resultingVertices = new List<IVertexView>() { (GenerateOutput(type, 1)) };
                }
                else
                {
                    error = new VertexTypeDoesNotExistException(_TypeName, "");
                }

                #endregion

            }
            else
            {

                #region All types

                foreach (var type in myGraphDB.GetAllVertexTypes<IEnumerable<IVertexType>>(mySecurityToken,
                                                                                            myTransactionToken,
                                                                                            new RequestGetAllVertexTypes(),
                                                                                            (stats, vertexTypes) => vertexTypes))
                {
                    resultingVertices.Add(GenerateOutput(type));
                }

                #endregion
            }

            if (error != null)
                return new QueryResult("", SonesGQLConstants.GQL, 0L, ResultType.Failed, resultingVertices, error);
            else
                return new QueryResult("", SonesGQLConstants.GQL, 0L, ResultType.Successful, resultingVertices);
        }
开发者ID:loubo,项目名称:sones,代码行数:52,代码来源:DescribeTypeDefinition.cs

示例5: GetResult

        /// <summary>
        /// <seealso cref=" ADescribeDefinition"/>
        /// </summary>
        public override IEnumerable<IVertexView> GetResult(GQLPluginManager myPluginManager,
                                                IGraphDB myGraphDB,
                                                SecurityToken mySecurityToken,
                                                Int64 myTransactionToken)
        {
            var resultingVertices = new List<IVertexView>();

            if (!String.IsNullOrEmpty(_TypeName))
            {

                #region Specific type

                var request = new RequestGetVertexType(_TypeName);
                var type = myGraphDB.GetVertexType<IVertexType>(mySecurityToken, myTransactionToken, request, (stats, vertexType) => vertexType);

                if (type != null)
                {
                    resultingVertices = new List<IVertexView>() { (GenerateOutput(type, 1)) };
                }
                else
                {
                    throw new VertexTypeDoesNotExistException(_TypeName, "");
                }

                #endregion

            }
            else
            {

                #region All types

                foreach (var type in myGraphDB.GetAllVertexTypes<IEnumerable<IVertexType>>(mySecurityToken,
                                                                                            myTransactionToken,
                                                                                            new RequestGetAllVertexTypes(),
                                                                                            (stats, vertexTypes) => vertexTypes))
                {
                    resultingVertices.Add(GenerateOutput(type));
                }

                #endregion
            }

            return resultingVertices;
        }
开发者ID:anukat2015,项目名称:sones,代码行数:48,代码来源:DescribeTypeDefinition.cs

示例6: Execute

        public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken)
        {
            _query = myQuery;

            //prepare
            var vertexType = myGraphDB.GetVertexType<IVertexType>(
                mySecurityToken,
                myTransactionToken,
                new RequestGetVertexType(_TypeName),
                (stats, vtype) => vtype);

            //validate
            _whereExpression.Validate(myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, vertexType);

            //calculate
            var expressionGraph = _whereExpression.Calculon(myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, new CommonUsageGraph(myGraphDB, mySecurityToken, myTransactionToken), false);

            //extract
            var myToBeUpdatedVertices = expressionGraph.Select(new LevelKey(vertexType.ID, myGraphDB, mySecurityToken, myTransactionToken), null, true).ToList();

            switch (myToBeUpdatedVertices.Count)
            {
                case 0:
                    //insert
                    throw new ReplaceException("There are no vertices that match the where expression, so it's not possible to execute a Replace statement. Try using InsertOrUpdate.");

                case 1:
                    //delete
                    ProcessDelete(myToBeUpdatedVertices[0], myGraphDB, myPluginManager, mySecurityToken, myTransactionToken);

                    //insert
                    return ProcessInsert(myGraphDB, myPluginManager, mySecurityToken, myTransactionToken);

                default:
                    //error
                    throw new NotImplementedQLException("It's currenty not implemented to InsertOrReplace more than one vertex");
            }
        }
开发者ID:ramz,项目名称:sones,代码行数:38,代码来源:ReplaceNode.cs

示例7: FindShortPathToAll

        /// <summary>
        /// Algorithm Dijkstra for find all shortest path from start Vertex to all others Vertices 
        /// </summary>
        /// <param name="myAttributeDefinition"></param>
        /// <param name="myCallingObject"></param>
        /// <param name="myStartVertex"></param>
        /// <param name="myGraphDB"></param>
        /// <param name="maxDepth"></param>
        /// <param name="mySecurityToken"></param>
        /// <param name="myTransactionToken"></param>
        /// <returns></returns>
        private Tuple<IVertex, DataDijkstra> FindShortPathToAll(IAttributeDefinition myAttributeDefinition,
                                                Object myCallingObject,
                                                IVertex myStartVertex,
                                                IGraphDB myGraphDB,
                                                UInt64 maxDepth,
                                                SecurityToken mySecurityToken,
                                                Int64 myTransactionToken)
        {
            if (myStartVertex == null)
                throw new InvalidFunctionParameterException("StartVertex", "Vertex that represents the start vertex", "null");

            //set the start node
            var currentVertex = myStartVertex;

            var myType = myGraphDB.GetVertexType<IVertexType>(mySecurityToken,
                                                     myTransactionToken,
                                                     new sones.GraphDB.Request.RequestGetVertexType(myAttributeDefinition.RelatedType.Name),
                                                     (statistics, type) => type);

            var myEdgeType = myAttributeDefinition.ID;

            var hasProperty = myType.GetOutgoingEdgeDefinition(myAttributeDefinition.Name).InnerEdgeType.HasProperty("Weight");

            long myPropertyID = 0;

            if (hasProperty == true)
            {
                myPropertyID = myType.GetOutgoingEdgeDefinition(myAttributeDefinition.Name).InnerEdgeType.GetPropertyDefinition("Weight").ID;
            }

            var edgeTypeDifinition = myType.GetOutgoingEdgeDefinition(myAttributeDefinition.Name);

            DataDijkstra lists = new DataDijkstra();
            BufferDijkstra buffer = new BufferDijkstra();

            buffer.Add(myStartVertex, 0, 0);
            lists.Add(currentVertex, 0, 0, null,null, currentVertex);

            double currentVertexDistance = 0;
            ulong currentVertexDepth = 0;

            while (buffer.Count != 0)
            {
                if (currentVertexDepth < maxDepth)
                {
                    var hyperEdge = currentVertex.GetOutgoingHyperEdge(myEdgeType);

                    if (hyperEdge != null)
                    {
                        var singleEdge = hyperEdge.GetAllEdges();

                        for (int iCount = 0; iCount < singleEdge.Count(); iCount++)
                        {

                            var TargetVertex = singleEdge.ElementAt(iCount).GetTargetVertex();

                            double current_distance;

                            if (hasProperty == true)
                            {

                                current_distance = Math.Abs(singleEdge.ElementAt(iCount).GetProperty<double>(myPropertyID));

                            }
                            else
                            {
                                current_distance = 1;
                            }

                            var current_singleEdge = singleEdge.ElementAt(iCount);

                            var TargetVertexID = lists.GetElement(TargetVertex.VertexID);

                            if (TargetVertexID == null)
                            {

                                buffer.Add(TargetVertex,
                                         current_distance + currentVertexDistance,
                                        currentVertexDepth + 1);

                                lists.Add(TargetVertex,
                                    current_distance + currentVertexDistance,
                                    currentVertexDepth + 1,
                                    current_singleEdge,
                                    edgeTypeDifinition,
                                    currentVertex);
                            }
                            else
                            {
//.........这里部分代码省略.........
开发者ID:anukat2015,项目名称:sones,代码行数:101,代码来源:Dijkstra.cs

示例8: Helper

        private void Helper(IGraphDB graph, SecurityToken sec, Int64 trans, List<TypeWithProperty> type_property_object, List<Tuple<long, long>> PATHShort)	
        {
           List<Tuple<String, String>> output = new List<Tuple<string, string>>();
		   this._stringPath.Clear();
		   var StartTypeLong =  PATHShort.Find(x => x.Item2 == 0);
		   var StartType = graph.GetVertexType(sec,
												trans, 
												new sones.GraphDB.Request.RequestGetVertexType(StartTypeLong.Item1),
													 (statistics, type) => type);

           this._stringPath.Add(Tuple.Create("Starting VertexType for SELECT", StartType.Name));
			

		   String str = StartType.Name;

		   foreach (TypeWithProperty value in type_property_object.Where(x => x.Type.ID == StartType.ID))
			   this._stringPath.Add(Tuple.Create(StartType.Name + '.' + value.PropertyDefinition.Name,StartType.Name + '.' + value.PropertyDefinition.Name));
			
		   Recurs(str, StartType, type_property_object, PATHShort);

		}
开发者ID:anukat2015,项目名称:sones,代码行数:21,代码来源:TypesConnect.cs

示例9: GetBackwardEdgeKey

        protected EdgeKey GetBackwardEdgeKey(LevelKey myPath, int desiredBELevel, IGraphDB myGraphDB, SecurityToken mySecurityToken, Int64 myTransactionToken)
        {
            #region data

            IVertexType tempType;
            IAttributeDefinition tempAttr;

            #endregion

            tempType = myGraphDB.GetVertexType<IVertexType>(
                mySecurityToken, 
                myTransactionToken,
                new RequestGetVertexType(myPath.Edges[desiredBELevel].VertexTypeID), 
                (stats, vertexType) => vertexType);
            
            tempAttr = tempType.GetAttributeDefinition(myPath.Edges[desiredBELevel].AttributeID);

            if (tempAttr.Kind != AttributeType.IncomingEdge)
            {
                return new EdgeKey(tempType.ID, tempAttr.ID);
            }
            else
            {
                IIncomingEdgeDefinition incomingEdgeDefinition = tempAttr as IIncomingEdgeDefinition;

                return new EdgeKey(incomingEdgeDefinition.RelatedEdgeDefinition.SourceVertexType.ID, incomingEdgeDefinition.RelatedEdgeDefinition.ID);
            }
        }
开发者ID:anukat2015,项目名称:sones,代码行数:28,代码来源:AExpressionGraph.cs

示例10: Execute

        public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, TransactionToken myTransactionToken)
        {
            var sw = Stopwatch.StartNew();

            _query = myQuery;

            //prepare
            var vertexTypeSource = myGraphDB.GetVertexType<IVertexType>(
                mySecurityToken,
                myTransactionToken,
                new RequestGetVertexType(_SourceType),
                (stats, vtype) => vtype);

            var vertexTypeTarget = myGraphDB.GetVertexType<IVertexType>(
                mySecurityToken,
                myTransactionToken,
                new RequestGetVertexType(_TargetType),
                (stats, vtype) => vtype);

            //validate
            _Condition.Validate(myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, vertexTypeSource);

            //calculate
            var expressionGraph = _Condition.Calculon(myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, new CommonUsageGraph(myGraphDB, mySecurityToken, myTransactionToken), false);

            //extract
            var myToBeUpdatedVertices = expressionGraph.Select(new LevelKey(vertexTypeSource.ID, myGraphDB, mySecurityToken, myTransactionToken), null, true).ToList();

            if (myToBeUpdatedVertices.Count > 0)
            {

                //update
                ProcessUpdate(myToBeUpdatedVertices, myGraphDB, myPluginManager, mySecurityToken, myTransactionToken);

            }

            sw.Stop();

            return GenerateResult(sw.Elapsed.TotalMilliseconds);
        }
开发者ID:loubo,项目名称:sones,代码行数:40,代码来源:UnlinkNode.cs

示例11: AddVertexTypeAndAttributesRecursivly

        private void AddVertexTypeAndAttributesRecursivly(IGraphDB myGraphDB, 
            SecurityToken mySecurityToken,
            Int64 myTransactionToken,
            IVertexType type,
            ref HashSet<IVertexType> types)
        {
            if (!type.IsUserDefined) return;

            if (type.HasParentType)
            {
                if (!types.Contains(type.ParentVertexType))
                {
                    types.Add(type.ParentVertexType);

                    foreach (var attr in (type.GetAttributeDefinitions(false)).Where(attrDef => attrDef.Kind == AttributeType.Property))
                    {
                        var attrType = myGraphDB.GetVertexType<IVertexType>(mySecurityToken,
                                                                            myTransactionToken,
                                                                            new RequestGetVertexType(attr.ID),
                                                                            (stats, vertex) => vertex);

                        AddVertexTypeAndAttributesRecursivly(myGraphDB,
                                                                mySecurityToken,
                                                                myTransactionToken,
                                                                attrType,
                                                                ref types);
                    }
                }
            }
        }
开发者ID:anukat2015,项目名称:sones,代码行数:30,代码来源:GraphDBExport_GQL.cs

示例12: Execute

        public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, TransactionToken myTransactionToken)
        {
            Stopwatch sw = Stopwatch.StartNew();

            _query = myQuery;
            QueryResult result = null;
            String myAction = "";
            List<IVertex> myToBeUpdatedVertices = new List<IVertex>();

            //prepare
            var vertexType = myGraphDB.GetVertexType<IVertexType>(
                mySecurityToken,
                myTransactionToken,
                new RequestGetVertexType(_type),
                (stats, vtype) => vtype);

            if (_whereExpression != null)
            {
                //validate
                _whereExpression.Validate(myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, vertexType);

                //calculate
                var expressionGraph = _whereExpression.Calculon(myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, new CommonUsageGraph(myGraphDB, mySecurityToken, myTransactionToken), false);

                //extract
                myToBeUpdatedVertices = expressionGraph.Select(new LevelKey(vertexType.ID, myGraphDB, mySecurityToken, myTransactionToken), null, true).ToList();
            }

            switch (myToBeUpdatedVertices.Count)
            {
                case 0:

                    //insert
                    result = ProcessInsert(myGraphDB, myPluginManager, mySecurityToken, myTransactionToken);

                    myAction = "Inserted";

                    break;

                case 1:

                    //delete
                    ProcessDelete(myToBeUpdatedVertices[0], myGraphDB, myPluginManager, mySecurityToken, myTransactionToken);

                    //insert
                    result = ProcessInsert(myGraphDB, myPluginManager, mySecurityToken, myTransactionToken);

                    myAction = "Replaced";

                    break;

                default:
                    //error
                    throw new NotImplementedQLException("It's currenty not implemented to InsertOrReplace more than one vertex");
            }

            if (result.Error != null)
                throw result.Error;

            return GenerateResult(sw.ElapsedMilliseconds, result, myAction);
        }
开发者ID:loubo,项目名称:sones,代码行数:61,代码来源:InsertOrReplaceNode.cs

示例13: ExecFunc

        public override FuncParameter ExecFunc(IAttributeDefinition myAttributeDefinition,
            Object myCallingObject,
            IVertex myStartVertex,
            IGraphDB myGraphDB,
            SecurityToken mySecurityToken,
            Int64 myTransactionToken,
            params FuncParameter[] myParams)
        {
            #region initialize data

            var graph = myGraphDB;

            // The edge we starting of (e.g. Friends)
            var typeAttribute = myAttributeDefinition;

            if (myStartVertex == null)
                throw new InvalidFunctionParameterException("StartVertex", "Vertex that represents the start vertex", "null");

            //set the start node
            var startNode = myStartVertex;

            if ((myParams[0].Value as IEnumerable<IVertex>) == null)
                throw new InvalidFunctionParameterException("TargetVertex", "Set of vertices that represents the target vertices", "null");

            //set the target node
            var targetNode = (myParams[0].Value as IEnumerable<IVertex>).First();

            //set the maximum depth
            UInt64 maxDepth = Convert.ToUInt64(myParams[1].Value);

            //set the maximum path length
            UInt64 maxPathLength = Convert.ToUInt64(myParams[2].Value);

            //mark if only the shortest path should be searched
            bool onlyShortestPath = Convert.ToBoolean(myParams[3].Value);

            //mark if all paths should be searched
            bool allPaths = Convert.ToBoolean(myParams[4].Value);

            if (!onlyShortestPath && !allPaths)
            {
                allPaths = true;
            }

            bool useBidirectionalBFS = false;

            if(myParams.GetLength(0) == 6)
                //mark if the BidirectionalBFS should be used
                useBidirectionalBFS = Convert.ToBoolean(myParams[5].Value);

            var vertexType = myGraphDB.GetVertexType<IVertexType>(mySecurityToken,
                                                                    myTransactionToken,
                                                                    new RequestGetVertexType(startNode.VertexTypeID),
                                                                    (stats, type) => type);

            if (vertexType == null)
                throw new InvalidFunctionParameterException("StartVertexType",
                                                            "VertexType that represents the start vertex type not found",
                                                            startNode.VertexTypeID);
            #endregion

            #region check correctness of parameters

            //check if values are correct
            if (maxDepth < 1)
                throw new InvalidFunctionParameterException("maxDepth", ">= 1", maxDepth.ToString());

            if (maxPathLength < 2)
                throw new InvalidFunctionParameterException("maxPathLength", ">= 2", maxPathLength.ToString());

            #endregion

            #region call graph function

            HashSet<List<Tuple<long, long>>> paths = null;

            //call BFS find methods
            if (useBidirectionalBFS)
                paths = new BidirectionalBFS().Find(typeAttribute,
                                                    vertexType,
                                                    startNode,
                                                    targetNode,
                                                    onlyShortestPath,
                                                    allPaths,
                                                    maxDepth, maxPathLength);
            else
                paths = new BFS().Find(typeAttribute,
                                        vertexType,
                                        startNode,
                                        targetNode,
                                        onlyShortestPath,
                                        allPaths,
                                        maxDepth,
                                        maxPathLength);

            #endregion

            #region create output

            if (paths != null)
//.........这里部分代码省略.........
开发者ID:anukat2015,项目名称:sones,代码行数:101,代码来源:PathFunc.cs

示例14: GetVertexTypes

        private IEnumerable<IVertexType> GetVertexTypes(IGraphDB myGraphDB, 
            SecurityToken mySecurityToken,
            Int64 myTransactionToken,
            IEnumerable<String> myTypes)
        {
            #region GetTypeToDump

            IEnumerable<IVertexType> typesToDump = new List<IVertexType>();

            if (myTypes.IsNullOrEmpty())
                typesToDump = myGraphDB.GetAllVertexTypes(mySecurityToken,
                                                            myTransactionToken,
                                                            new RequestGetAllVertexTypes(),
                                                            (stats, vertexTypes) => vertexTypes)
                                        .Where(_ => _.IsUserDefined);
            else
            {
                var typesToDumpHash = new HashSet<IVertexType>();

                foreach (var stringType in myTypes)
                {
                    var type = myGraphDB.GetVertexType(mySecurityToken,
                                                        myTransactionToken,
                                                        new RequestGetVertexType(stringType),
                                                        (stats, vertexType) => vertexType);

                    if (type == null)
                        throw new TypeDoesNotExistException(stringType, "");

                    //typesToDumpHash.UnionWith(myDBContext.DBTypeManager.GetAllParentTypes(type, true, false));
                    AddVertexTypeAndAttributesRecursivly(myGraphDB,
                                                            mySecurityToken,
                                                            myTransactionToken,
                                                            type,
                                                            ref typesToDumpHash);
                }

                typesToDump = typesToDumpHash.ToList();
            }

            #endregion

            return typesToDump;
        }
开发者ID:anukat2015,项目名称:sones,代码行数:44,代码来源:GraphDBExport_GQL.cs

示例15: ExecFunc

        public override FuncParameter ExecFunc(IAttributeDefinition myAttributeDefinition,
                                                Object myCallingObject,
                                                IVertex myStartVertex,
                                                IGraphDB myGraphDB,
                                                SecurityToken mySecurityToken,
                                                Int64 myTransactionToken,
                                                params FuncParameter[] myParams)
        {
            #region initialization
            if (myStartVertex == null)
                throw new InvalidFunctionParameterException("StartVertex", "Vertex that represents the start vertex", "null");

            //set the start node
            var currentVertex = myStartVertex;

            if ((myParams[0].Value as IEnumerable<IVertex>).First() == null)
                throw new InvalidFunctionParameterException("EndVertex", "Set of vertices that represents the target vertices", "null");

            //set the target node
            var endVertex = (myParams[0].Value as IEnumerable<IVertex>).First();

            //set the maximum depth

            if (myAttributeDefinition == null)
                throw new InvalidFunctionParameterException("EdgeType ", "Edge type not found", "faild");

            UInt64 maxDepth = Convert.ToUInt64(myParams[1].Value);

            if (maxDepth < 1)
                throw new InvalidFunctionParameterException("MaxDepth", "Max depth to low", maxDepth.ToString());

            var myType = myGraphDB.GetVertexType<IVertexType>(
                                                      mySecurityToken,
                                                      myTransactionToken,
                                                      new sones.GraphDB.Request.RequestGetVertexType(myAttributeDefinition.RelatedType.Name),
                                                      (statistics, type) => type);

               var myEdgeType = myAttributeDefinition.ID;

            var hasProperty = myType.GetOutgoingEdgeDefinition(myAttributeDefinition.Name).InnerEdgeType.HasProperty("Weight");

            long myPropertyID = 0;

            if (hasProperty == true)
            {
                myPropertyID = myType.GetOutgoingEdgeDefinition(myAttributeDefinition.Name).InnerEdgeType.GetPropertyDefinition("Weight").ID;
            }

            Dictionary<IOutgoingEdgeDefinition, Tuple<bool, long>> edgeTypeID = new Dictionary<IOutgoingEdgeDefinition, Tuple<bool, long>>();

            var edgeType = myParams[2].Value.ToString();

            if (edgeType == "")
            {
                edgeTypeID.Add(myType.GetOutgoingEdgeDefinition(myAttributeDefinition.Name), Tuple.Create(hasProperty, myPropertyID));
            }
            else
            {
                if (edgeType.Contains("all edgeType"))
                {
                    edgeTypeID = this.AllEdgeWithTargetVertex(myType);
                }
                else
                {
                   edgeTypeID = this.StringParser(edgeType, myType);
                    if (!edgeTypeID.ContainsKey(myType.GetOutgoingEdgeDefinition(myAttributeDefinition.Name)))
                   edgeTypeID.Add(myType.GetOutgoingEdgeDefinition(myAttributeDefinition.Name), Tuple.Create(hasProperty, myPropertyID));

                }

            }

            List<UInt64> depthBuffer = new List<UInt64>();

            List<Tuple<ISingleEdge, IOutgoingEdgeDefinition>> edgeBuffer = new List<Tuple<ISingleEdge, IOutgoingEdgeDefinition>>();

            List<double> distanceBuffer = new List<double>();
            List<IVertex> VertexBuffer = new List<IVertex>();

            BufferDijkstra buf = new BufferDijkstra();
            DataDijkstra lists = new DataDijkstra();

            buf.Add(myStartVertex, 0, 0);
            lists.Add(currentVertex, 0, 0, null,null, currentVertex);

            bool endVertexFlag = false;

            #endregion
            #region Dijkstra algorithm

            double currentVertexDistance = 0;
            ulong currentVertexDepth = 0;

            double endVertexDistance = 0;
            ulong endvertexDepth = 0;

            Stopwatch clock = new Stopwatch();
            clock.Start();

            while (buf.Count != 0)
//.........这里部分代码省略.........
开发者ID:anukat2015,项目名称:sones,代码行数:101,代码来源:Dijkstra.cs


注:本文中的IGraphDB.GetVertexType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。