Class GraphImplLinearEdge<V>

  • All Implemented Interfaces:
    java.lang.Cloneable, Graph<V>, NormalisedIntGraph

    public class GraphImplLinearEdge<V>
    extends java.lang.Object
    implements Graph<V>
    • Constructor Summary

      Constructors 
      Constructor Description
      GraphImplLinearEdge​(java.lang.Class<?> clazz)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addEdge​(int source, int target, long weight)
      Adds an edge.
      void addEdge​(V source, V target, long weight)
      Adds an edge.
      void addVertex​(int vertexIndex)  
      int addVertex​(V x)
      Add a vertex to the graph.
      void addVertices​(java.util.Collection<V> xs)  
      void addVertices​(V[] xs)  
      Graph<V> clone()  
      boolean containsEdge​(int source, int target)
      Returns whether the graph contains an edge between source and target.
      boolean containsEdge​(V source, V target)
      Returns whether the graph contains an edge between source and target.
      java.lang.Iterable<java.lang.Long> getEdges()
      Gives an iterable that iterates over all edges; The edges that are returned are indices.
      java.lang.Iterable<java.lang.Long> getEdgesOf​(int indexOfV)
      Return an iterable of edgeIndex containing all edges of which v is a source or a target.
      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.
      V getEdgeSource​(long edgeIndex)
      Returns the vertex the edgeIndex comes from.
      int getEdgeSourceIndex​(long edgeIndex)
      Returns the vertex the edgeIndex comes from.
      V getEdgeTarget​(long edgeIndex)
      Returns the vertex the edgeIndex points to.
      int getEdgeTargetIndex​(long edgeIndex)
      Returns the index of the vertex the edgeIndex points to.
      long getEdgeWeight​(int source, int target)
      Returns the weight of an edge between source and target.
      long getEdgeWeight​(long edgeIndex)
      Returns the weight of an edge.
      long getEdgeWeight​(V source, V target)
      Returns the weight of an edge.
      java.lang.Iterable<java.lang.Long> getIncomingEdgesOf​(int v)
      Returns an array of edge index, containing all edges of which v is the target.
      java.lang.Iterable<java.lang.Long> getIncomingEdgesOf​(V v)
      Returns an array of edge index, containing all edges of which v is the target.
      int getIndexOfVertex​(V v)  
      int getNumberOfVertices()  
      java.lang.Iterable<java.lang.Long> getOutgoingEdgesOf​(int v)
      Returns an array of edge index, containing all edges of which v is the source.
      java.lang.Iterable<java.lang.Long> getOutgoingEdgesOf​(V v)
      Returns an array of edge index, containing all edges of which v is the source.
      int[] getVertexIndices()  
      V getVertexOfIndex​(int index)  
      V[] getVertices()  
      long getWeightOfHeaviestEdge()
      Returns the weight of the edge with the highest weight.
      void removeEdge​(long edge)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • GraphImplLinearEdge

        public GraphImplLinearEdge​(java.lang.Class<?> clazz)
    • Method Detail

      • addVertex

        public int addVertex​(V x)
        Description copied from interface: Graph
        Add a vertex to the graph. Has no effect if the vertex is already in the graph. Returns the index of the inserted vertex.
        Specified by:
        addVertex in interface Graph<V>
      • addVertices

        public void addVertices​(java.util.Collection<V> xs)
        Specified by:
        addVertices in interface Graph<V>
      • addVertices

        public void addVertices​(V[] xs)
        Specified by:
        addVertices in interface Graph<V>
      • addEdge

        public void addEdge​(int source,
                            int target,
                            long weight)
        Description copied from interface: NormalisedIntGraph
        Adds an edge. If the weight becomes 0, the edge is removed.
        Specified by:
        addEdge in interface NormalisedIntGraph
      • removeEdge

        public void removeEdge​(long edge)
      • addEdge

        public void addEdge​(V source,
                            V target,
                            long weight)
        Description copied from interface: Graph
        Adds an edge. If the weight becomes 0, the edge is removed. Use the integer variant if possible.
        Specified by:
        addEdge in interface Graph<V>
      • getVertexOfIndex

        public V getVertexOfIndex​(int index)
        Specified by:
        getVertexOfIndex in interface Graph<V>
      • getVertices

        public V[] getVertices()
        Specified by:
        getVertices in interface Graph<V>
      • getEdges

        public java.lang.Iterable<java.lang.Long> getEdges()
        Description copied from interface: NormalisedIntGraph
        Gives an iterable that iterates over all edges; The edges that are returned are indices. Notice that the edge weight might NOT be 0.
        Specified by:
        getEdges in interface NormalisedIntGraph
        Returns:
      • containsEdge

        public boolean containsEdge​(V source,
                                    V target)
        Description copied from interface: Graph
        Returns whether the graph contains an edge between source and target.
        Specified by:
        containsEdge in interface Graph<V>
        Returns:
      • containsEdge

        public boolean containsEdge​(int source,
                                    int target)
        Description copied from interface: NormalisedIntGraph
        Returns whether the graph contains an edge between source and target.
        Specified by:
        containsEdge in interface NormalisedIntGraph
        Returns:
      • getEdgeSource

        public V getEdgeSource​(long edgeIndex)
        Description copied from interface: Graph
        Returns the vertex the edgeIndex comes from.
        Specified by:
        getEdgeSource in interface Graph<V>
        Returns:
      • getEdgeTarget

        public V getEdgeTarget​(long edgeIndex)
        Description copied from interface: Graph
        Returns the vertex the edgeIndex points to.
        Specified by:
        getEdgeTarget in interface Graph<V>
        Returns:
      • getEdgeWeight

        public long getEdgeWeight​(int source,
                                  int target)
        Description copied from interface: NormalisedIntGraph
        Returns the weight of an edge between source and target.
        Specified by:
        getEdgeWeight in interface NormalisedIntGraph
        Returns:
      • getEdgeWeight

        public long getEdgeWeight​(V source,
                                  V target)
        Description copied from interface: Graph
        Returns the weight of an edge.
        Specified by:
        getEdgeWeight in interface Graph<V>
        Returns:
      • getIncomingEdgesOf

        public java.lang.Iterable<java.lang.Long> getIncomingEdgesOf​(V v)
        Description copied from interface: Graph
        Returns an array of edge index, containing all edges of which v is the target. Notice that the edge weight might be 0.
        Specified by:
        getIncomingEdgesOf in interface Graph<V>
        Returns:
      • getIncomingEdgesOf

        public java.lang.Iterable<java.lang.Long> getIncomingEdgesOf​(int v)
        Description copied from interface: NormalisedIntGraph
        Returns an array of edge index, containing all edges of which v is the target. Notice that the edge weight might be 0.
        Specified by:
        getIncomingEdgesOf in interface NormalisedIntGraph
        Returns:
      • getOutgoingEdgesOf

        public java.lang.Iterable<java.lang.Long> getOutgoingEdgesOf​(V v)
        Description copied from interface: Graph
        Returns an array of edge index, containing all edges of which v is the source.
        Specified by:
        getOutgoingEdgesOf in interface Graph<V>
        Returns:
      • getOutgoingEdgesOf

        public java.lang.Iterable<java.lang.Long> getOutgoingEdgesOf​(int v)
        Description copied from interface: NormalisedIntGraph
        Returns an array of edge index, containing all edges of which v is the source. Notice that the edge weight might be 0.
        Specified by:
        getOutgoingEdgesOf in interface NormalisedIntGraph
        Returns:
      • getEdgesOf

        public java.lang.Iterable<java.lang.Long> getEdgesOf​(V v)
        Description copied from interface: Graph
        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.
        Specified by:
        getEdgesOf in interface Graph<V>
        Returns:
      • getEdgesOf

        public java.lang.Iterable<java.lang.Long> getEdgesOf​(int indexOfV)
        Description copied from interface: NormalisedIntGraph
        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.
        Specified by:
        getEdgesOf in interface NormalisedIntGraph
        Returns:
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • clone

        public Graph<V> clone()
        Specified by:
        clone in interface Graph<V>
        Specified by:
        clone in interface NormalisedIntGraph
        Overrides:
        clone in class java.lang.Object
        Returns:
        A copy of the graph that is not connected to this graph. Should not clone the vertices themselves.
      • getIndexOfVertex

        public int getIndexOfVertex​(V v)
        Specified by:
        getIndexOfVertex in interface Graph<V>
        Returns:
        the index of the given vertex
      • addVertex

        public void addVertex​(int vertexIndex)