Class ImmutableUndirectedBigGraphAdapter

    • Constructor Detail

      • ImmutableUndirectedBigGraphAdapter

        public ImmutableUndirectedBigGraphAdapter​(it.unimi.dsi.big.webgraph.ImmutableGraph immutableGraph)
        Creates an adapter for an undirected (i.e., symmetric) big immutable graph.

        It is responsibility of the caller that the provided graph has is symmetric (for each arc x → y there is an arc y → x). If this property is not true, results will be unpredictable.

        Parameters:
        immutableGraph - a symmetric big immutable graph.
    • Method Detail

      • makeEdge

        protected it.unimi.dsi.fastutil.longs.LongLongSortedPair makeEdge​(long x,
                                                                          long y)
        Specified by:
        makeEdge in class AbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>
      • containsEdge

        public boolean containsEdge​(it.unimi.dsi.fastutil.longs.LongLongSortedPair e)
        Description copied from interface: Graph
        Returns true if this graph contains the specified edge. More formally, returns true if and only if this graph contains an edge e2 such that e.equals(e2). If the specified edge is null returns false.
        Specified by:
        containsEdge in interface Graph<java.lang.Long,​it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        Parameters:
        e - edge whose presence in this graph is to be tested.
        Returns:
        true if this graph contains the specified edge.
      • edgeSet

        public java.util.Set<it.unimi.dsi.fastutil.longs.LongLongSortedPair> edgeSet()
        Description copied from interface: Graph
        Returns a set of the edges contained in this graph. The set is backed by the graph, so changes to the graph are reflected in the set. If the graph is modified while an iteration over the set is in progress, the results of the iteration are undefined.

        The graph implementation may maintain a particular set ordering (e.g. via LinkedHashSet) for deterministic iteration, but this is not required. It is the responsibility of callers who rely on this behavior to only use graph implementations which support it.

        Specified by:
        edgeSet in interface Graph<java.lang.Long,​it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        Returns:
        a set of the edges contained in this graph.
      • degreeOf

        public int degreeOf​(java.lang.Long vertex)
        Description copied from interface: Graph
        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 Graph<java.lang.Long,​it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        Parameters:
        vertex - vertex whose degree is to be calculated.
        Returns:
        the degree of the specified vertex.
      • edgesOf

        public java.util.Set<it.unimi.dsi.fastutil.longs.LongLongSortedPair> edgesOf​(java.lang.Long vertex)
        Description copied from interface: Graph
        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 Graph<java.lang.Long,​it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        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 int inDegreeOf​(java.lang.Long vertex)
        Description copied from interface: Graph
        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 Graph<java.lang.Long,​it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        Parameters:
        vertex - vertex whose degree is to be calculated.
        Returns:
        the degree of the specified vertex.
      • incomingEdgesOf

        public java.util.Set<it.unimi.dsi.fastutil.longs.LongLongSortedPair> incomingEdgesOf​(java.lang.Long vertex)
        Description copied from interface: Graph
        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 Graph<java.lang.Long,​it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        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

        public int outDegreeOf​(java.lang.Long vertex)
        Description copied from interface: Graph
        Returns the "out degree" of the specified vertex.

        The "out degree" of a vertex in a directed graph is the number of outward directed edges from that vertex. See http://mathworld.wolfram.com/Outdegree.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:
        outDegreeOf in interface Graph<java.lang.Long,​it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        Parameters:
        vertex - vertex whose degree is to be calculated.
        Returns:
        the degree of the specified vertex.
      • outgoingEdgesOf

        public java.util.Set<it.unimi.dsi.fastutil.longs.LongLongSortedPair> outgoingEdgesOf​(java.lang.Long vertex)
        Description copied from interface: Graph
        Returns a set of all edges outgoing from 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:
        outgoingEdgesOf in interface Graph<java.lang.Long,​it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        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.
      • removeEdge

        public it.unimi.dsi.fastutil.longs.LongLongSortedPair removeEdge​(java.lang.Long sourceVertex,
                                                                         java.lang.Long targetVertex)
        Description copied from interface: Graph
        Removes an edge going from source vertex to target vertex, if such vertices and such edge exist in this graph. Returns the edge if removed or null otherwise.
        Specified by:
        removeEdge in interface Graph<java.lang.Long,​it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        Overrides:
        removeEdge in class AbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        Parameters:
        sourceVertex - source vertex of the edge.
        targetVertex - target vertex of the edge.
        Returns:
        The removed edge, or null if no edge removed.
      • removeEdge

        public boolean removeEdge​(it.unimi.dsi.fastutil.longs.LongLongSortedPair e)
        Description copied from interface: Graph
        Removes the specified edge from the graph. Removes the specified edge from this graph if it is present. More formally, removes an edge e2 such that e2.equals(e), if the graph contains such edge. Returns true if the graph contained the specified edge. (The graph will not contain the specified edge once the call returns).

        If the specified edge is null returns false.

        Specified by:
        removeEdge in interface Graph<java.lang.Long,​it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        Overrides:
        removeEdge in class AbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        Parameters:
        e - edge to be removed from this graph, if present.
        Returns:
        true if and only if the graph contained the specified edge.
      • removeVertex

        public boolean removeVertex​(java.lang.Long v)
        Description copied from interface: Graph
        Removes the specified vertex from this graph including all its touching edges if present. More formally, if the graph contains a vertex u such that u.equals(v), the call removes all edges that touch u and then removes u itself. If no such u is found, the call leaves the graph unchanged. Returns true if the graph contained the specified vertex. (The graph will not contain the specified vertex once the call returns).

        If the specified vertex is null returns false.

        Specified by:
        removeVertex in interface Graph<java.lang.Long,​it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        Overrides:
        removeVertex in class AbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        Parameters:
        v - vertex to be removed from this graph, if present.
        Returns:
        true if the graph contained the specified vertex; false otherwise.
      • vertexSet

        public java.util.Set<java.lang.Long> vertexSet()
        Description copied from interface: Graph
        Returns a set of the vertices contained in this graph. The set is backed by the graph, so changes to the graph are reflected in the set. If the graph is modified while an iteration over the set is in progress, the results of the iteration are undefined.

        The graph implementation may maintain a particular set ordering (e.g. via LinkedHashSet) for deterministic iteration, but this is not required. It is the responsibility of callers who rely on this behavior to only use graph implementations which support it.

        Specified by:
        vertexSet in interface Graph<java.lang.Long,​it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        Overrides:
        vertexSet in class AbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        Returns:
        a set view of the vertices contained in this graph.
      • getEdgeSource

        public java.lang.Long getEdgeSource​(it.unimi.dsi.fastutil.longs.LongLongSortedPair e)
        Description copied from interface: Graph
        Returns the source vertex of an edge. For an undirected graph, source and target are distinguishable designations (but without any mathematical meaning).
        Specified by:
        getEdgeSource in interface Graph<java.lang.Long,​it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        Overrides:
        getEdgeSource in class AbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        Parameters:
        e - edge of interest
        Returns:
        source vertex
      • getEdgeTarget

        public java.lang.Long getEdgeTarget​(it.unimi.dsi.fastutil.longs.LongLongSortedPair e)
        Description copied from interface: Graph
        Returns the target vertex of an edge. For an undirected graph, source and target are distinguishable designations (but without any mathematical meaning).
        Specified by:
        getEdgeTarget in interface Graph<java.lang.Long,​it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        Overrides:
        getEdgeTarget in class AbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        Parameters:
        e - edge of interest
        Returns:
        target vertex
      • getEdgeWeight

        public double getEdgeWeight​(it.unimi.dsi.fastutil.longs.LongLongSortedPair e)
        Description copied from interface: Graph
        Returns the weight assigned to a given edge. Unweighted graphs return 1.0 (as defined by Graph.DEFAULT_EDGE_WEIGHT), allowing weighted-graph algorithms to apply to them when meaningful.
        Specified by:
        getEdgeWeight in interface Graph<java.lang.Long,​it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        Overrides:
        getEdgeWeight in class AbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        Parameters:
        e - edge of interest
        Returns:
        edge weight
      • setEdgeWeight

        public void setEdgeWeight​(it.unimi.dsi.fastutil.longs.LongLongSortedPair e,
                                  double weight)
        Description copied from interface: Graph
        Assigns a weight to an edge.
        Specified by:
        setEdgeWeight in interface Graph<java.lang.Long,​it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        Overrides:
        setEdgeWeight in class AbstractImmutableBigGraphAdapter<it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        Parameters:
        e - edge on which to set weight
        weight - new weight for edge
      • getType

        public GraphType getType()
        Description copied from interface: Graph
        Get the graph type. The graph type can be used to query for additional metadata such as whether the graph supports directed or undirected edges, self-loops, multiple (parallel) edges, weights, etc.
        Specified by:
        getType in interface Graph<java.lang.Long,​it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        Returns:
        the graph type
      • iterables

        public GraphIterables<java.lang.Long,​it.unimi.dsi.fastutil.longs.LongLongSortedPair> iterables()
        Description copied from interface: Graph
        Access the graph using the GraphIterables interface. This allows accessing graphs without the restrictions imposed by 32-bit arithmetic. Moreover, graph implementations are free to implement this interface without explicitly materializing intermediate results.
        Specified by:
        iterables in interface Graph<java.lang.Long,​it.unimi.dsi.fastutil.longs.LongLongSortedPair>
        Returns:
        the graph iterables