Example #1
0
        public void AllPaths(List <GraphPath <T, U> > returns, Node <T, U> node, GraphPath <T, U> path, double cost, NormAbstract norm)
        {
            if (path == null)
            {
                path = new GraphPath <T, U>(norm);
            }
            path.AddNode(node, cost);

            if (node.Edges.Count > 0)
            {
                var original = path.Copy();
                for (int i = 0; i < node.Edges.Count; i++)
                {
                    if (i == 0)
                    {
                        AllPaths(returns, node.Edges[i].Destiny, path, node.Edges[i].Cost, norm);
                    }
                    else
                    {
                        AllPaths(returns, node.Edges[i].Destiny, original.Copy(), node.Edges[i].Cost, norm);
                    }
                }
            }
            else
            {
                if (!returns.Contains(path))
                {
                    returns.Add(path);
                }
            }
        }
Example #2
0
        public GraphPath <T, U> Copy()
        {
            GraphPath <T, U> returns = new GraphPath <T, U>(this.Norm);

            returns.Cost = this.Cost;
            returns.Nodes.AddRange(this.Nodes);
            return(returns);
        }
Example #3
0
 public bool Equals(GraphPath <T, U> other)
 {
     return(Math.Abs(other.Cost - this.Cost) <= 0.001);
 }