// Helper to keep track of the path being looked at every iteration private static void trackAnimationFrame(List <AnimationFrame> frames, CytoscapeNode current) { AStarAnimationFrame frame = new AStarAnimationFrame(); frame.frame = new List <AStarAnimationNode>(); AStarAnimationNode tempNode; foreach (CytoscapeNode node in current.path) { tempNode = new AStarAnimationNode(node.id); frame.frame.Add(tempNode); } frames.Add(frame); }
// Converts the Cytoscape nodes into animation nodes and pushes them onto the list that tracks frontiers // We have to clone the frontier and then delete the elements from the copy because there is no way // to iterate through the frontier ordered by priority. private static void storeFrontierOverTime(AStarSpecificAnimation frontierOverTime, IntervalHeap <CytoscapeNode> frontier) { IntervalHeap <CytoscapeNode> frontierCopy = cloneFrontier(frontier); AStarAnimationNode animationNode; List <AStarAnimationNode> currentFrontier = new List <AStarAnimationNode>(); CytoscapeNode cyNode; while (frontierCopy.Any()) { cyNode = frontierCopy.DeleteMax(); animationNode = new AStarAnimationNode(cyNode.id); animationNode.name = cyNode.name; animationNode.f = cyNode.f; currentFrontier.Add(animationNode); } frontierOverTime.frontierOverTime.Add(currentFrontier); }
// For debug purposes private static Animation testAnim(int startID, int goalID) { Animation results = new Animation(); results.frames = new List <AnimationFrame>(); AStarAnimationFrame firstFrame = new AStarAnimationFrame(); List <AStarAnimationNode> firstFrameContents = new List <AStarAnimationNode>(); AStarAnimationNode start = new AStarAnimationNode(startID); firstFrameContents.Add(start); firstFrame.frame = firstFrameContents; results.frames.Add(firstFrame); AStarAnimationFrame nextFrame = new AStarAnimationFrame(); List <AStarAnimationNode> nextFrameContents = new List <AStarAnimationNode>(); AStarAnimationNode goal = new AStarAnimationNode(goalID); nextFrameContents.Add(goal); nextFrame.frame = nextFrameContents; results.frames.Add(nextFrame); return(results); }