Interface Specifics<V,​E>

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean addEdgeToTouchingVertices​(V sourceVertex, V targetVertex, E e)
      Adds the specified edge to the edge containers of its source and target vertices.
      boolean addEdgeToTouchingVerticesIfAbsent​(V sourceVertex, V targetVertex, E e)
      Adds the specified edge to the edge containers of its source and target vertices only if the edge is not already in the graph.
      boolean addVertex​(V vertex)
      Adds a vertex.
      E createEdgeToTouchingVerticesIfAbsent​(V sourceVertex, V targetVertex, java.util.function.Supplier<E> edgeSupplier)
      Creates an edge given an edge supplier and adds it to the edge containers of its source and target vertices only if the graph does not contain other edges with the same source and target vertices.
      int degreeOf​(V vertex)
      Returns the degree of the specified vertex.
      java.util.Set<E> edgesOf​(V vertex)
      Returns a set of all edges touching the specified vertex.
      java.util.Set<E> getAllEdges​(V sourceVertex, V targetVertex)
      Returns a set of all edges connecting source vertex to target vertex if such vertices exist in this graph.
      E getEdge​(V sourceVertex, V targetVertex)
      Returns an edge connecting source vertex to target vertex if such vertices and such edge exist in this graph.
      java.util.Set<V> getVertexSet()
      Get the vertex set.
      java.util.Set<E> incomingEdgesOf​(V vertex)
      Returns a set of all edges incoming into the specified vertex.
      int inDegreeOf​(V vertex)
      Returns the "in degree" of the specified vertex.
      int outDegreeOf​(V vertex)
      Returns the "out degree" of the specified vertex.
      java.util.Set<E> outgoingEdgesOf​(V vertex)
      Returns a set of all edges outgoing from the specified vertex.
      void removeEdgeFromTouchingVertices​(V sourceVertex, V targetVertex, E e)
      Removes the specified edge from the edge containers of its source and target vertices.
    • Method Detail

      • addVertex

        boolean addVertex​(V vertex)
        Adds a vertex.
        Parameters:
        vertex - vertex to be added.
        Returns:
        true if the vertex was added, false if the vertex was already present
      • getVertexSet

        java.util.Set<V> getVertexSet()
        Get the vertex set.
        Returns:
        the vertex set
      • getAllEdges

        java.util.Set<E> getAllEdges​(V sourceVertex,
                                     V targetVertex)
        Returns a set of all edges connecting source vertex to target vertex if such vertices exist in this graph. If any of the vertices does not exist or is null, returns null. If both vertices exist but no edges found, returns an empty set.
        Parameters:
        sourceVertex - source vertex of the edge.
        targetVertex - target vertex of the edge.
        Returns:
        a set of all edges connecting source vertex to target vertex.
      • getEdge

        E getEdge​(V sourceVertex,
                  V targetVertex)
        Returns an edge connecting source vertex to target vertex if such vertices and such edge exist in this graph. Otherwise returns null. If any of the specified vertices is null returns null

        In undirected graphs, the returned edge may have its source and target vertices in the opposite order.

        Parameters:
        sourceVertex - source vertex of the edge.
        targetVertex - target vertex of the edge.
        Returns:
        an edge connecting source vertex to target vertex.
      • addEdgeToTouchingVertices

        boolean addEdgeToTouchingVertices​(V sourceVertex,
                                          V targetVertex,
                                          E e)
        Adds the specified edge to the edge containers of its source and target vertices.
        Parameters:
        sourceVertex - the source vertex
        targetVertex - the target vertex
        e - the edge
        Returns:
        true if the edge was added, false otherwise
      • addEdgeToTouchingVerticesIfAbsent

        boolean addEdgeToTouchingVerticesIfAbsent​(V sourceVertex,
                                                  V targetVertex,
                                                  E e)
        Adds the specified edge to the edge containers of its source and target vertices only if the edge is not already in the graph.
        Parameters:
        sourceVertex - the source vertex
        targetVertex - the target vertex
        e - the edge
        Returns:
        true if the edge was added, false otherwise
      • createEdgeToTouchingVerticesIfAbsent

        E createEdgeToTouchingVerticesIfAbsent​(V sourceVertex,
                                               V targetVertex,
                                               java.util.function.Supplier<E> edgeSupplier)
        Creates an edge given an edge supplier and adds it to the edge containers of its source and target vertices only if the graph does not contain other edges with the same source and target vertices.
        Parameters:
        sourceVertex - the source vertex
        targetVertex - the target vertex
        edgeSupplier - the function which will create the edge
        Returns:
        the newly created edge or null if an edge with the same source and target vertices was already present
      • degreeOf

        int degreeOf​(V vertex)
        Returns the degree of the specified vertex. A degree of a vertex in an undirected graph is the number of edges touching that vertex.
        Parameters:
        vertex - vertex whose degree is to be calculated.
        Returns:
        the degree of the specified vertex.
      • edgesOf

        java.util.Set<E> edgesOf​(V vertex)
        Returns a set of all edges touching the specified vertex. If no edges are touching the specified vertex returns an empty set.
        Parameters:
        vertex - the vertex for which a set of touching edges is to be returned.
        Returns:
        a set of all edges touching the specified vertex.
      • inDegreeOf

        int inDegreeOf​(V vertex)
        Returns the "in degree" of the specified vertex.
        Parameters:
        vertex - vertex whose in degree is to be calculated.
        Returns:
        the in degree of the specified vertex.
      • incomingEdgesOf

        java.util.Set<E> incomingEdgesOf​(V vertex)
        Returns a set of all edges incoming into the specified vertex.
        Parameters:
        vertex - the vertex for which the list of incoming edges to be returned.
        Returns:
        a set of all edges incoming into the specified vertex.
      • outDegreeOf

        int outDegreeOf​(V vertex)
        Returns the "out degree" of the specified vertex.
        Parameters:
        vertex - vertex whose out degree is to be calculated.
        Returns:
        the out degree of the specified vertex.
      • outgoingEdgesOf

        java.util.Set<E> outgoingEdgesOf​(V vertex)
        Returns a set of all edges outgoing from the specified vertex.
        Parameters:
        vertex - the vertex for which the list of outgoing edges to be returned.
        Returns:
        a set of all edges outgoing from the specified vertex.
      • removeEdgeFromTouchingVertices

        void removeEdgeFromTouchingVertices​(V sourceVertex,
                                            V targetVertex,
                                            E e)
        Removes the specified edge from the edge containers of its source and target vertices.
        Parameters:
        sourceVertex - the source vertex
        targetVertex - the target vertex
        e - the edge