public virtual List <Node> GetDependentNodes(GraphNet graph) { if (!dependentNodes.ContainsKey(graph)) { dependentNodes[graph] = new List <Node>(); } return(dependentNodes[graph]); }
public override void OnAdd(GraphNet graph) { if (Edges.Count == 0) { Edges = AllEdges(); } BaseOnAdd(this, graph); }
public override bool IsPathValid(GraphNet graph, NodePath path) { if (isPathValid == null) { return(base.IsPathValid(graph, path)); } else { return(isPathValid(this, graph, path)); } }
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); } }
public override void OnRemove(GraphNet graph) { if (onRemove == null) { base.OnRemove(graph); } else { onRemove(this, graph); } }
public override void OnAdd(GraphNet graph) { if (onAdd == null) { base.OnAdd(graph); } else { onAdd(this, graph); } }
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); } }); }
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); }); }
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); }
public override void OnProcess(GraphNet graph, Node input, List <NodePath> results) { Result = Predict(input); }
public virtual void OnRemove(GraphNet graph) { BaseOnRemove(this, graph); }
public virtual void OnProcess(GraphNet graph, Node input, List <NodePath> results) { }
public virtual void OnAdd(GraphNet graph) { BaseOnAdd(this, graph); }
public Node AddEdge(string predicate, Node obj, GraphNet gn) { return(AddEdge(gn.Node(predicate), obj)); }
public Node AddEdge(string predicate, object obj, GraphNet gn) { return(AddEdge(predicate, gn.Node(obj), gn)); }
public virtual bool IsPathValid(GraphNet graph, NodePath path) { return(BaseIsPathValid(this, graph, path)); }