类 Graph<V,​E>

  • 类型参数:
    V - type of vertex
    E - type of edge

    public class Graph<V,​E>
    extends Object
    Graph
    作者:
    Chan Chung Kwong
    • 构造器详细资料

      • Graph

        public Graph()
        Create a empty graph
    • 方法详细资料

      • add

        public void add​(E edge,
                        V start,
                        V end)
        Added a edge
        参数:
        edge - the edge
        start - the start vertex
        end - the end vertex
      • remove

        public void remove​(E edge)
        Remove a edge
        参数:
        edge - to be removed
      • get

        public E get​(V start,
                     V end)
        Get a edge that link two given vertexes
        参数:
        start - a vertex
        end - another vertex
        返回:
        the edge or null
      • merge

        public void merge​(E replacement,
                          E replace0,
                          E replace1,
                          V vertex)
        Merge two edge into one
        参数:
        replacement - new edge
        replace0 - to be replaced
        replace1 - to be replaced
        vertex - the vertex between two edges
      • getVertexs

        public Set<V> getVertexs()
        返回:
        all vertexes
      • getEdges

        public Set<E> getEdges()
        返回:
        all edges
      • getEdges

        public Set<E> getEdges​(V vertex)
        参数:
        vertex -
        返回:
        all vertexes adjoint to a given vertex
      • getStart

        public V getStart​(E edge)
        参数:
        edge -
        返回:
        the start vertex of a edge
      • getEnd

        public V getEnd​(E edge)
        参数:
        edge -
        返回:
        the end vertex of a edge
      • getComponents

        public Iterator<Graph<V,​E>> getComponents()
        返回:
        the connected components