java.lang.Object
es.uam.eps.ir.relison.graph.multigraph.edges.fast.FastMultiEdges
All Implemented Interfaces:
MultiEdges
Direct Known Subclasses:
FastDirectedUnweightedMultiEdges, FastDirectedWeightedMultiEdges, FastUndirectedUnweightedMultiEdges, FastUndirectedWeightedMultiEdges

public abstract class FastMultiEdges
extends java.lang.Object
implements MultiEdges
Abstract fast implementation of class MultiEdges.
  • Field Details

    • weights

      protected final AutoRelation<java.util.List<java.lang.Double>> weights
      Relation for storing the weights of the edges.
    • types

      protected final AutoRelation<java.util.List<java.lang.Integer>> types
      Relation for storing the types of the edges.
    • numEdges

      protected long numEdges
      Number of edges.
  • Constructor Details

    • FastMultiEdges

      public FastMultiEdges​(AutoRelation<java.util.List<java.lang.Double>> weights, AutoRelation<java.util.List<java.lang.Integer>> types)
      Constructor.
      Parameters:
      weights - The weights of the edges.
      types - The types of the edges
  • Method Details

    • containsEdge

      public boolean containsEdge​(int orig, int dest)
      Description copied from interface: MultiEdges
      Checks if an edge exists.
      Specified by:
      containsEdge in interface MultiEdges
      Parameters:
      orig - The origin endpoint
      dest - The destiny endpoint
      Returns:
      true if the edge exists, false if not.
    • getEdgeWeights

      public java.util.List<java.lang.Double> getEdgeWeights​(int orig, int dest)
      Description copied from interface: MultiEdges
      Gets the weight of an edge.
      Specified by:
      getEdgeWeights in interface MultiEdges
      Parameters:
      orig - The origin endpoint.
      dest - The destiny endpoint.
      Returns:
      the value if the edge exists, the default error value if not.
    • getEdgeTypes

      public java.util.List<java.lang.Integer> getEdgeTypes​(int orig, int dest)
      Description copied from interface: MultiEdges
      Gets the type of an edge.
      Specified by:
      getEdgeTypes in interface MultiEdges
      Parameters:
      orig - The origin endpoint.
      dest - The destiny endpoint.
      Returns:
      the type if the edge exists, the default error value if not.
    • addUser

      public boolean addUser​(int node)
      Description copied from interface: MultiEdges
      Adds a user to the edges.
      Specified by:
      addUser in interface MultiEdges
      Parameters:
      node - Identifier of the user
      Returns:
      the user.
    • getNumEdges

      public int getNumEdges​(int orig, int dest)
      Description copied from interface: MultiEdges
      Gets the number of existing edges between two destinies
      Specified by:
      getNumEdges in interface MultiEdges
      Parameters:
      orig - The origin endpoint
      dest - The destiny endpoint
      Returns:
      the number of edges
    • getNumEdges

      public long getNumEdges()
      Description copied from interface: MultiEdges
      Obtains the number of edges
      Specified by:
      getNumEdges in interface MultiEdges
      Returns:
      the number of edges
    • getIncidentCount

      public int getIncidentCount​(int dest)
      Description copied from interface: MultiEdges
      Gets the number of incident edges to a node
      Specified by:
      getIncidentCount in interface MultiEdges
      Parameters:
      dest - Destiny node
      Returns:
      the number of incident edges
    • getAdjacentCount

      public int getAdjacentCount​(int dest)
      Description copied from interface: MultiEdges
      Gets the number of adjacent edges to a node
      Specified by:
      getAdjacentCount in interface MultiEdges
      Parameters:
      dest - Origin node
      Returns:
      the number of adjacent edges
    • getIsolatedNodes

      public java.util.stream.IntStream getIsolatedNodes()
      Description copied from interface: MultiEdges
      Obtains the set of nodes which do not have any neighbor.
      Specified by:
      getIsolatedNodes in interface MultiEdges
      Returns:
      a stream containing the set of nodes which do not have neighbors.
    • hasAdjacentEdges

      public boolean hasAdjacentEdges​(int node)
      Description copied from interface: MultiEdges
      Checks if a node has adjacent edges.
      Specified by:
      hasAdjacentEdges in interface MultiEdges
      Parameters:
      node - the identifier of the node
      Returns:
      true if it has adjacent edges, false otherwise
    • hasIncidentEdges

      public boolean hasIncidentEdges​(int node)
      Description copied from interface: MultiEdges
      Checks if a node has incident edges.
      Specified by:
      hasIncidentEdges in interface MultiEdges
      Parameters:
      node - the identifier of the node
      Returns:
      true if it has incident edges, false otherwise
    • hasEdges

      public boolean hasEdges​(int node)
      Description copied from interface: MultiEdges
      Checks if a node has adjacent or incident edges.
      Specified by:
      hasEdges in interface MultiEdges
      Parameters:
      node - the identifier of the node
      Returns:
      true if it has adjacent or incident edges, false otherwise
    • hasMutualEdges

      public boolean hasMutualEdges​(int node)
      Description copied from interface: MultiEdges
      Checks if a node has mutual edges.
      Specified by:
      hasMutualEdges in interface MultiEdges
      Parameters:
      node - the identifier of the node
      Returns:
      true if it has mutual edges, false otherwise