public Dijkstra(GraphInterface g, int start)
 {
     graph = g;
     dist  = new int[g.CountNodes()];
     prev  = new EdgeId[g.CountNodes()];
     queue = new List <int>();
     for (int i = 0; i < g.CountNodes(); i++)
     {
         queue.Add(i);
         dist[i] = INFINITY;
         prev[i] = NOEDGE;
     }
     dist[start] = 0;
 }
    void Init(GraphInterface g)
    {
        int n = g.CountNodes();

        //balls = new Rigidbody[n];
        //sticks = new Rigidbody[g.CountNodes()][];
        springs = new SpringJoint[n][];
        sticks  = new GameObject[n][];
        for (int i = 0; i < n; i++)
        {
            balls[i].velocity = 0.0f * Random.insideUnitSphere;
            springs[i]        = new SpringJoint[g.CountEdges(i)];
            sticks[i]         = new GameObject[g.CountEdges(i)];
        }
        balls[0].velocity = Vector3.zero;
        for (int i = 0; i < n; i++)
        {
            int j = 0;
            foreach (Edge e in g[i])
            {
                //if (i < e.v || e.reverse_edge == Edge.None)
                //{
                sticks[i][j] = Instantiate(stickPrefab);
                //}
                springs[i][j] = balls[i].gameObject.AddComponent <SpringJoint>();
                springs[i][j].connectedBody = balls[e.v];
                springs[i][j].spring        = 1.0f;
                springs[i][j].minDistance   = 0.1f * e.d - Vector3.Distance(balls[i].position, balls[e.v].position);
                springs[i][j].maxDistance   = 0.1f * e.d - Vector3.Distance(balls[i].position, balls[e.v].position);
                j++;
            }
        }
    }