/** * Correct costs of successors of the input vertex using backward star form. * (FLOWER) * * @param vertex */ public void CorrectCostBackward(BaseVertex vertex) { // 1. initialize the list of vertex to be updated var vertexList = new java.util.LinkedList <BaseVertex>(); vertexList.add(vertex); // 2. update the cost of relevant precedents of the input vertex while (!vertexList.isEmpty()) { BaseVertex curVertex = vertexList.remove(0); double costOfCurVertex = startVertexDistanceIndex[curVertex]; ISet <BaseVertex> preVertexSet = graph.GetPrecedentVertices(curVertex); foreach (BaseVertex preVertex in preVertexSet) { double costOfPreVertex = startVertexDistanceIndex.ContainsKey(preVertex) ? startVertexDistanceIndex[preVertex] : Graph.DISCONNECTED; double freshCost = costOfCurVertex + graph.GetEdgeWeight(preVertex, curVertex); if (costOfPreVertex > freshCost) { startVertexDistanceIndex.AddOrReplace(preVertex, freshCost); predecessorIndex.AddOrReplace(preVertex, curVertex); vertexList.add(preVertex); } } } }
protected override IList <P> FindShortestPathHook( V startVertex, V endVertex, int maxNumberOfPaths ) { IList <P> paths = new System.Collections.Generic.List <P>(); IList <edu.ufl.cise.bsmock.graph.util.Path> pathList = yenAlgorithm.Ksp( graphAdaptee, startVertex.VertexId, endVertex.VertexId, maxNumberOfPaths ); foreach (edu.ufl.cise.bsmock.graph.util.Path path in pathList) { java.util.LinkedList <edu.ufl.cise.bsmock.graph.Edge> listOfEdges = path.GetEdges(); IList <E> edges = new System.Collections.Generic.List <E>(); foreach (edu.ufl.cise.bsmock.graph.Edge edgeAdaptee in listOfEdges) { E edge = GetOriginalEdgeInstance(edgeAdaptee); edges.Add( edge ); } W totalWeight = base.CreateInstanceWithTotalWeight(path.GetTotalCost(), edges); paths.Add(base.CreatePath(totalWeight, edges)); } return(new ReadOnlyCollection <P>(paths)); }
public void AddEdges(java.util.LinkedList <Edge> edges) { foreach (Edge edge in edges) { AddEdge(edge); } }
static Searcher() { FacetHandlers = new java.util.LinkedList(); FacetHandlers.add(new SimpleFacetHandler(FieldName.CandidateStatus)); FacetHandlers.add(new CompactMultiValueFacetHandler(FieldName.Industries)); FacetHandlers.add(new CompactMultiValueFacetHandler(FieldName.DesiredJobTypes)); }
public bool Equals(Path path2) { if (path2 == null) { return(false); } java.util.LinkedList <Edge> edges2 = path2.GetEdges(); int numEdges1 = edges.size(); int numEdges2 = edges2.size(); if (numEdges1 != numEdges2) { return(false); } for (int i = 0; i < numEdges1; i++) { Edge edge1 = edges.get(i); Edge edge2 = edges2.get(i); if (!edge1.GetFromNode().Equals(edge2.GetFromNode())) { return(false); } if (!edge1.GetToNode().Equals(edge2.GetToNode())) { return(false); } } return(true); }
public static void FilterInstances(weka.core.Instances allInstances) { DateTime nextHpDate = DateTime.MinValue; java.util.LinkedList deleteList = new java.util.LinkedList(); for (int i = 0; i < allInstances.numInstances(); ++i) { DateTime nowDate = WekaUtils.GetDateValueFromInstances(allInstances, 0, i); if (TestParameters2.RealTimeMode && i == allInstances.numInstances() - 1) { allInstances.instance(i).setClassValue(0); allInstances.instance(i).setValue(1, WekaUtils.GetTimeFromDate(Parameters.MaxDate) * 1000); } else { if (nowDate < nextHpDate) { deleteList.Add(allInstances.instance(i)); } else { DateTime hpDate = WekaUtils.GetDateValueFromInstances(allInstances, 1, i); nextHpDate = hpDate; } } } allInstances.removeAll(deleteList); }
internal LinkIterator(java.util.LinkedList <ET> @object, int location) { list = @object; expectedModCount = list.modCount; if (location >= 0 && location <= list._size) { // pos ends up as -1 if list is empty, it ranges from -1 to // list.size - 1 // if link == voidLink then pos must == -1 link = list.voidLink; if (location < list._size / 2) { for (pos = -1; pos + 1 < location; pos++) { link = link.next; } } else { for (pos = list._size; pos >= location; pos--) { link = link.previous; } } } else { throw new System.IndexOutOfRangeException(); } }
internal ReverseLinkIterator(LinkedList <E> _enclosing, java.util.LinkedList <ET> linkedList ) { this._enclosing = _enclosing; this.list = linkedList; this.expectedModCount = this.list.modCount; this.link = this.list.voidLink; this.canRemove = false; }
public Path(java.util.LinkedList <Edge> edges) { this.edges = edges; totalCost = 0; foreach (Edge edge in edges) { totalCost += edge.GetWeight(); } }
public static void AddAll <T>( this ICollection <T> list, java.util.LinkedList <T> list2 ) { foreach (T t in list2) { list.Add(t); } }
public static java.util.List ConvertToJList(List <Token> tokens) { var list = new java.util.LinkedList(); foreach (var token in tokens) { list.add(token); } return(list); }
public java.util.LinkedList <Edge> GetEdges() { java.util.LinkedList <Edge> edges = new java.util.LinkedList <Edge>(); foreach (String toNodeLabel in neighbors.Keys) { edges.add(new Edge(label, toNodeLabel, neighbors[toNodeLabel])); } return(edges); }
/** * Calculate the distance from the target vertex to the input * vertex using forward star form. * (FLOWER) * * @param vertex */ public Path UpdateCostForward(BaseVertex vertex) { double cost = Graph.DISCONNECTED; // 1. get the set of successors of the input vertex ISet <BaseVertex> adjVertexSet = graph.GetAdjacentVertices(vertex); // 2. make sure the input vertex exists in the index if (!startVertexDistanceIndex.ContainsKey(vertex)) { startVertexDistanceIndex.Add(vertex, Graph.DISCONNECTED); } // 3. update the distance from the root to the input vertex if necessary foreach (BaseVertex curVertex in adjVertexSet) { // 3.1 get the distance from the root to one successor of the input vertex double distance = startVertexDistanceIndex.ContainsKey(curVertex)? startVertexDistanceIndex[curVertex] : Graph.DISCONNECTED; // 3.2 calculate the distance from the root to the input vertex distance += graph.GetEdgeWeight(vertex, curVertex); //distance += ((VariableGraph)graph).get_edge_weight_of_graph(vertex, curVertex); // 3.3 update the distance if necessary double costOfVertex = startVertexDistanceIndex[vertex]; if (costOfVertex > distance) { startVertexDistanceIndex.AddOrReplace(vertex, distance); predecessorIndex.AddOrReplace(vertex, curVertex); cost = distance; } } // 4. create the subPath if exists Path subPath = null; if (cost < Graph.DISCONNECTED) { subPath = new Path(); subPath.SetWeight(cost); java.util.LinkedList <BaseVertex> vertexList = subPath.GetVertexList(); vertexList.add(vertex); BaseVertex selVertex = predecessorIndex[vertex]; while (selVertex != null) { vertexList.add(selVertex); selVertex = predecessorIndex.GetValueIfExists(selVertex); } } return(subPath); }
public java.util.LinkedList <Edge> GetEdgeList() { java.util.LinkedList <Edge> edgeList = new java.util.LinkedList <Edge>(); foreach (Node node in nodes.Values) { edgeList.addAll(node.GetEdges()); } return(edgeList); }
public Path ShallowClone() { java.util.LinkedList <Edge> edges = new java.util.LinkedList <Edge>(); foreach (Edge edge in this.edges) { edges.add(edge); } return(new Path(edges, this.totalCost)); }
public Path CloneFrom(int i) { java.util.LinkedList <Edge> edges = new java.util.LinkedList <Edge>(); foreach (Edge edge in this.edges.subList(i, this.edges.size())) { edges.add(edge.Clone()); } return(new Path(edges)); }
public Path Clone() { java.util.LinkedList <Edge> edges = new java.util.LinkedList <Edge>(); foreach (Edge edge in this.edges) { edges.add(edge.Clone()); } return(new Path(edges)); }
public java.util.LinkedList <Edge> RemoveNode(String label) { java.util.LinkedList <Edge> edges = new java.util.LinkedList <Edge>(); if (nodes.ContainsKey(label)) { Node node = nodes[label]; nodes.Remove(label); edges.addAll(node.GetEdges()); edges.addAll(RemoveEdgesToNode(label)); } return(edges); }
public java.util.LinkedList <Edge> RemoveEdgesToNode(String label) { java.util.LinkedList <Edge> edges = new java.util.LinkedList <Edge>(); foreach (Node node in nodes.Values) { if (node.GetAdjacencyList().Contains(label)) // TODO: perfomance ... Contains in collection ... { double weight = node.RemoveEdge(label); edges.add(new Edge(node.GetLabel(), label, weight)); } } return(edges); }
public Path CloneTo(int i) { java.util.LinkedList <Edge> edges = new java.util.LinkedList <Edge>(); int l = this.edges.size(); if (i > l) { i = l; } //for (Edge edge : this.edges.subList(0,i)) { for (int j = 0; j < i; j++) { edges.add(this.edges.get(j).Clone()); } return(new Path(edges)); }
private void removeItem(System.Object item) { if (items != null) { List temp = new LinkedList(); List litems = (List)item; for (int idx = 0; idx < litems.size(); idx++) { System.Object tmpItem = litems.get(idx); if (!tmpItem.Equals(item)) { temp.add(tmpItem); } } items = temp.toArray(); fireContentsChanged(this, 0, items.Length); } }
public java.util.LinkedList <String> GetNodes() { java.util.LinkedList <String> nodes = new java.util.LinkedList <String>(); foreach (Edge edge in edges) { nodes.add(edge.GetFromNode()); } Edge lastEdge = edges.getLast(); if (lastEdge != null) { nodes.add(lastEdge.GetToNode()); } return(nodes); }
public void YenKShortestPathsTest() { const double deltaValue = 0.0000001; var graph = new Graph(); graph.AddEdge("A", "B", 5); graph.AddEdge("A", "C", 6); graph.AddEdge("B", "C", 7); graph.AddEdge("B", "D", 8); graph.AddEdge("C", "D", 9); Yen yenAlgorithm = new Yen(); IList <Path> paths = yenAlgorithm.Ksp(graph, "A", "D", 5); Assert.AreEqual(3, paths.Count); Path path1 = paths[0]; Path path2 = paths[1]; Path path3 = paths[2]; Assert.AreEqual(13, path1.GetTotalCost(), deltaValue); Assert.AreEqual(15, path2.GetTotalCost(), deltaValue); Assert.AreEqual(21, path3.GetTotalCost(), deltaValue); java.util.LinkedList <String> nodes1 = path1.GetNodes(); Assert.AreEqual(3, nodes1.size()); Assert.AreEqual("A", nodes1.get(0)); Assert.AreEqual("B", nodes1.get(1)); Assert.AreEqual("D", nodes1.get(2)); java.util.LinkedList <String> nodes2 = path2.GetNodes(); Assert.AreEqual(3, nodes2.size()); Assert.AreEqual("A", nodes2.get(0)); Assert.AreEqual("C", nodes2.get(1)); Assert.AreEqual("D", nodes2.get(2)); java.util.LinkedList <String> nodes3 = path3.GetNodes(); Assert.AreEqual(4, nodes3.size()); Assert.AreEqual("A", nodes3.get(0)); Assert.AreEqual("B", nodes3.get(1)); Assert.AreEqual("C", nodes3.get(2)); Assert.AreEqual("D", nodes3.get(3)); }
public void Test_ForEach_LinkedList() { java.lang.SystemJ.outJ.println("LinkedList foreach test"); java.util.LinkedList <String> testArray = new java.util.LinkedList <String>(); testArray.add("VampireAPI"); testArray.add("supports"); testArray.add("foreach statements"); testArray.add("! Yeah!!!"); // for count loop java.lang.SystemJ.outJ.println("for count loop: "); for (int i = 0; i < testArray.size(); i++) { java.lang.SystemJ.outJ.print(testArray.get(i)); java.lang.SystemJ.outJ.print(" "); } java.lang.SystemJ.outJ.println(); // for iterator loop java.lang.SystemJ.outJ.println("for iterator loop: "); for (java.util.Iterator <String> it = testArray.iterator(); it.hasNext();) { java.lang.SystemJ.outJ.print(it.next()); java.lang.SystemJ.outJ.print(" "); } java.lang.SystemJ.outJ.println(); // foreach loop java.lang.SystemJ.outJ.println("foreach loop: "); foreach (String text in testArray) { java.lang.SystemJ.outJ.print(text); java.lang.SystemJ.outJ.print(" "); } java.lang.SystemJ.outJ.println(); Assert.True(true, "compiler OK"); }
/** * Note that, the source should not be as same as the sink! (we could extend * this later on) * * @param sourceVertex * @param sinkVertex * @return */ public Path GetShortestPath(BaseVertex sourceVertex, BaseVertex sinkVertex) { DetermineShortestPaths(sourceVertex, sinkVertex, true); // java.util.LinkedList <BaseVertex> vertexList = new java.util.LinkedList <BaseVertex>(); double weight = startVertexDistanceIndex.ContainsKey(sinkVertex) ? startVertexDistanceIndex[sinkVertex] : Graph.DISCONNECTED; if (weight != Graph.DISCONNECTED) { BaseVertex curVertex = sinkVertex; do { vertexList.add(curVertex); curVertex = predecessorIndex[curVertex]; } while (curVertex != null && curVertex != sourceVertex); vertexList.add(sourceVertex); vertexList.reverse(); } return(new Path(vertexList, weight)); }
protected internal virtual void createPrimitives(ViewGraphNode root) { LinkedList queue = new LinkedList(); queue.add(root); while (!queue.isEmpty()) { ViewGraphNode act = (ViewGraphNode)queue.remove(0); Shape s = null; if (act.Shape == null) { s = makeShapeFromNode(act, queue); } else { s = act.Shape; } if (act.ParentsChecked) { continue; } act.ParentsChecked = true; for (Iterator it = act.Parents.iterator(); it.hasNext();) { ViewGraphNode n = (ViewGraphNode)it.next(); Shape s1 = n.Shape; if (s1 == null) { s1 = makeShapeFromNode(n, queue); } ConnectorLine line = new ConnectorLine(s1, s); line.Color = System.Drawing.Color.Blue; if (n.ReteNode is BaseJoin) { line.Color = System.Drawing.Color.Red; } addPrimitive(line); } } }
protected internal virtual Shape makeShapeFromNode(ViewGraphNode act, LinkedList queue) { System.Drawing.Color bg = getBackgroundColorForNode(act); System.Drawing.Color border = getBorderColorForNode(act); System.String desc = ""; BaseNode reteNode = act.ReteNode; HashSet terminalNodes = new HashSet(); getCorrespondingTerminalNodes(act, terminalNodes); if (reteNode != null) desc = reteNode.NodeId.ToString(); Shape s; if (reteNode == null) { // ROOT NODE s = new Ellipse(); } else if (reteNode is BaseJoin || act.ReteNode is BaseAlpha2) { s = new Trapezoid(); } else if (reteNode is TerminalNode) { s = new RoundedRectangle(); } else if (reteNode is LIANode) { s = new Ellipse(); } else { s = new Rectangle(); } s.Bgcolor = bg; s.Bordercolor = border; //UPGRADE_WARNING: Narrowing conversions may produce unexpected results in C#. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1042"' int x = (spaceHorizontal / 2) + (int) ((float) (act.X * (spaceHorizontal + nodeHorizontal)) / 2.0); int y = (spaceVertical / 2) + act.Y * (spaceVertical + nodeVertical); System.String key = x + "," + y; // if there is already a node at the given location, we shift it right while (this.coordinates.ContainsKey(key)) { x = x + ((spaceHorizontal + nodeHorizontal) * 2); key = x + "," + y; } SupportClass.PutElement(coordinates, key, s); s.X = x; s.Y = y; s.Width = nodeHorizontal; s.Height = nodeVertical; System.String longdesc = ""; if (reteNode == null) { longdesc = "Root Node"; } else { longdesc = "ID:" + reteNode.NodeId + " NodeType:" + reteNode.GetType().FullName; longdesc += " Details:" + reteNode.toPPString(); } longdesc += " Rules:"; Iterator iter = terminalNodes.iterator(); while (iter.hasNext()) { TerminalNode t = (TerminalNode) iter.next(); longdesc += t.Rule.Name; if (iter.hasNext()) longdesc += ";"; } s.LongDescription = longdesc; if (reteNode is LIANode) s.incWidth(- nodeHorizontal / 3); s.Text = desc; act.Shape = s; addPrimitive(s); for (Iterator it = act.Successors.iterator(); it.hasNext(); ) { ViewGraphNode n = (ViewGraphNode) it.next(); queue.add(n); } return s; }
protected internal virtual void createPrimitives(ViewGraphNode root) { LinkedList queue = new LinkedList(); queue.add(root); while (!queue.isEmpty()) { ViewGraphNode act = (ViewGraphNode) queue.remove(0); Shape s = null; if (act.Shape == null) { s = makeShapeFromNode(act, queue); } else { s = act.Shape; } if (act.ParentsChecked) continue; act.ParentsChecked = true; for (Iterator it = act.Parents.iterator(); it.hasNext(); ) { ViewGraphNode n = (ViewGraphNode) it.next(); Shape s1 = n.Shape; if (s1 == null) s1 = makeShapeFromNode(n, queue); ConnectorLine line = new ConnectorLine(s1, s); line.Color = System.Drawing.Color.Blue; if (n.ReteNode is BaseJoin) line.Color = System.Drawing.Color.Red; addPrimitive(line); } } }
static Searcher() { FacetHandlers = new java.util.LinkedList(); FacetHandlers.add(new CompactMultiValueFacetHandler(FieldName.Industries)); FacetHandlers.add(new CompactMultiValueFacetHandler(FieldName.JobTypes)); }
/** * Computes the K shortest paths in a graph from node s to node t using Yen's algorithm * * @param graph the graph on which to compute the K shortest paths from s to t * @param sourceLabel the starting node for all of the paths * @param targetLabel the ending node for all of the paths * @param K the number of shortest paths to compute * @return a list of the K shortest paths from s to t, ordered from shortest to longest */ public IList <Path> Ksp(Graph graph, String sourceLabel, String targetLabel, int K) { // Initialize containers for candidate paths and k shortest paths List <Path> ksp = new List <Path>(); java.util.PriorityQueue <Path> candidates = new java.util.PriorityQueue <Path>(); //try { /* Compute and add the shortest path */ Path kthPath = Dijkstra.ShortestPath(graph, sourceLabel, targetLabel); ksp.Add(kthPath); /* Iteratively compute each of the k shortest paths */ for (int k = 1; k < K; k++) { // Get the (k-1)st shortest path Path previousPath = ksp[k - 1]; /* Iterate over all of the nodes in the (k-1)st shortest path except for the target node; for each node, * (up to) one new candidate path is generated by temporarily modifying the graph and then running * Dijkstra's algorithm to find the shortest path between the node and the target in the modified * graph */ for (int i = 0; i < previousPath.Size(); i++) { // Initialize a container to store the modified (removed) edges for this node/iteration java.util.LinkedList <Edge> removedEdges = new java.util.LinkedList <Edge>(); // Spur node = currently visited node in the (k-1)st shortest path String spurNode = previousPath.GetEdges().get(i).GetFromNode(); // Root path = prefix portion of the (k-1)st path up to the spur node Path rootPath = previousPath.CloneTo(i); /* Iterate over all of the (k-1) shortest paths */ foreach (Path p in ksp) { Path stub = p.CloneTo(i); // Check to see if this path has the same prefix/root as the (k-1)st shortest path if (rootPath.Equals((object)stub)) { /* If so, eliminate the next edge in the path from the graph (later on, this forces the spur * node to connect the root path with an un-found suffix path) */ Edge re = p.GetEdges().get(i); graph.RemoveEdge(re.GetFromNode(), re.GetToNode()); removedEdges.add(re); } } /* Temporarily remove all of the nodes in the root path, other than the spur node, from the graph */ foreach (Edge rootPathEdge in rootPath.GetEdges()) { String rn = rootPathEdge.GetFromNode(); if (!rn.Equals(spurNode)) { removedEdges.addAll(graph.RemoveNode(rn)); } } // Spur path = shortest path from spur node to target node in the reduced graph Path spurPath = Dijkstra.ShortestPath(graph, spurNode, targetLabel); // If a new spur path was identified... if (spurPath != null) { // Concatenate the root and spur paths to form the new candidate path Path totalPath = rootPath.Clone(); totalPath.AddPath(spurPath); // If candidate path has not been generated previously, add it if (!candidates.contains(totalPath)) { candidates.add(totalPath, totalPath.GetTotalCost()); } } // Restore all of the edges that were removed during this iteration graph.AddEdges(removedEdges); } /* Identify the candidate path with the shortest cost */ bool isNewPath; do { kthPath = candidates.poll(); isNewPath = true; if (kthPath != null) { foreach (Path p in ksp) { // Check to see if this candidate path duplicates a previously found path if (p.Equals(kthPath)) { isNewPath = false; break; } } } } while(!isNewPath); // If there were not any more candidates, stop if (kthPath == null) { break; } // Add the best, non-duplicate candidate identified as the k shortest path ksp.Add(kthPath); } //} catch (Exception e) { // SystemOut.println(e); // e.printStackTrace(); //} // Return the set of k shortest paths return(ksp); }
/** * Get the shortest path among all that connecting source with targe. * * @return */ public Path Next() { //3.1 prepare for removing vertices and arcs Path curPath = pathCandidates.Poll(); resultList.Add(curPath); BaseVertex curDerivation = pathDerivationVertexIndex[curPath]; int curPathHash = curPath.GetVertexList().subList(0, curPath.GetVertexList().indexOf(curDerivation)).GetHashCode(); int count = resultList.Count; //3.2 remove the vertices and arcs in the graph for (int i = 0; i < count - 1; ++i) { Path curResultPath = resultList[i]; int curDevVertexId = curResultPath.GetVertexList().indexOf(curDerivation); if (curDevVertexId < 0) { continue; } // Note that the following condition makes sure all candidates should be considered. /// The algorithm in the paper is not correct for removing some candidates by mistake. int pathHash = curResultPath.GetVertexList().subList(0, curDevVertexId).GetHashCode(); if (pathHash != curPathHash) { continue; } BaseVertex curSuccVertex = curResultPath.GetVertexList().get(curDevVertexId + 1); graph.DeleteEdge(new Pair <int, int>( curDerivation.GetId(), curSuccVertex.GetId())); } int pathLength = curPath.GetVertexList().size(); java.util.LinkedList <BaseVertex> curPathVertexList = curPath.GetVertexList(); for (int i = 0; i < pathLength - 1; ++i) { graph.DeleteVertex(curPathVertexList.get(i).GetId()); graph.DeleteEdge(new Pair <int, int>( curPathVertexList.get(i).GetId(), curPathVertexList.get(i + 1).GetId())); } //3.3 calculate the shortest tree rooted at target vertex in the graph DijkstraShortestPathAlg reverseTree = new DijkstraShortestPathAlg(graph); reverseTree.GetShortestPathFlower(targetVertex); //3.4 recover the deleted vertices and update the cost and identify the new candidate results bool isDone = false; for (int i = pathLength - 2; i >= 0 && !isDone; --i) { //3.4.1 get the vertex to be recovered BaseVertex curRecoverVertex = curPathVertexList.get(i); graph.RecoverDeletedVertex(curRecoverVertex.GetId()); //3.4.2 check if we should stop continuing in the next iteration if (curRecoverVertex.GetId() == curDerivation.GetId()) { isDone = true; } //3.4.3 calculate cost using forward star form Path subPath = reverseTree.UpdateCostForward(curRecoverVertex); //3.4.4 get one candidate result if possible if (subPath != null) { ++generatedPathNum; //3.4.4.1 get the prefix from the concerned path double cost = 0; IList <BaseVertex> prePathList = new List <BaseVertex>(); reverseTree.CorrectCostBackward(curRecoverVertex); for (int j = 0; j < pathLength; ++j) { BaseVertex curVertex = curPathVertexList.get(j); if (curVertex.GetId() == curRecoverVertex.GetId()) { j = pathLength; } else { cost += graph.GetEdgeWeightOfGraph(curPathVertexList.get(j), curPathVertexList.get(j + 1)); prePathList.Add(curVertex); } } prePathList.AddAll(subPath.GetVertexList()); //3.4.4.2 compose a candidate subPath.SetWeight(cost + subPath.GetWeight()); subPath.GetVertexList().clear(); subPath.GetVertexList().addAll(prePathList); //3.4.4.3 put it in the candidate pool if new if (!pathDerivationVertexIndex.ContainsKey(subPath)) { pathCandidates.Add(subPath); pathDerivationVertexIndex.Add(subPath, curRecoverVertex); } } //3.4.5 restore the edge BaseVertex succVertex = curPathVertexList.get(i + 1); graph.RecoverDeletedEdge(new Pair <int, int>( curRecoverVertex.GetId(), succVertex.GetId())); //3.4.6 update cost if necessary double cost1 = graph.GetEdgeWeight(curRecoverVertex, succVertex) + reverseTree.GetStartVertexDistanceIndex()[succVertex]; if (reverseTree.GetStartVertexDistanceIndex()[curRecoverVertex] > cost1) { reverseTree.GetStartVertexDistanceIndex().AddOrReplace(curRecoverVertex, cost1); reverseTree.GetPredecessorIndex().AddOrReplace(curRecoverVertex, succVertex); reverseTree.CorrectCostBackward(curRecoverVertex); } } //3.5 restore everything graph.RecoverDeletedEdges(); graph.RecoverDeletedVertices(); return(curPath); }
public void SetEdges(java.util.LinkedList <Edge> edges) { this.edges = edges; }
private void removeItem(System.Object item) { if (items != null) { List temp = new LinkedList(); List litems = (List) item; for (int idx = 0; idx < litems.size(); idx++) { System.Object tmpItem = litems.get(idx); if (!tmpItem.Equals(item)) { temp.add(tmpItem); } } items = temp.toArray(); fireContentsChanged(this, 0, items.Length); } }