Class Edge<T>

  • Type Parameters:
    T -

    public class Edge<T>
    extends java.lang.Object
    A directed, weighted edge in a graph
    Version:
    $Revision$
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int cost  
      private Vertex<T> from  
      private boolean mark  
      private Vertex<T> to  
    • Constructor Summary

      Constructors 
      Constructor Description
      Edge​(Vertex<T> from, Vertex<T> to)
      Create a zero cost edge between from and to
      Edge​(Vertex<T> from, Vertex<T> to, int cost)
      Create an edge between from and to with the given cost.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clearMark()
      Clear the edge mark flag
      int getCost()
      Get the cost of the edge
      Vertex<T> getFrom()
      Get the starting vertex
      Vertex<T> getTo()
      Get the ending vertex
      boolean isMarked()
      Get the edge mark flag
      void mark()
      Set the mark flag of the edge
      java.lang.String toString()
      String rep of edge
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • cost

        private int cost
      • mark

        private boolean mark
    • Constructor Detail

      • Edge

        public Edge​(Vertex<T> from,
                    Vertex<T> to)
        Create a zero cost edge between from and to
        Parameters:
        from - the starting vertex
        to - the ending vertex
      • Edge

        public Edge​(Vertex<T> from,
                    Vertex<T> to,
                    int cost)
        Create an edge between from and to with the given cost.
        Parameters:
        from - the starting vertex
        to - the ending vertex
        cost - the cost of the edge
    • Method Detail

      • getTo

        public Vertex<T> getTo()
        Get the ending vertex
        Returns:
        ending vertex
      • getFrom

        public Vertex<T> getFrom()
        Get the starting vertex
        Returns:
        starting vertex
      • getCost

        public int getCost()
        Get the cost of the edge
        Returns:
        cost of the edge
      • mark

        public void mark()
        Set the mark flag of the edge
      • clearMark

        public void clearMark()
        Clear the edge mark flag
      • isMarked

        public boolean isMarked()
        Get the edge mark flag
        Returns:
        edge mark flag
      • toString

        public java.lang.String toString()
        String rep of edge
        Overrides:
        toString in class java.lang.Object
        Returns:
        string rep with from/to vertex names and cost