//public List<TNodeB> GetLinkedNodesOfType<TNodeB>(TNode item, Boolean includeBtoALinks = false) //{ //} //public List<IObjectWithNameWeightAndType> GetLinkedNodes(TNode item, Boolean includeBtoALinks = false) //{ // String id = GetID(item); // var result = graph.GetLinkedNodes(id, includeBtoALinks); // List<IObjectWithNameWeightAndType> output = new List<IObjectWithNameWeightAndType>(); // IObjectWithNameWeightAndType n = source[t][GetID(item)]; // return GetLinked(item); //} /// <summary> /// Adds new link, or update existing /// </summary> /// <param name="NodeA">The node a.</param> /// <param name="NodeB">The node b.</param> /// <param name="w">The w.</param> /// <param name="type">The type.</param> /// <param name="onWeight">The on weight.</param> /// <param name="onType">Type of the on.</param> /// <returns></returns> public freeGraphLinkBase AddLink(TNode NodeA, IObjectWithNameWeightAndType NodeB, Double w, Int32 type, operation onWeight = operation.assign, operation onType = operation.assign) { String a = GetID(NodeA); String b = GetID(NodeB); var lnk = graph.GetLink(a, b); if (lnk != null) { lnk.weight = onWeight.compute(lnk.weight, w); lnk.type = onWeight.compute(lnk.type, type); } else { lnk = graph.AddLink(a, b, w, type); } return(lnk); }
public List <freeGraphLinkBase> AddLinks(IObjectWithNameWeightAndType NodeA, IEnumerable <IObjectWithNameWeightAndType> NodeBs, double w = 1, int type = 0, operation onWeight = operation.assign, operation onType = operation.assign) { String a = GetID(NodeA); List <freeGraphLinkBase> output = new List <freeGraphLinkBase>(); foreach (var B in NodeBs) { String b = GetID(B); var lnk = graph.GetLink(a, b); if (lnk != null) { lnk.weight = onWeight.compute(lnk.weight, w); lnk.type = onWeight.compute(lnk.type, type); } else { lnk = graph.AddLink(a, b, w, type); } output.Add(lnk); } return(output); }
public freeGraphNodeBase Assign(IObjectWithNameWeightAndType NodeA, operation onWeight = operation.assign, operation onType = operation.assign) { String b = GetID(NodeA); var lnk = graph.AddNode(b, NodeA.weight, NodeA.type); if (lnk != null) { lnk.weight = onWeight.compute(lnk.weight, NodeA.weight); lnk.type = onType.compute(lnk.type, NodeA.type); } else { lnk = graph.AddNode(b, NodeA.weight, NodeA.type); } return(lnk); }
public List <freeGraphNodeBase> Assign(IEnumerable <IObjectWithNameWeightAndType> NodeA, operation onWeight = operation.assign, operation onType = operation.assign) { List <freeGraphNodeBase> output = new List <freeGraphNodeBase>(); foreach (var B in NodeA) { String b = GetID(B); var lnk = graph.AddNode(b, B.weight, B.type); if (lnk != null) { lnk.weight = onWeight.compute(lnk.weight, B.weight); lnk.type = onType.compute(lnk.type, B.type); } else { lnk = graph.AddNode(b, B.weight, B.type); } output.Add(lnk); } return(output); }