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

            BaseOnAdd(this, graph);
        }
Beispiel #3
0
 public override bool IsPathValid(GraphNet graph, NodePath path)
 {
     if (isPathValid == null)
     {
         return(base.IsPathValid(graph, path));
     }
     else
     {
         return(isPathValid(this, graph, path));
     }
 }
Beispiel #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);
     }
 }
Beispiel #5
0
 public override void OnRemove(GraphNet graph)
 {
     if (onRemove == null)
     {
         base.OnRemove(graph);
     }
     else
     {
         onRemove(this, graph);
     }
 }
Beispiel #6
0
 public override void OnAdd(GraphNet graph)
 {
     if (onAdd == null)
     {
         base.OnAdd(graph);
     }
     else
     {
         onAdd(this, graph);
     }
 }
Beispiel #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);
                }
            });
        }
Beispiel #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);
     });
 }
Beispiel #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);
        }
Beispiel #10
0
 public override void OnProcess(GraphNet graph, Node input, List <NodePath> results)
 {
     Result = Predict(input);
 }
Beispiel #11
0
 public virtual void OnRemove(GraphNet graph)
 {
     BaseOnRemove(this, graph);
 }
Beispiel #12
0
 public virtual void OnProcess(GraphNet graph, Node input, List <NodePath> results)
 {
 }
Beispiel #13
0
 public virtual void OnAdd(GraphNet graph)
 {
     BaseOnAdd(this, graph);
 }
Beispiel #14
0
 public Node AddEdge(string predicate, Node obj, GraphNet gn)
 {
     return(AddEdge(gn.Node(predicate), obj));
 }
Beispiel #15
0
 public Node AddEdge(string predicate, object obj, GraphNet gn)
 {
     return(AddEdge(predicate, gn.Node(obj), gn));
 }
Beispiel #16
0
 public virtual bool IsPathValid(GraphNet graph, NodePath path)
 {
     return(BaseIsPathValid(this, graph, path));
 }