Пример #1
0
    void InitializeGraph()
    {
        graph        = new GraphProject.Graph <Transform>();
        solver       = new GraphProject.Solver <Transform>();
        solver.graph = graph;

        HashSet <Transform> set = new HashSet <Transform>();

        set.UnionWith(start);
        set.UnionWith(end);

        set.RemoveWhere(IsObsrtructed);

        for (int i = 0; i < start.Count; ++i)
        {
            if (start[i] != null && end[i] != null && ValidateEdge(start[i], end[i]))
            {
                start[i] = null;
                end[i]   = null;
            }
        }

        //for (int i = 0; i < start.Count; ++i)
        //{
        //    if (IsObsrtructed(start[i]))
        //    {
        //        start[i] = null;
        //    }
        //}
        //for (int i = 0; i < end.Count; ++i)
        //{
        //    if (IsObsrtructed(end[i]))
        //    {
        //        end[i] = null;
        //    }
        //}


        foreach (var trans in set)
        {
            if (trans != null)
            {
                graph.AddNode(trans);
            }
        }

        for (int i = 0; i < start.Count; ++i)
        {
            if (start[i] != null && end[i] != null)
            {
                graph.addEdge(start[i], end[i], diff, 0.0001f, diff(start[i], end[i]));
            }
        }
    }