Пример #1
0
 public virtual List <Node> GetDependentNodes(GraphNet graph)
 {
     if (!dependentNodes.ContainsKey(graph))
     {
         dependentNodes[graph] = new List <Node>();
     }
     return(dependentNodes[graph]);
 }
Пример #2
0
        public override void OnAdd(GraphNet graph)
        {
            if (Edges.Count == 0)
            {
                Edges = AllEdges();
            }

            BaseOnAdd(this, graph);
        }
Пример #3
0
 public override bool IsPathValid(GraphNet graph, NodePath path)
 {
     if (isPathValid == null)
     {
         return(base.IsPathValid(graph, path));
     }
     else
     {
         return(isPathValid(this, graph, path));
     }
 }
Пример #4
0
 public override void OnProcess(GraphNet graph, Node input, List <NodePath> paths)
 {
     if (onProcess == null)
     {
         base.OnProcess(graph, input, paths);
     }
     else
     {
         onProcess(this, graph, input, paths);
     }
 }
Пример #5
0
 public override void OnRemove(GraphNet graph)
 {
     if (onRemove == null)
     {
         base.OnRemove(graph);
     }
     else
     {
         onRemove(this, graph);
     }
 }
Пример #6
0
 public override void OnAdd(GraphNet graph)
 {
     if (onAdd == null)
     {
         base.OnAdd(graph);
     }
     else
     {
         onAdd(this, graph);
     }
 }
Пример #7
0
        public static void BaseOnRemove(Node node, GraphNet graph)
        {
            foreach (var e in node.Edges)
            {
                graph.Remove(e);
            }

            node.GetDependentNodes(graph).ForEach(n =>
            {
                if (graph.ContainsNode(n))
                {
                    graph.Remove(n);
                }
            });
        }
Пример #8
0
 public static void BaseOnAdd(Node node, GraphNet graph)
 {
     node.GetDependentNodes(graph).Clear();
     node.Edges.ForEach(e =>
     {
         if (e.Obj != node && !graph.ContainsNode(e.Obj))
         {
             node.GetDependentNodes(graph).Add(e.Obj);
         }
         if (e.Subject != node && !graph.ContainsNode(e.Subject))
         {
             node.GetDependentNodes(graph).Add(e.Subject);
         }
         graph.Add(e);
     });
 }
Пример #9
0
        public static bool BaseIsPathValid(Node node, GraphNet graph, NodePath path)
        {
            if (path.HasLoop)
            {
                return(false);
            }
            if (path.Count == 0)
            {
                return(false);
            }
            if (path[0].Value.Equals(path[path.Count - 1].Value))
            {
                return(false);
            }
            var middle = path.Skip(1).Take(path.Count - 2);
            var passesThroughAnOutputOrThisNode = middle.Any(n => n.Equals(node) || graph.Outputs.Contains(n) || graph.Inputs.Contains(n));

            return(!passesThroughAnOutputOrThisNode);
        }
Пример #10
0
 public override void OnProcess(GraphNet graph, Node input, List <NodePath> results)
 {
     Result = Predict(input);
 }
Пример #11
0
 public virtual void OnRemove(GraphNet graph)
 {
     BaseOnRemove(this, graph);
 }
Пример #12
0
 public virtual void OnProcess(GraphNet graph, Node input, List <NodePath> results)
 {
 }
Пример #13
0
 public virtual void OnAdd(GraphNet graph)
 {
     BaseOnAdd(this, graph);
 }
Пример #14
0
 public Node AddEdge(string predicate, Node obj, GraphNet gn)
 {
     return(AddEdge(gn.Node(predicate), obj));
 }
Пример #15
0
 public Node AddEdge(string predicate, object obj, GraphNet gn)
 {
     return(AddEdge(predicate, gn.Node(obj), gn));
 }
Пример #16
0
 public virtual bool IsPathValid(GraphNet graph, NodePath path)
 {
     return(BaseIsPathValid(this, graph, path));
 }