Class IncomingNoReindexSparseDirectedSpecifics

  • All Implemented Interfaces:
    SparseGraphSpecifics

    public class IncomingNoReindexSparseDirectedSpecifics
    extends NoIncomingNoReindexSparseDirectedSpecifics
    Specifics for a sparse directed graph which does not re-index the edges and supports incoming edges. No reindexing means that the edges are numbered in increasing order using the order that the user loads the edges. Support for incoming edges is provided but is initialized lazily the first time the user accessed a corresponding method.
    • Field Detail

      • inIncidenceMatrix

        protected CSRBooleanMatrix inIncidenceMatrix
        Incidence matrix with incoming edges
    • Constructor Detail

      • IncomingNoReindexSparseDirectedSpecifics

        public IncomingNoReindexSparseDirectedSpecifics​(int numVertices,
                                                        int numEdges,
                                                        java.util.function.Supplier<java.util.stream.Stream<Pair<java.lang.Integer,​java.lang.Integer>>> edges,
                                                        boolean lazyIncomingEdges)
        Create a new graph from an edge list.
        Parameters:
        numVertices - the number of vertices
        numEdges - the number of edges
        edges - a supplier of an edge stream
        lazyIncomingEdges - whether to lazily support incoming edge traversals, only if actually needed by the user
    • Method Detail

      • degreeOf

        public long degreeOf​(java.lang.Integer vertex)
        Description copied from interface: SparseGraphSpecifics
        Returns the degree of the specified vertex.

        A degree of a vertex in an undirected graph is the number of edges touching that vertex. Edges with same source and target vertices (self-loops) are counted twice.

        In directed graphs this method returns the sum of the "in degree" and the "out degree".

        Specified by:
        degreeOf in interface SparseGraphSpecifics
        Overrides:
        degreeOf in class NoIncomingNoReindexSparseDirectedSpecifics
        Parameters:
        vertex - vertex whose degree is to be calculated.
        Returns:
        the degree of the specified vertex.
      • edgesOf

        public java.util.Set<java.lang.Integer> edgesOf​(java.lang.Integer vertex)
        Description copied from interface: SparseGraphSpecifics
        Returns a set of all edges touching the specified vertex. If no edges are touching the specified vertex returns an empty set.
        Specified by:
        edgesOf in interface SparseGraphSpecifics
        Overrides:
        edgesOf in class NoIncomingNoReindexSparseDirectedSpecifics
        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

        public long inDegreeOf​(java.lang.Integer vertex)
        Description copied from interface: SparseGraphSpecifics
        Returns the "in degree" of the specified vertex.

        The "in degree" of a vertex in a directed graph is the number of inward directed edges from that vertex. See http://mathworld.wolfram.com/Indegree.html.

        In the case of undirected graphs this method returns the number of edges touching the vertex. Edges with same source and target vertices (self-loops) are counted twice.

        Specified by:
        inDegreeOf in interface SparseGraphSpecifics
        Overrides:
        inDegreeOf in class NoIncomingNoReindexSparseDirectedSpecifics
        Parameters:
        vertex - vertex whose degree is to be calculated.
        Returns:
        the degree of the specified vertex.
      • incomingEdgesOf

        public java.util.Set<java.lang.Integer> incomingEdgesOf​(java.lang.Integer vertex)
        Description copied from interface: SparseGraphSpecifics
        Returns a set of all edges incoming into the specified vertex.

        In the case of undirected graphs this method returns all edges touching the vertex, thus, some of the returned edges may have their source and target vertices in the opposite order.

        Specified by:
        incomingEdgesOf in interface SparseGraphSpecifics
        Overrides:
        incomingEdgesOf in class NoIncomingNoReindexSparseDirectedSpecifics
        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.
      • indexIncomingEdges

        protected void indexIncomingEdges()
        Build the index for the incoming edges.