Class Edge<V>

    • Field Detail

      • vertex1

        protected final V vertex1
      • vertex2

        protected final V vertex2
    • Constructor Detail

      • Edge

        protected Edge​(V vertex1,
                       V vertex2)
    • Method Detail

      • directedEdge

        public static <V> DirectedEdge<V> directedEdge​(V from,
                                                       V to)
        Creates a new directed edge
        Type Parameters:
        V - The vertex type
        Parameters:
        from - The from vertex
        to - The to vertex
        Returns:
        The created edge
      • directedEdge

        public static <V> DirectedEdge<V> directedEdge​(V from,
                                                       V to,
                                                       double weight)
        Creates a new directed edge
        Type Parameters:
        V - The vertex type
        Parameters:
        from - The from vertex
        to - The to vertex
        weight - The edge weight
        Returns:
        The created edge
      • undirectedEdge

        public static <V> UndirectedEdge<V> undirectedEdge​(V from,
                                                           V to)
        Creates a new undirected edge
        Type Parameters:
        V - The vertex type
        Parameters:
        from - The from vertex
        to - The to vertex
        Returns:
        The created edge
      • undirectedEdge

        public static <V> UndirectedEdge<V> undirectedEdge​(V from,
                                                           V to,
                                                           double weight)
        Creates a new undirected edge
        Type Parameters:
        V - The vertex type
        Parameters:
        from - The from vertex
        to - The to vertex
        weight - The edge weight
        Returns:
        The created edge
      • getFirstVertex

        public V getFirstVertex()
        Returns:
        The first (from) vertex
      • getOppositeVertex

        public V getOppositeVertex​(V vertex)
        Gets the vertex opposite of the one given
        Parameters:
        vertex - The vertex whose opposite we want
        Returns:
        The other vertex in the edge
      • getSecondVertex

        public V getSecondVertex()
        Returns:
        The second (to) vertex
      • getWeight

        public double getWeight()
        Returns:
        The weight of the edge or 1 if none
      • isDirected

        public abstract boolean isDirected()
        Returns:
        True if the edge is directed, False if not
      • isWeighted

        public boolean isWeighted()
        Returns:
        True if the edge has a weight, false otherwise
      • setWeight

        public void setWeight​(double weight)
        Sets the weight of the edge
        Parameters:
        weight - the weight