// Performs the modified dijkstra algorithm and calls the method to fill the shortestPathBetweenStartAndEndNode list.
    public void CalculateModifiedDijkstraAlgorithm()
    {
        HelperNodeController endHelperNode = null;

        // Add the start node with state = 0 and distance = 0 to the SimplePriorityQueue
        GameObject           helpObject = Instantiate(helperNodePrefab);
        HelperNodeController help       = helpObject.GetComponent <HelperNodeController>();

        help.Initialize(startNode.Id, initialState, 0, null);
        prioQueue.Enqueue(help, 0);
        garbage.Add(helpObject);
        allDistances[startNode.Id, initialState] = 0;

        while (prioQueue.Count != 0)
        {
            // Retrieve the node with the smallest distance
            HelperNodeController currentHelperNode = prioQueue.Dequeue();

            // Skip the node if it was treated yet
            if (currentHelperNode.Distance != allDistances[currentHelperNode.Id, currentHelperNode.State])
            {
                continue;
            }

            NodeController currentNode = MainScript.AllNodes[currentHelperNode.Id];

            // End node test
            if (currentHelperNode.Id == endNode.Id)
            {
                endHelperNode = currentHelperNode;
                break;
            }

            // Perform the state change of the current node
            int newState = currentNode.ChangeState(currentHelperNode.State);

            // Handle all outgoing edges of the current node
            foreach (EdgeController edge in currentNode.OutgoingEdges)
            {
                // Calculate the new distance of the end node of the edge
                int newDistance = currentHelperNode.Distance + edge.GetCostForState(newState);

                // Create the new node and add it if allowed
                GameObject           newNodeObject = Instantiate(helperNodePrefab);
                HelperNodeController newNode       = newNodeObject.GetComponent <HelperNodeController>();
                garbage.Add(newNodeObject);

                // Check which node is the target node
                if (edge.Node1.Id != currentNode.Id)
                {
                    newNode.Initialize(edge.Node1.Id, newState, newDistance, currentHelperNode);
                }
                else
                {
                    newNode.Initialize(edge.Node0.Id, newState, newDistance, currentHelperNode);
                }

                if (DecideToAddNewNode(newNode))
                {
                    prioQueue.Enqueue(newNode, newDistance);
                }
            }
        }

        // Calculate the distance and path of the result
        if (endHelperNode != null)
        {
            ShortestDistance = endHelperNode.Distance;
            CalculatePathBetweenStartAndEndNode(endHelperNode);
        }

        // Destroy garbage
        foreach (GameObject obj in garbage)
        {
            Destroy(obj);
        }
    }