public void BreadthFirstSearchEnumeratorTestCase1()
        {
            var expectedOutputSequence = "1, 2, 3, 4, 5, 6, 7, 8, ";
            var graph = new GraphCollection <int, int>(false);

            for (int i = 1; i < 9; i++)
            {
                graph.AddNode(i);
            }

            graph.AddEdge(1, 2);
            graph.AddEdge(1, 3);
            graph.AddEdge(2, 4);
            graph.AddEdge(3, 4);
            graph.AddEdge(4, 5);
            graph.AddEdge(5, 6);
            graph.AddEdge(5, 7);
            graph.AddEdge(5, 8);

            var iterator = new BreadthFirstSearchEnumerator <int, int>(graph);

            var actualOutputSequence = new StringBuilder();

            while (iterator.MoveNext())
            {
                actualOutputSequence.Append($"{iterator.Current.Data}, ");
            }

            Assert.AreEqual(expectedOutputSequence, actualOutputSequence.ToString(), "DFS output sequence not as expected.");
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="QueryOperation" /> class.
 /// </summary>
 /// <param name="node">The node.</param>
 /// <param name="operationType">Type of the operation being represented.</param>
 /// <param name="operationGraphType">The graph type representing the operation type.</param>
 public QueryOperation(OperationTypeNode node, GraphCollection operationType, IObjectGraphType operationGraphType)
 {
     this.Node          = Validation.ThrowIfNullOrReturn(node, nameof(node));
     this.OperationType = operationType;
     this.GraphType     = Validation.ThrowIfNullOrReturn(operationGraphType, nameof(operationGraphType));
     this.Name          = this.Node.OperationName.IsEmpty ? string.Empty : node.OperationName.ToString();
 }
        /// <summary>
        /// Converts the value into its equivilant routing constant.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <returns>System.String.</returns>
        public static string ToRouteRoot(this GraphCollection value)
        {
            switch (value)
            {
            case GraphCollection.Query:
                return(RouteConstants.QUERY_ROOT);

            case GraphCollection.Mutation:
                return(RouteConstants.MUTATION_ROOT);

            case GraphCollection.Subscription:
                return(RouteConstants.SUBSCRIPTION_ROOT);

            case GraphCollection.Types:
                return(RouteConstants.TYPE_ROOT);

            case GraphCollection.Enums:
                return(RouteConstants.ENUM_ROOT);

            case GraphCollection.Directives:
                return(RouteConstants.DIRECTIVE_ROOT);

            default:
                return(RouteConstants.NOOP_ROOT);
            }
        }
Пример #4
0
        public void Join_WithRoot_JoinsAsExpected(GraphCollection root, string leftSide, string rightSide, string expectedOutput)
        {
            // standard join
            var fragment = GraphFieldPath.Join(root, leftSide, rightSide);

            Assert.AreEqual(expectedOutput, fragment);
        }
Пример #5
0
        public void Destructuring(
            string rawPath,
            string expectedPath,
            bool expectedValidState,
            GraphCollection expectedRoot,
            string expectedName,
            bool shouldHaveParent,
            string expectedParentPath)
        {
            var route = new GraphFieldPath(rawPath);

            // valid path should be untouched
            Assert.AreEqual(expectedValidState, route.IsValid);
            Assert.AreEqual(rawPath, route.Raw);
            Assert.AreEqual(expectedPath, route.Path);
            Assert.AreEqual(expectedRoot, route.RootCollection);
            Assert.AreEqual(expectedName, route.Name);

            if (!shouldHaveParent)
            {
                Assert.IsNull(route.Parent);
            }
            else
            {
                Assert.IsNotNull(route.Parent);
                Assert.AreEqual(expectedParentPath, route.Parent.Path);
            }
        }
Пример #6
0
        public GraphCollection GetRealData([FromBody] List <Criterias> criteria)
        {
            string userRestriction = Flexi.WebUI.Utility.UserRestriction.GetUserRestriction(User.Identity.GetUserName(), "SalesChart");

            GraphCollection gc = GetDataFromDb(criteria, userRestriction);

            //gc.SDM = LoadSummary(criteria,userRestriction);
            return(gc);
        }
Пример #7
0
            /// <summary>
            /// Inspects the known operation types for a name matching the provided value returning it when found.
            /// </summary>
            /// <param name="operationType">Type of the operation to retrieve the graph type name for.</param>
            /// <returns>GraphCollection.</returns>
            public static string FindOperationTypeNameByType(GraphCollection operationType)
            {
                if (GRAPH_OPERATION_TYPE_NAME_BY_TYPE.ContainsKey(operationType))
                {
                    return(GRAPH_OPERATION_TYPE_NAME_BY_TYPE[operationType]);
                }

                return(string.Empty);
            }
Пример #8
0
        private void Save()
        {
            int count = GraphCollection.Count;

            if (IdState < GraphCollection.Count)
            {
                for (int i = 0; i < count - IdState; i++)
                {
                    GraphCollection.Remove(GraphCollection.Last());
                }
            }
            IdState++;
            GraphCollection.Add(new Graph
            {
                Vertexes = new ObservableCollection <Vertex>(),
                Edges    = new ObservableCollection <Edge>()
            });
            foreach (var v in Graph.Vertexes)
            {
                GraphCollection.Last().Vertexes.Add(new Vertex
                {
                    IsMouseRightButtonDown = v.IsMouseRightButtonDown,
                    IsMouseLeftButtonDown  = v.IsMouseLeftButtonDown,

                    IdVertex          = v.IdVertex,
                    Position          = v.Position,
                    Path              = v.Path,
                    Margin            = v.Margin,
                    ConnectedVertexes = new List <Vertex>(),
                    ConnectedEdges    = new List <Edge>()
                });
                foreach (var conver in v.ConnectedVertexes)
                {
                    GraphCollection.Last().Vertexes.Last().ConnectedVertexes.Add(new Vertex
                    {
                        IsMouseRightButtonDown = conver.IsMouseRightButtonDown,
                        IsMouseLeftButtonDown  = conver.IsMouseLeftButtonDown,
                        IdVertex = conver.IdVertex,
                        Position = conver.Position,
                        Path     = conver.Path,
                        Margin   = conver.Margin
                    });
                }
                foreach (var coned in v.ConnectedEdges)
                {
                    GraphCollection.Last().Edges.Add(new Edge
                    {
                        StartPoint            = coned.StartPoint,
                        EndPoint              = coned.EndPoint,
                        EndVertexId           = coned.EndVertexId,
                        IdEdge                = coned.IdEdge,
                        IsMouseLeftButtonDown = coned.IsMouseLeftButtonDown,
                        StartVertexId         = coned.StartVertexId
                    });
                }
            }
        }
        public void GraphCollectionBasic3()
        {
            GraphCollection collection = new GraphCollection();
            Graph           g          = new Graph();

            collection.Add(g, true);

            Assert.IsTrue(collection.Contains(g.BaseUri));
        }
Пример #10
0
        private void InitGraph()
        {
            GraphCollection tempCollection = new GraphCollection();

            tempCollection.CompressionRateIndex = 1;
            tempCollection.CompressionValue     = 1;
            tempCollection.GraphColumns         = 1;
            graphCollection = tempCollection;
            graphCollection.OnCompressionRateIndexChanged += OnCompressionRateIndexChanged;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="GraphFieldAttribute" /> class.
 /// </summary>
 /// <param name="isRootFragment">if set to <c>true</c> this instance represents a a path from its assigned graph root.</param>
 /// <param name="fieldType">The top level schema type this declared field should be assigned to.</param>
 /// <param name="template">The template naming scheme to use to generate a graph field from this method.</param>
 /// <param name="unionTypeName">Name of the union type if one is to be created, null otherwise.</param>
 /// <param name="typeSet">A collection of types that, depending on other parameters will be used to generate a union
 /// or just setup the field.</param>
 protected GraphFieldAttribute(
     bool isRootFragment,
     GraphCollection fieldType,
     string template,
     string unionTypeName,
     params Type[] typeSet)
     : this(isRootFragment, fieldType, template, typeSet)
 {
     this.UnionTypeName = unionTypeName?.Trim();
 }
Пример #12
0
 /// <summary>
 /// Ensures that the root operation type (query, mutation etc.) exists on this schema and the associated virtual
 /// type representing it also exists in the schema's type collection.
 /// </summary>
 /// <param name="operationType">Type of the operation.</param>
 private void EnsureGraphOperationType(GraphCollection operationType)
 {
     if (!this.Schema.OperationTypes.ContainsKey(operationType))
     {
         var name      = _formatter.FormatGraphTypeName(operationType.ToString());
         var operation = new GraphOperation(operationType, name);
         this.Schema.KnownTypes.EnsureGraphType(operation);
         this.Schema.OperationTypes.Add(operation.OperationType, operation);
     }
 }
Пример #13
0
 /// <summary>
 /// Generates a "top level" source data representing the operation root under which a field
 /// context should be executed.
 /// </summary>
 /// <param name="operationType">Type of the operation.</param>
 /// <returns>System.Object.</returns>
 private object GenerateRootSourceData(GraphCollection operationType)
 {
     if (_schema.OperationTypes.TryGetValue(operationType, out var rootOperation))
     {
         return(new VirtualResolvedObject(rootOperation.Name));
     }
     else
     {
         return(new object());
     }
 }
        public DepthFirstSearchEnumerator(GraphCollection <TData, TWeight> graph, bool leftToRight = false)
        {
            if (graph == null)
            {
                throw new ArgumentNullException(nameof(graph));
            }

            this.Graph = graph;

            this.LeftToRight = leftToRight;

            Reset();
        }
Пример #15
0
        public static GraphCollection GetChartDataForDashboard()
        {
            GraphCollection gc   = new GraphCollection();
            var             list = new List <Graph>();

            list.Add(GetTokyoData());
            list.Add(GetLondonData());
            list.Add(GetBerlinData());
            //list.Add(GetNewYorkData());
            gc.GraphList = list;

            return(gc);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="GraphFieldAttribute" /> class.
 /// </summary>
 /// <param name="isRootFragment">if set to <c>true</c> this instance represents a a path from its assigned graph root.</param>
 /// <param name="fieldType">The top level schema type this declared field should be assigned to.</param>
 /// <param name="template">The template naming scheme to use to generate a graph field from this method.</param>
 /// <param name="typeSet">A collection of types that, depending on other parameters will be used to generate a union
 /// or just setup the field.</param>
 protected GraphFieldAttribute(
     bool isRootFragment,
     GraphCollection fieldType,
     string template,
     params Type[] typeSet)
 {
     this.IsRootFragment = isRootFragment;
     this.FieldType      = fieldType;
     this.Template       = template?.Trim();
     this.UnionTypeName  = null;
     this.Types          = new List <Type>(typeSet?.Where(x => x != null) ?? Enumerable.Empty <Type>());
     this.Complexity     = 1;
 }
Пример #17
0
        private void OpenWindowLoadGraph(object obj)
        {
            Graph = new Graph();
            LoadGraphViewModel loadGraphViewModel = new LoadGraphViewModel(Graph);
            var winLoad = new LoadGraphWindow(loadGraphViewModel);

            loadGraphViewModel.Window = winLoad;
            winLoad.ShowDialog();
            if (loadGraphViewModel.ReadTo)
            {
                GraphCollection.Add(Graph);
                AddToObjectCompositeCollection();
            }
        }
Пример #18
0
        private void OpenWindowRandom(object obj)
        {
            Graph = new Graph();
            RandomWindowViewModel randomViewModel = new RandomWindowViewModel(Graph, 400, 400);
            var winRandom = new RandomWindow(randomViewModel);

            randomViewModel.Window = winRandom;
            winRandom.ShowDialog();
            if (randomViewModel.ReadTo)
            {
                GraphCollection.Add(Graph);
                AddToObjectCompositeCollection();
            }
        }
Пример #19
0
        private IEnumerable <T> Enumerate <T>(string url)
        {
            string nextUrl = url;

            while (!string.IsNullOrEmpty(nextUrl))
            {
                GraphCollection <T> results = this.Get <GraphCollection <T> >(nextUrl);
                foreach (T result in results.Value)
                {
                    yield return(result);
                }

                nextUrl = results.ODataNextLink;
            }
        }
Пример #20
0
        private void OpenWindowPrufer(object obj)
        {
            Graph = new Graph();
            PruferWindowViewModel pruferViewModel = new PruferWindowViewModel(Graph, 400, 400);
            var winPrufer = new PruferWindow(pruferViewModel);

            pruferViewModel.Window = winPrufer;
            winPrufer.ShowDialog();

            if (pruferViewModel.ReadTo)
            {
                GraphCollection.Add(Graph);
                AddToObjectCompositeCollection();
            }
        }
Пример #21
0
            static public GraphCollection CreateNewGraphCollection(string suggestedName)
            {
                string nameCandidate = suggestedName;

                var collection = BatchBuildConfig.GetConfig().GraphCollections;
                int i          = 0;

                while (true)
                {
                    if (collection.Find(c => c.Name.ToLower() == nameCandidate.ToLower()) == null)
                    {
                        var newCollection = new GraphCollection(nameCandidate);
                        collection.Add(newCollection);
                        BatchBuildConfig.SetConfigDirty();
                        return(newCollection);
                    }
                    nameCandidate = string.Format("{0} {1}", suggestedName, ++i);
                }
            }
Пример #22
0
        private string GetGroupIdFromEmail(string email)
        {
            // We can get all groups that have the given email as one of their addresses with:
            // https://graph.microsoft.com/v1.0/groups?$filter=mail eq '{email}' or proxyAddresses/any(x:x eq 'smtp:{email}')
            string request = string.Format("{0}/groups?$filter=mail eq '{1}' or proxyAddresses/any(x:x eq 'smtp:{1}')", this.ApiVersion, email);
            GraphCollection <Group> groups = this.Get <GraphCollection <Group> >(request);

            if (groups.Value.Length == 0)
            {
                throw new UserInformationException(Strings.MicrosoftGroup.NoGroupsWithEmail(email), "MicrosoftGroupNoGroupsWithEmail");
            }
            else if (groups.Value.Length > 1)
            {
                throw new UserInformationException(Strings.MicrosoftGroup.MultipleGroupsWithEmail(email), "MicrosoftGroupMultipleGroupsWithEmail");
            }
            else
            {
                return(groups.Value.Single().Id);
            }
        }
Пример #23
0
        private GraphCollection GenereateChartData(DataTable chartTable)
        {
            if (chartTable == null)
            {
                return(null);
            }
            GraphCollection graphCol = new GraphCollection();

            graphCol.XAxis     = new string[chartTable.Rows.Count];
            graphCol.GraphList = new List <Graph>();
            int index = 0;

            for (int i = 0; i < chartTable.Columns.Count; i++)
            {
                if (i == 0)
                {
                    foreach (DataRow item in chartTable.Rows)
                    {
                        graphCol.XAxis[index] = item[0].ToString();
                        index++;
                    }
                }
                else
                {
                    Graph graphItem = new Graph();
                    graphItem.data = new List <double>();
                    graphItem.name = chartTable.Columns[i].ColumnName;
                    foreach (DataRow drow in chartTable.Rows)
                    {
                        try
                        { graphItem.data.Add(Convert.ToDouble(drow[i])); }
                        catch
                        { graphItem.data.Add(0); }
                    }
                    graphCol.GraphList.Add(graphItem);
                }
            }

            return(graphCol);
        }
Пример #24
0
 /// <summary>
 /// Joins a parent and child route segments under the top level field type provided.
 /// </summary>
 /// <param name="fieldType">Type of the field to prepend a root key to the path.</param>
 /// <param name="routeSegments">The route segments to join.</param>
 /// <returns>System.String.</returns>
 public static string Join(GraphCollection fieldType, params string[] routeSegments)
 {
     return(GraphFieldPath.Join(fieldType.ToRouteRoot().AsEnumerable().Concat(routeSegments).ToArray()));
 }
 /// <summary>
 /// Attempts to retrieve the introspected model item representing one of the primary
 /// operation types supported by the schema.  Reuses any previously created objects
 /// and will attempt to resolve a missing object on each request in an attempt to
 /// account for a run-time-updated schema instance.
 /// </summary>
 /// <param name="collection">The collection.</param>
 /// <returns>IntrospectedType.</returns>
 private IntrospectedType FindOperationType(GraphCollection collection)
 {
     return(this.FindIntrospectedType(Constants.ReservedNames.FindOperationTypeNameByType(collection)));
 }
 public BreadthFirstSearchEnumerator(GraphCollection <TData, TWeight> graph, bool leftToRight = true)
 {
     this.Graph       = graph;
     this.LeftToRight = leftToRight;
     Reset();
 }
Пример #27
0
 public static GraphCollection CreateNewGraphCollection(string suggestedName)
 {
     return(GraphCollection.CreateNewGraphCollection(suggestedName));
 }
Пример #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GraphOperation" /> class.
 /// </summary>
 /// <param name="operationType">The operation type this instance represents.</param>
 /// <param name="name">The name of the operation type as it would appear in the object graph.</param>
 public GraphOperation(GraphCollection operationType, string name)
     : base(Constants.ReservedNames.FindOperationTypeNameByType(operationType))
 {
     this.OperationType = operationType;
     this.Extend(new Introspection_TypeNameMetaField(name));
 }
Пример #29
0
 public GraphTabVM(string name, GraphCollection collection)
 {
     Name             = name;
     SeriesCollection = collection;
 }
Пример #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GraphFieldPath" /> class.
 /// </summary>
 /// <param name="collection">The collection the route belongs to.</param>
 /// <param name="pathSegments">The individual path segments of the route.</param>
 public GraphFieldPath(GraphCollection collection, params string[] pathSegments)
     : this(GraphFieldPath.Join(collection, pathSegments))
 {
 }