public override void AddRelation(Node from, Node to) { if (!from.AdjacentNodes.Exists(n => n.Id == to.Id)) from.AdjacentNodes.Add(to); if (!from.AdjacentIds.Exists(n => n == to.Id)) from.AdjacentIds.Add(to.Id); base.AddRelation(from, to); }
public virtual void AddRelation(Node from, Node to) { _adjacents[Nodes.IndexOf(from)].AddFirst(Nodes.IndexOf(to)); _edgesCount++; }
public IEnumerable<int> CalculateShortestPath(Node from, Node to) { var b = new PathCalculator(GraphData, GraphData.Nodes.IndexOf(from)); var path = b.PathTo(GraphData.Nodes.IndexOf(to)); return path != null ? path.Select(i => GraphData.Nodes[i].Id).ToList() : null; }