Coverage details for edu.uci.ics.jung.algorithms.shortestpath.ShortestPathUtils

LineHitsSource
1 /*
2  * Created on Jul 10, 2005
3  *
4  * Copyright (c) 2005, the JUNG Project and the Regents of the University
5  * of California
6  * All rights reserved.
7  *
8  * This software is open-source under the BSD license; see either
9  * "license.txt" or
10  * http://jung.sourceforge.net/license.txt for a description.
11  */
12 package edu.uci.ics.jung.algorithms.shortestpath;
13  
14 import java.util.LinkedList;
15 import java.util.List;
16 import java.util.Map;
17  
18 import edu.uci.ics.jung.graph.Edge;
19 import edu.uci.ics.jung.graph.Vertex;
20  
210public class ShortestPathUtils
22 {
23     /**
24      * Returns a <code>List</code> of the edges on the shortest path from
25      * <code>source</code> to <code>target</code>, in order of their
26      * occurrence on this path.
27      */
28     public static List getPath(ShortestPath sp, Vertex source, Vertex target)
29     {
300        LinkedList path = new LinkedList();
31         
320        Map incomingEdges = sp.getIncomingEdgeMap(source);
33         
340        if (incomingEdges.isEmpty() || incomingEdges.get(target) == null)
350            return path;
360        Vertex current = target;
370        while (current != source)
38         {
390            Edge incoming = (Edge)incomingEdges.get(current);
400            path.addFirst(incoming);
410            current = incoming.getOpposite(current);
42         }
430        return path;
44     }
45 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.