Interface Graph<V>

    • Method Detail

      • addVertex

        int addVertex​(V x)
        Add a vertex to the graph. Has no effect if the vertex is already in the graph. Returns the index of the inserted vertex.
        Parameters:
        x -
      • addVertices

        void addVertices​(java.util.Collection<V> xs)
      • addVertices

        void addVertices​(V[] xs)
      • addEdge

        void addEdge​(V source,
                     V target,
                     long weight)
        Adds an edge. If the weight becomes 0, the edge is removed. Use the integer variant if possible.
        Parameters:
        source -
        target -
        weight -
      • getVertexOfIndex

        V getVertexOfIndex​(int index)
      • getVertices

        V[] getVertices()
      • getVertexIndices

        int[] getVertexIndices()
      • getNumberOfVertices

        int getNumberOfVertices()
      • containsEdge

        boolean containsEdge​(V source,
                             V target)
        Returns whether the graph contains an edge between source and target.
        Returns:
      • getEdgeSource

        V getEdgeSource​(long edgeIndex)
        Returns the vertex the edgeIndex comes from.
        Parameters:
        edgeIndex -
        Returns:
      • getEdgeTarget

        V getEdgeTarget​(long edgeIndex)
        Returns the vertex the edgeIndex points to.
        Parameters:
        edgeIndex -
        Returns:
      • getEdgeWeight

        long getEdgeWeight​(V source,
                           V target)
        Returns the weight of an edge.
        Parameters:
        source -
        target -
        Returns:
      • getIncomingEdgesOf

        java.lang.Iterable<java.lang.Long> getIncomingEdgesOf​(V v)
        Returns an array of edge index, containing all edges of which v is the target. Notice that the edge weight might be 0.
        Parameters:
        v -
        Returns:
      • getOutgoingEdgesOf

        java.lang.Iterable<java.lang.Long> getOutgoingEdgesOf​(V v)
        Returns an array of edge index, containing all edges of which v is the source.
        Parameters:
        v -
        Returns:
      • getEdgesOf

        java.lang.Iterable<java.lang.Long> getEdgesOf​(V v)
        Return an iterable of edgeIndex containing all edges of which v is a source or a target. Notice that the edge weight might be 0.
        Parameters:
        v -
        Returns:
      • getIndexOfVertex

        int getIndexOfVertex​(V v)
        Parameters:
        v -
        Returns:
        the index of the given vertex
      • clone

        Graph<V> clone()
        Specified by:
        clone in interface NormalisedIntGraph
        Returns:
        A copy of the graph that is not connected to this graph. Should not clone the vertices themselves.