public static CypherResult ExecuteRecommendationQuery(GraphAction graphAction, ContentTypeDistribution distribution, AggregateFilter filters, AlgoContext context, out string requestString)
 {
     try
     {
         if (graphAction.Query != null)
         {
             return(ExecuteCypherRecommendation(graphAction.Query.QueryContent, distribution, filters, context, out requestString));
         }
         else if (graphAction.Script != null)
         {
             return(ExecuteGremlinRecommendation(graphAction.Script.Script, distribution, filters, context, out requestString));
         }
         else
         {
             Log.Error("ExecuteRecommendationQuery", "This graph actions defines neither a Cypher query, nor a Gremlin query", graphAction.Id);
             requestString = null;
             return(null);
         }
     }
     catch (Exception e)
     {
         Log.Error("ExecuteRecommendationQuery", "Error executing query", e);
         throw;
     }
 }
Exemple #2
0
 protected void AddAction(GraphAction action)
 {
     if (action != null)
     {
         Actions.Add(action);
     }
 }
        public static CypherResult ExecuteMirrorQuery(GraphAction ga, AlgoContext context, int[] productIds)
        {
            if (ga.MirrorQuery != null)
            {
                return(ExecuteMirrorCypherQuery(ga.MirrorQuery.QueryContent, context, productIds));
            }
            else if (ga.MirrorScript != null)
            {
                return(ExecuteMirrorGremlin(ga.MirrorScript.MirrorScript, context, productIds));
            }

            return(null);
        }
Exemple #4
0
        private void CreateNodeAndRelationships(BaseNode node, IEnumerable <Relationship> rels)
        {
            foreach (var r in rels)
            {
                string query = r.IsDirectional ? CreateDirectionalRelIfDestExists : CreateRelIfDestExists;
                _actions.Add(GraphAction.CreateCypherAction(new GraphQuery
                {
                    Query  = string.Format(query, node.GetBusinessKeyName(), node.GetBusinessKey(), r.Target.GetBusinessKeyName(), r.Target.GetBusinessKey(), r.GetRelationType()),
                    Params = new Dictionary <string, object>()
                    {
                        { "RelProp", r.GetRelationshipDetail() }
                    }
                }));
            }

            Query();
        }
        private static void Main()
        {
            string[] menu =
            {
                "Create graph (using generator) and find max flow.",
                "Create graph (using keyboard) and find max flow.",
                "Close"
            };
            while (true)
            {
                var sw = _print_menu(0, menu);
                switch (sw)
                {
                case 1: {
                    int size       = _check_zero_one_value();
                    var _generator = new GraphGenerator(size, 0);
                    byte[,] graph        = _generator.GetMatrix;
                    int[,] ribs_capacity = _generator.GetRibsCapacity;
                    GraphAction action = new GraphAction(graph, ribs_capacity);
                    action.Output();
                    Console.WriteLine("Generator answer: {1}\nMax flow in the graph: {0}",
                                      action.GetMaxFlow,
                                      _generator.GetSum);
                    Console.ReadKey(true);
                    break;
                }

                case 2: {
                    var _generator = new GraphGenerator(0, 1);
                    byte[,] graph        = _generator.GetMatrix;
                    int[,] ribs_capacity = _generator.GetRibsCapacity;
                    GraphAction action = new GraphAction(graph, ribs_capacity);
                    action.Output();
                    Console.WriteLine("Max flow in the graph: {0}",
                                      action.GetMaxFlow);
                    Console.ReadKey(true);
                    break;
                }

                case 3: {
                    return;
                }
                }
            }
        }
        private void ExecuteGraphAction(GraphAction graphAction, string nodeTypeQualifiedName = "")
        {
            switch (graphAction)
            {
            case GraphAction.Copy:
                CopyNodes(WindowSettings.SelectedNodes);
                break;

            case GraphAction.Connect:

                break;

            case GraphAction.CreateNode:
                Type nodeType = Type.GetType(nodeTypeQualifiedName, true);
                CreateNodeInTheOpenedGraph(nodeType, WorldToGridPosition(CurrentMousePosition), true);
                break;

            case GraphAction.DeleteNodes:
                SoftDeleteNodes(WindowSettings.SelectedNodes, true, false);
                break;

            case GraphAction.DeselectAll:
                DeselectAll(true);
                break;

            case GraphAction.Disconnect:
                break;

            case GraphAction.Paste:
                PasteNodes();
                break;

            case GraphAction.SelectAll:
                SelectAll(true);
                break;

            case GraphAction.SelectNodes:
                break;

            default: throw new ArgumentOutOfRangeException("graphAction", graphAction, null);
            }
        }
Exemple #7
0
 internal void Execute()
 {
     GraphAction.Invoke("");
 }
 internal static GraphActionProxy GraphActionProxy(GraphAction action)
 {
     return(new GraphActionProxy(action));
 }
Exemple #9
0
 internal GraphActionProxy(GraphAction actions)
 {
     GraphActions = actions;
 }