Class AbstractFastGraph<V>

java.lang.Object
es.uam.eps.ir.relison.graph.fast.AbstractFastGraph<V>
Type Parameters:
V - Type of the vertices.
All Implemented Interfaces:
FastGraph<V>, Graph<V>, ReducedIndex<V>, java.io.Serializable
Direct Known Subclasses:
FastDirectedUnweightedGraph, FastDirectedWeightedGraph, FastTree, FastUndirectedUnweightedGraph, FastUndirectedWeightedGraph

public abstract class AbstractFastGraph<V>
extends java.lang.Object
implements FastGraph<V>, java.io.Serializable
Fast implementation of a graph.
See Also:
Serialized Form
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected Edges edges
    Edges in the network.
    protected Index<V> vertices
    Index of vertices.
  • Constructor Summary

    Constructors 
    Constructor Description
    AbstractFastGraph​(Index<V> vertices, Edges edges)
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    boolean addEdge​(int nodeA, int nodeB, double weight, int type)
    Uncontrolled edge addition method, using ids.
    boolean addEdge​(V nodeA, V nodeB, double weight, int type, boolean insertNodes)
    Adds a weighted edge to the graph.
    boolean addNode​(V node)
    Adds a new node to the graph.
    Graph<V> complement()
    Complements the graph
    boolean containsEdge​(int uidx, int vidx)
    Checks whether the network contains an edge or not.
    boolean containsEdge​(V nodeA, V nodeB)
    Checks if an edge exists in the graph.
    boolean containsVertex​(V node)
    Checks if a vertex exists in the graph.
    Index<V> getAdjacencyMatrixMap()
    For an adjacency matrix, obtains the mapping between indexes and nodes.
    int getAdjacentEdgesCount​(V node)
    Calculates the number of adjacent edges of a node (not necessarily equal to the out-degree).
    java.util.stream.Stream<Weight<V,​java.lang.Integer>> getAdjacentMutualNodesTypes​(V node)
    Given a node, finds the types of the edges towards the nodes u such that the edge (node to u) and the edge (u to node) are in the graph.
    java.util.stream.Stream<Weight<V,​java.lang.Double>> getAdjacentMutualNodesWeights​(V node)
    Given a node, finds the weights of the edges towards the nodes u such that the edge (node to u) and the edge (u to node) are in the graph.
    java.util.stream.Stream<V> getAdjacentNodes​(V node)
    Given a node, finds all the nodes u such that the edge (node to u) is in the graph.
    java.util.stream.Stream<Weight<V,​java.lang.Integer>> getAdjacentNodesTypes​(V node)
    Given a node, finds the types of the edges towards the nodes u such that the edge (node to u) is in the graph.
    java.util.stream.Stream<Weight<V,​java.lang.Double>> getAdjacentNodesWeights​(V node)
    Given a node, finds the weights of the edges towards the nodes u such that the edge (node to u) is in the graph.
    java.util.stream.Stream<V> getAllNodes()
    Gets all the nodes in the graph.
    java.util.stream.IntStream getAllNodesIds()
    Obtains the identifiers of all the nodes in the network.
    long getEdgeCount()
    Measures the number of edges in the network.
    int getEdgeType​(V nodeA, V nodeB)
    Obtains the type of an edge in the graph
    double getEdgeWeight​(int uidx, int vidx)
    Obtains the weight of an edge, given the identifiers of the involved nodes.
    double getEdgeWeight​(V nodeA, V nodeB)
    Obtains the weight of an edge in the graph
    int getIncidentEdgesCount​(V node)
    Calculates the number of incident edges of a node (not necessarily equal to the in-degree).
    java.util.stream.Stream<Weight<V,​java.lang.Integer>> getIncidentMutualNodesTypes​(V node)
    Given a node, finds the types of the edges from the nodes u such that the edge (node to u) and the edge (u to node) are in the graph.
    java.util.stream.Stream<Weight<V,​java.lang.Double>> getIncidentMutualNodesWeights​(V node)
    Given a node, finds the weights of the edges from the nodes u such that the edge (node to u) and the edge (u to node) are in the graph.
    java.util.stream.Stream<V> getIncidentNodes​(V node)
    Given a node, finds all the nodes u such that the edge (u to node) is in the graph.
    java.util.stream.Stream<Weight<V,​java.lang.Integer>> getIncidentNodesTypes​(V node)
    Given a node, finds the types of the edges from the nodes u such that the edge (u to node) is in the graph.
    java.util.stream.Stream<Weight<V,​java.lang.Double>> getIncidentNodesWeights​(V node)
    Given a node, finds the weights of the edges from the nodes u such that the edge (u to node) is in the graph.
    Index<V> getIndex()
    Obtains the index for the vertices.
    java.util.stream.IntStream getIsolatedNodeIds()
    Obtains the set of isolated nodes in the graph.
    java.util.stream.Stream<V> getIsolatedNodes()
    Obtains the set of nodes without edges.
    int getMutualEdgesCount​(V node)
    Calculates the total number of adjacent edges of a node such that there is an incident reciprocal link towards the node.
    java.util.stream.Stream<V> getMutualNodes​(V node)
    Given a node, finds all the nodes u such that the edges (node to u) and (u to node) are in the graph.
    java.util.stream.Stream<Weight<V,​java.lang.Integer>> getMutualNodesTypes​(V node)
    Given a node, find the types of edges from the nodes u such that the edge (node to u) and the edge (u to node) are in the graph.
    java.util.stream.Stream<Weight<V,​java.lang.Double>> getMutualNodesWeights​(V node)
    Given a node, finds the weights of the edges towards and from the nodes u such that the edge (node to u) and the edge (u to node) are in the graph.
    java.util.stream.Stream<java.lang.Integer> getNeighborhood​(int uidx, EdgeOrientation orientation)
    Obtains the neighborhood of a node, given its identifier.
    java.util.stream.Stream<EdgeType> getNeighborhoodTypes​(int uidx, EdgeOrientation orientation)
    Obtains the neighborhood of a node and the type of the edges to each other, given its identifier.
    java.util.stream.Stream<es.uam.eps.ir.ranksys.fast.preference.IdxPref> getNeighborhoodWeights​(int uidx, EdgeOrientation orientation)
    Obtains the neighborhood of a node and the weight of the edges to each other, given its identifier.
    java.util.stream.Stream<V> getNeighbourhood​(V node, EdgeOrientation direction)
    Gets all the nodes in the neighbourhood of a node given by a direction.
    java.util.stream.Stream<V> getNeighbourNodes​(V node)
    Given a node, finds all the nodes u so that either (node to u) or (u to node) are in the graph.
    java.util.stream.Stream<Weight<V,​java.lang.Integer>> getNeighbourNodesTypes​(V node)
    Given a node, finds the types of the edges from the nodes u such that the edge (node to u) or the edge (u to node) are in the graph.
    java.util.stream.Stream<Weight<V,​java.lang.Double>> getNeighbourNodesWeights​(V node)
    Given a node, finds the weights of the edges from the nodes u such that the edge (node to u) or the edge (u to node) are in the graph.
    java.util.stream.IntStream getNodesIdsWithEdges​(EdgeOrientation direction)
    Obtains the identifiers of the nodes which have edges.
    java.util.stream.Stream<V> getNodesWithAdjacentNeighbors()
    Obtains the set of nodes which have adjacent edges.
    java.util.stream.Stream<V> getNodesWithIncidentNeighbors()
    Obtains the set of nodes which have incident edges.
    java.util.stream.Stream<V> getNodesWithMutualNeighbors()
    Obtains the set of nodes having mutual edges.
    java.util.stream.Stream<V> getNodesWithNeighbors()
    Obtains the set of nodes having either incident or adjacent edges.
    java.util.stream.Stream<V> getNodesWithNeighbors​(EdgeOrientation direction)
    Obtains the set of nodes with edges in a particular direction.
    long getVertexCount()
    Measures the number of nodes in the network.
    boolean hasAdjacentNeighbors​(V u)
    Checks if the user has adjacent edges or not.
    boolean hasIncidentNeighbors​(V u)
    Checks if the user has incident edges or not.
    boolean hasMutualNeighbors​(V u)
    Checks if the user has mutual edges.
    boolean hasNeighbors​(V u)
    Checks if the user shares at least an edge with other user.
    V idx2object​(int idx)
    Gets the object corresponding to a certain index.
    int object2idx​(V u)
    Gets the index of a given object.
    boolean removeEdge​(V orig, V dest)
    Removes an edge from the graph.
    boolean removeNode​(V u)
    Removes a node from the graph.
    boolean updateEdgeType​(V nodeA, V nodeB, int type)
    Updates the type of an edge.
    boolean updateEdgeWeight​(int nodeA, int nodeB, double weight)
    Uncontrolled edge update method, using ids.
    boolean updateEdgeWeight​(V nodeA, V nodeB, double weight)
    Updates the weight of an edge.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • vertices

      protected final Index<V> vertices
      Index of vertices.
    • edges

      protected final Edges edges
      Edges in the network.
  • Constructor Details

    • AbstractFastGraph

      public AbstractFastGraph​(Index<V> vertices, Edges edges)
      Constructor.
      Parameters:
      vertices - An index for the vertices of the graph.
      edges - Edges.
  • Method Details

    • addNode

      public boolean addNode​(V node)
      Description copied from interface: Graph
      Adds a new node to the graph.
      Specified by:
      addNode in interface Graph<V>
      Parameters:
      node - The new node to add.
      Returns:
      true if the node is correctly added, false if not.
    • addEdge

      public boolean addEdge​(V nodeA, V nodeB, double weight, int type, boolean insertNodes)
      Description copied from interface: Graph
      Adds a weighted edge to the graph.
      Specified by:
      addEdge in interface Graph<V>
      Parameters:
      nodeA - The incident node.
      nodeB - The adjacent node.
      weight - The weight.
      type - The edge type.
      insertNodes - If true, nodes will be inserted if they do not exist. If false, the edge will only be added if both nodes are inserted.
      Returns:
      if the edge is correctly added, false if not.
    • getAllNodes

      public java.util.stream.Stream<V> getAllNodes()
      Description copied from interface: Graph
      Gets all the nodes in the graph.
      Specified by:
      getAllNodes in interface Graph<V>
      Returns:
      a stream of all the nodes in the graph.
    • getIncidentNodes

      public java.util.stream.Stream<V> getIncidentNodes​(V node)
      Description copied from interface: Graph
      Given a node, finds all the nodes u such that the edge (u to node) is in the graph.
      Specified by:
      getIncidentNodes in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream of the incident nodes.
    • getAdjacentNodes

      public java.util.stream.Stream<V> getAdjacentNodes​(V node)
      Description copied from interface: Graph
      Given a node, finds all the nodes u such that the edge (node to u) is in the graph.
      Specified by:
      getAdjacentNodes in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream containing the adjacent nodes.
    • getNeighbourNodes

      public java.util.stream.Stream<V> getNeighbourNodes​(V node)
      Description copied from interface: Graph
      Given a node, finds all the nodes u so that either (node to u) or (u to node) are in the graph.
      Specified by:
      getNeighbourNodes in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream containing all the nodes in the neighbourhood.
    • getMutualNodes

      public java.util.stream.Stream<V> getMutualNodes​(V node)
      Description copied from interface: Graph
      Given a node, finds all the nodes u such that the edges (node to u) and (u to node) are in the graph.
      Specified by:
      getMutualNodes in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream containing all the nodes which share reciprocal links.
    • getNeighbourhood

      public java.util.stream.Stream<V> getNeighbourhood​(V node, EdgeOrientation direction)
      Description copied from interface: Graph
      Gets all the nodes in the neighbourhood of a node given by a direction.
      Specified by:
      getNeighbourhood in interface Graph<V>
      Parameters:
      node - The node.
      direction - The direction of the links.
      Returns:
      A stream containing the corresponding neighbourhood.
    • getIncidentEdgesCount

      public int getIncidentEdgesCount​(V node)
      Description copied from interface: Graph
      Calculates the number of incident edges of a node (not necessarily equal to the in-degree).
      Specified by:
      getIncidentEdgesCount in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      the number of incident neighbours of the node if it is contained in the graph, -1 if not.
    • getAdjacentEdgesCount

      public int getAdjacentEdgesCount​(V node)
      Description copied from interface: Graph
      Calculates the number of adjacent edges of a node (not necessarily equal to the out-degree).
      Specified by:
      getAdjacentEdgesCount in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      the degree of the node if it is contained in the graph, -1 if not.
    • getMutualEdgesCount

      public int getMutualEdgesCount​(V node)
      Description copied from interface: Graph
      Calculates the total number of adjacent edges of a node such that there is an incident reciprocal link towards the node.
      Specified by:
      getMutualEdgesCount in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      the number of reciprocal links starting from the node.
    • containsVertex

      public boolean containsVertex​(V node)
      Description copied from interface: Graph
      Checks if a vertex exists in the graph.
      Specified by:
      containsVertex in interface Graph<V>
      Parameters:
      node - The vertex to check.
      Returns:
      true if the vertex is contained in the graph, false if not.
    • containsEdge

      public boolean containsEdge​(V nodeA, V nodeB)
      Description copied from interface: Graph
      Checks if an edge exists in the graph.
      Specified by:
      containsEdge in interface Graph<V>
      Parameters:
      nodeA - The incident node.
      nodeB - The adjacent node.
      Returns:
      true if the edge is contained in the graph, false if not.
    • getEdgeWeight

      public double getEdgeWeight​(V nodeA, V nodeB)
      Description copied from interface: Graph
      Obtains the weight of an edge in the graph
      Specified by:
      getEdgeWeight in interface Graph<V>
      Parameters:
      nodeA - The incident node.
      nodeB - The adjacent node.
      Returns:
      The corresponding weight. If the edge does not exist, NaN
    • updateEdgeWeight

      public boolean updateEdgeWeight​(V nodeA, V nodeB, double weight)
      Description copied from interface: Graph
      Updates the weight of an edge.
      Specified by:
      updateEdgeWeight in interface Graph<V>
      Parameters:
      nodeA - The incident node.
      nodeB - The adjacent node.
      weight - The new weight.
      Returns:
      true if everything goes OK, false if the edge does not exist or something fails.
    • updateEdgeType

      public boolean updateEdgeType​(V nodeA, V nodeB, int type)
      Description copied from interface: Graph
      Updates the type of an edge.
      Specified by:
      updateEdgeType in interface Graph<V>
      Parameters:
      nodeA - The incident node.
      nodeB - The adjacent node.
      type - The new type.
      Returns:
      true if everything goes OK, false if the edge does not exist or something fails.
    • getIncidentNodesWeights

      public java.util.stream.Stream<Weight<V,​java.lang.Double>> getIncidentNodesWeights​(V node)
      Description copied from interface: Graph
      Given a node, finds the weights of the edges from the nodes u such that the edge (u to node) is in the graph.
      Specified by:
      getIncidentNodesWeights in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream containing the adjacent nodes and weights.
    • getAdjacentNodesWeights

      public java.util.stream.Stream<Weight<V,​java.lang.Double>> getAdjacentNodesWeights​(V node)
      Description copied from interface: Graph
      Given a node, finds the weights of the edges towards the nodes u such that the edge (node to u) is in the graph.
      Specified by:
      getAdjacentNodesWeights in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream containing the adjacent nodes and weights.
    • getNeighbourNodesWeights

      public java.util.stream.Stream<Weight<V,​java.lang.Double>> getNeighbourNodesWeights​(V node)
      Description copied from interface: Graph
      Given a node, finds the weights of the edges from the nodes u such that the edge (node to u) or the edge (u to node) are in the graph.
      Specified by:
      getNeighbourNodesWeights in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream containing all the nodes in the neighbourhood and weights.
    • getAdjacentMutualNodesWeights

      public java.util.stream.Stream<Weight<V,​java.lang.Double>> getAdjacentMutualNodesWeights​(V node)
      Description copied from interface: Graph
      Given a node, finds the weights of the edges towards the nodes u such that the edge (node to u) and the edge (u to node) are in the graph.
      Specified by:
      getAdjacentMutualNodesWeights in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream containing all the nodes in the neighbourhood and weights.
    • getIncidentMutualNodesWeights

      public java.util.stream.Stream<Weight<V,​java.lang.Double>> getIncidentMutualNodesWeights​(V node)
      Description copied from interface: Graph
      Given a node, finds the weights of the edges from the nodes u such that the edge (node to u) and the edge (u to node) are in the graph.
      Specified by:
      getIncidentMutualNodesWeights in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream containing all the nodes in the neighbourhood and weights.
    • getMutualNodesWeights

      public java.util.stream.Stream<Weight<V,​java.lang.Double>> getMutualNodesWeights​(V node)
      Description copied from interface: Graph
      Given a node, finds the weights of the edges towards and from the nodes u such that the edge (node to u) and the edge (u to node) are in the graph. It finds the average value of the outgoing and incoming links.
      Specified by:
      getMutualNodesWeights in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream containing all the nodes in the neighbourhood and weights.
    • getMutualNodesTypes

      public java.util.stream.Stream<Weight<V,​java.lang.Integer>> getMutualNodesTypes​(V node)
      Description copied from interface: Graph
      Given a node, find the types of edges from the nodes u such that the edge (node to u) and the edge (u to node) are in the graph.
      Specified by:
      getMutualNodesTypes in interface Graph<V>
      Parameters:
      node - the node.
      Returns:
      a stream containing all the nodes in the neighbourhood and types.
    • getEdgeType

      public int getEdgeType​(V nodeA, V nodeB)
      Description copied from interface: Graph
      Obtains the type of an edge in the graph
      Specified by:
      getEdgeType in interface Graph<V>
      Parameters:
      nodeA - The incident node.
      nodeB - The adjacent node.
      Returns:
      The corresponding type. If the edge does not exist, -1.
    • getIncidentNodesTypes

      public java.util.stream.Stream<Weight<V,​java.lang.Integer>> getIncidentNodesTypes​(V node)
      Description copied from interface: Graph
      Given a node, finds the types of the edges from the nodes u such that the edge (u to node) is in the graph.
      Specified by:
      getIncidentNodesTypes in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream of the incident nodes and types.
    • getAdjacentNodesTypes

      public java.util.stream.Stream<Weight<V,​java.lang.Integer>> getAdjacentNodesTypes​(V node)
      Description copied from interface: Graph
      Given a node, finds the types of the edges towards the nodes u such that the edge (node to u) is in the graph.
      Specified by:
      getAdjacentNodesTypes in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream containing the adjacent nodes and types.
    • getNeighbourNodesTypes

      public java.util.stream.Stream<Weight<V,​java.lang.Integer>> getNeighbourNodesTypes​(V node)
      Description copied from interface: Graph
      Given a node, finds the types of the edges from the nodes u such that the edge (node to u) or the edge (u to node) are in the graph.
      Specified by:
      getNeighbourNodesTypes in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream containing all the nodes in the neighbourhood and types.
    • getAdjacentMutualNodesTypes

      public java.util.stream.Stream<Weight<V,​java.lang.Integer>> getAdjacentMutualNodesTypes​(V node)
      Description copied from interface: Graph
      Given a node, finds the types of the edges towards the nodes u such that the edge (node to u) and the edge (u to node) are in the graph.
      Specified by:
      getAdjacentMutualNodesTypes in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream containing all the nodes in the neighbourhood and types.
    • getIncidentMutualNodesTypes

      public java.util.stream.Stream<Weight<V,​java.lang.Integer>> getIncidentMutualNodesTypes​(V node)
      Description copied from interface: Graph
      Given a node, finds the types of the edges from the nodes u such that the edge (node to u) and the edge (u to node) are in the graph.
      Specified by:
      getIncidentMutualNodesTypes in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream containing all the nodes in the neighbourhood and types.
    • getVertexCount

      public long getVertexCount()
      Description copied from interface: Graph
      Measures the number of nodes in the network.
      Specified by:
      getVertexCount in interface Graph<V>
      Returns:
      the number of nodes.
    • getEdgeCount

      public long getEdgeCount()
      Description copied from interface: Graph
      Measures the number of edges in the network.
      Specified by:
      getEdgeCount in interface Graph<V>
      Returns:
      the number of edges.
    • removeEdge

      public boolean removeEdge​(V orig, V dest)
      Description copied from interface: Graph
      Removes an edge from the graph.
      Specified by:
      removeEdge in interface Graph<V>
      Parameters:
      orig - The incident node of the edge to remove.
      dest - The adjacent node of the edge to remove.
      Returns:
      true if everything went ok, false if not.
    • removeNode

      public boolean removeNode​(V u)
      Description copied from interface: Graph
      Removes a node from the graph.
      Specified by:
      removeNode in interface Graph<V>
      Parameters:
      u - Node to remove.
      Returns:
      true if the edge is correctly removed, false if not.
    • object2idx

      public int object2idx​(V u)
      Description copied from interface: ReducedIndex
      Gets the index of a given object.
      Specified by:
      object2idx in interface ReducedIndex<V>
      Parameters:
      u - Object to obtain.
      Returns:
      the index if the object exists, -1 if not.
    • idx2object

      public V idx2object​(int idx)
      Description copied from interface: ReducedIndex
      Gets the object corresponding to a certain index.
      Specified by:
      idx2object in interface ReducedIndex<V>
      Parameters:
      idx - The index.
      Returns:
      the object corresponding to the index.
    • getIndex

      public Index<V> getIndex()
      Obtains the index for the vertices.
      Specified by:
      getIndex in interface FastGraph<V>
      Returns:
      the index for the vertices.
    • getEdgeWeight

      public double getEdgeWeight​(int uidx, int vidx)
      Description copied from interface: FastGraph
      Obtains the weight of an edge, given the identifiers of the involved nodes.
      Specified by:
      getEdgeWeight in interface FastGraph<V>
      Parameters:
      uidx - identifier of the first user.
      vidx - identifier of the second user.
      Returns:
      the weight if it exists, an error value otherwise.
    • getNeighborhood

      public java.util.stream.Stream<java.lang.Integer> getNeighborhood​(int uidx, EdgeOrientation orientation)
      Description copied from interface: FastGraph
      Obtains the neighborhood of a node, given its identifier.
      Specified by:
      getNeighborhood in interface FastGraph<V>
      Parameters:
      uidx - the identifier of the node.
      orientation - the orientation of the neighborhood to retrieve.
      Returns:
      an stream containing the neighbors of the node.
    • getNeighborhoodWeights

      public java.util.stream.Stream<es.uam.eps.ir.ranksys.fast.preference.IdxPref> getNeighborhoodWeights​(int uidx, EdgeOrientation orientation)
      Description copied from interface: FastGraph
      Obtains the neighborhood of a node and the weight of the edges to each other, given its identifier.
      Specified by:
      getNeighborhoodWeights in interface FastGraph<V>
      Parameters:
      uidx - the identifier of the node.
      orientation - the orientation of the neighborhood to retrieve.
      Returns:
      an stream containing the weights of neighbors of the node.
    • getNeighborhoodTypes

      public java.util.stream.Stream<EdgeType> getNeighborhoodTypes​(int uidx, EdgeOrientation orientation)
      Description copied from interface: FastGraph
      Obtains the neighborhood of a node and the type of the edges to each other, given its identifier.
      Specified by:
      getNeighborhoodTypes in interface FastGraph<V>
      Parameters:
      uidx - the identifier of the node.
      orientation - the orientation of the neighborhood to retrieve.
      Returns:
      an stream containing the edge types of the neighbors of the node.
    • getAllNodesIds

      public java.util.stream.IntStream getAllNodesIds()
      Description copied from interface: FastGraph
      Obtains the identifiers of all the nodes in the network.
      Specified by:
      getAllNodesIds in interface FastGraph<V>
      Returns:
      an stream containing the vertex identifiers.
    • containsEdge

      public boolean containsEdge​(int uidx, int vidx)
      Description copied from interface: FastGraph
      Checks whether the network contains an edge or not.
      Specified by:
      containsEdge in interface FastGraph<V>
      Parameters:
      uidx - the identifier of the first vertex
      vidx - the identifier of the second vertex
      Returns:
      true if the edge exists, false otherwise.
    • addEdge

      public boolean addEdge​(int nodeA, int nodeB, double weight, int type)
      Description copied from interface: FastGraph
      Uncontrolled edge addition method, using ids.
      Specified by:
      addEdge in interface FastGraph<V>
      Parameters:
      nodeA - Identifier of the first node.
      nodeB - Identifier of the second node.
      weight - Weight of the link.
      type - Type of the link.
      Returns:
      true if everything went ok, false otherwise.
    • updateEdgeWeight

      public boolean updateEdgeWeight​(int nodeA, int nodeB, double weight)
      Description copied from interface: FastGraph
      Uncontrolled edge update method, using ids.
      Specified by:
      updateEdgeWeight in interface FastGraph<V>
      Parameters:
      nodeA - Identifier of the first node.
      nodeB - Identifier of the second node.
      weight - Weight of the link.
      Returns:
      true if everything went ok, false otherwise.
    • getIsolatedNodes

      public java.util.stream.Stream<V> getIsolatedNodes()
      Description copied from interface: Graph
      Obtains the set of nodes without edges.
      Specified by:
      getIsolatedNodes in interface Graph<V>
      Returns:
      the set of nodes without edges.
    • getNodesWithNeighbors

      public java.util.stream.Stream<V> getNodesWithNeighbors​(EdgeOrientation direction)
      Description copied from interface: Graph
      Obtains the set of nodes with edges in a particular direction.
      Specified by:
      getNodesWithNeighbors in interface Graph<V>
      Parameters:
      direction - the particular direction
      Returns:
      the set of nodes with edges in the given direction.
    • getNodesIdsWithEdges

      public java.util.stream.IntStream getNodesIdsWithEdges​(EdgeOrientation direction)
      Description copied from interface: FastGraph
      Obtains the identifiers of the nodes which have edges.
      Specified by:
      getNodesIdsWithEdges in interface FastGraph<V>
      Parameters:
      direction - the orientation selection.
      Returns:
      a stream containing the corresponding nodes.
    • getIsolatedNodeIds

      public java.util.stream.IntStream getIsolatedNodeIds()
      Description copied from interface: FastGraph
      Obtains the set of isolated nodes in the graph.
      Specified by:
      getIsolatedNodeIds in interface FastGraph<V>
      Returns:
      a stream containing the isolated nodes.
    • getNodesWithAdjacentNeighbors

      public java.util.stream.Stream<V> getNodesWithAdjacentNeighbors()
      Description copied from interface: Graph
      Obtains the set of nodes which have adjacent edges.
      Specified by:
      getNodesWithAdjacentNeighbors in interface Graph<V>
      Returns:
      the set of nodes which have adjacent edges.
    • getNodesWithIncidentNeighbors

      public java.util.stream.Stream<V> getNodesWithIncidentNeighbors()
      Description copied from interface: Graph
      Obtains the set of nodes which have incident edges.
      Specified by:
      getNodesWithIncidentNeighbors in interface Graph<V>
      Returns:
      the set of nodes which have incident edges.
    • getNodesWithNeighbors

      public java.util.stream.Stream<V> getNodesWithNeighbors()
      Description copied from interface: Graph
      Obtains the set of nodes having either incident or adjacent edges.
      Specified by:
      getNodesWithNeighbors in interface Graph<V>
      Returns:
      the set of nodes which have incident or adjacent edges.
    • getNodesWithMutualNeighbors

      public java.util.stream.Stream<V> getNodesWithMutualNeighbors()
      Description copied from interface: Graph
      Obtains the set of nodes having mutual edges.
      Specified by:
      getNodesWithMutualNeighbors in interface Graph<V>
      Returns:
      the set of nodes which have mutual edges.
    • hasAdjacentNeighbors

      public boolean hasAdjacentNeighbors​(V u)
      Description copied from interface: Graph
      Checks if the user has adjacent edges or not.
      Specified by:
      hasAdjacentNeighbors in interface Graph<V>
      Parameters:
      u - The user.
      Returns:
      true if the user has adjacent edges, false if it is a sink or isolated node.
    • hasIncidentNeighbors

      public boolean hasIncidentNeighbors​(V u)
      Description copied from interface: Graph
      Checks if the user has incident edges or not.
      Specified by:
      hasIncidentNeighbors in interface Graph<V>
      Parameters:
      u - the user.
      Returns:
      true if the user has incident edges, false if it is a source or isolated node.
    • hasNeighbors

      public boolean hasNeighbors​(V u)
      Description copied from interface: Graph
      Checks if the user shares at least an edge with other user.
      Specified by:
      hasNeighbors in interface Graph<V>
      Parameters:
      u - The user.
      Returns:
      true if the user is not isolated, false otherwise.
    • hasMutualNeighbors

      public boolean hasMutualNeighbors​(V u)
      Description copied from interface: Graph
      Checks if the user has mutual edges.
      Specified by:
      hasMutualNeighbors in interface Graph<V>
      Parameters:
      u - The user.
      Returns:
      true if the user has mutual edges, false otherwise.
    • complement

      public Graph<V> complement()
      Description copied from interface: Graph
      Complements the graph
      Specified by:
      complement in interface Graph<V>
      Returns:
      the complementary graph.
    • getAdjacencyMatrixMap

      public Index<V> getAdjacencyMatrixMap()
      Description copied from interface: Graph
      For an adjacency matrix, obtains the mapping between indexes and nodes.
      Specified by:
      getAdjacencyMatrixMap in interface Graph<V>
      Returns:
      the mapping between indexes and nodes.